aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsck_ffs/setup.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Add the '-C' "check clean" flag. If the FS is marked clean, skip fileDavid E. O'Brien2009-01-301-2/+2
| | | | | | | | | | | system checking. However, if the file system is not clean, perform a full fsck. Reviewed by: delphij Obtained from: Juniper Networks Notes: svn path=/head/; revision=187931
* Be more careful when checking superblock. We have already checkedXin LI2008-02-261-1/+1
| | | | | | | | | | | | | | | | | | | | whether fs_bsize is larger than MINBSIZE, which is larger than the value that is used to compared with fs_bsize, the sizeof fs, so the check followed, will be always true. By inspecting the code and some old commit log, I believe that the check must be that *fs_sbsize* is larger than sizeof fs. We round up the size to nearest dev_bsize, as the smallest accepted fs_sbsize, personally, I think this can be even changed to equal, because this number is mostly an invariant in file systems. With this check, fsck_ffs(8) will be more picky and has better chance rejecting bad first superblock rather than referring to bad value it supplied, thus gives better chance for it to check the filesystem carefully. Notes: svn path=/head/; revision=176573
* Implements gjournal support. If file system has gjournal support enabledPawel Jakub Dawidek2006-10-311-3/+3
| | | | | | | | | | | | | and -p flag was given perform fast file system checking (bascially only garbage collecting of orphaned objects). Rename bread() to blread() and bwrite() to blwrite() as we now link to the libufs library, which also implement functions with that names. Sponsored by: home.pl Notes: svn path=/head/; revision=163845
* Make background fsck based summary adjustments actually work byXin LI2005-03-071-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | initializing the sysctl mibs data before actually using them. The original patchset (which is the actual version that is running on my testboxes) have checked whether all of these sysctls and refuses to do background fsck if we don't have them. Kirk has pointed out that refusing running fsck on old kernels is pointless, as old kernels will recompute the summary at mount time, so I have removed these checks. Unfortunatelly, as the checks will initialize the mib values of those sysctl's, and which are vital for the runtime summary adjustment to work, we can not simply remove the check, which will lead to problem when running background fsck over a dirty volume. Add these checks in a different way: give a warning rather than refusing to work, and complain if the functionality is not available when adjustments are necessary. Noticed by: A power failure at my lab Pointy hat: me MFC After: 3 days Notes: svn path=/head/; revision=143235
* Generalize the UFS bad magic value used to determine when a filesystemJohn Baldwin2004-08-191-2/+2
| | | | | | | | | | | has only been partly initialized via newfs(8) so that it applies to both UFS1 and UFS2. Submitted by: "Xin LI" delphij at frontfree dot net MFC: maybe? Notes: svn path=/head/; revision=134011
* Remove advertising clause from University of California Regent's license,Mark Murray2004-04-091-4/+0
| | | | | | | | | per letter dated July 22, 1999. Approved by: core, imp Notes: svn path=/head/; revision=128073
* Avoid dereferencing null pointers in fsck_ffs. (pfatal may return,Colin Percival2004-01-261-0/+5
| | | | | | | | | | so it isn't a safe way of handling [mc]alloc failures.) PR: misc/61800 Approved by: rwatson (mentor) Notes: svn path=/head/; revision=125036
* Catch and report on filesystems that were interrupted during newfs,Wes Peters2003-11-161-0/+12
| | | | | | | | sporting the new 'BAD' magic number. Exit with a unique error code (11) so callers who care about this can respond appropriately. Notes: svn path=/head/; revision=122784
* Spell "file system" correctly.Ruslan Ermilov2003-08-011-1/+1
| | | | Notes: svn path=/head/; revision=118302
* Use __FBSDID() to quiet GCC 3.3 warnings.David E. O'Brien2003-05-031-4/+4
| | | | Notes: svn path=/head/; revision=114589
* Verify that alternate superblocks have a correct magic number beforeKirk McKusick2002-12-021-9/+10
| | | | | | | | | | | | trying to use them. Set a minimum value for numdirs when using an alternate superblock to avoid spurious numdirs == 0 error. Calculate new fields when using an alternate superblock from a UFS1 filesystem to avoid segment faulting. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=107518
* Create a new 32-bit fs_flags word in the superblock. Add code to moveKirk McKusick2002-11-271-2/+1
| | | | | | | | | | | | | | | | | | | | the old 8-bit fs_old_flags to the new location the first time that the filesystem is mounted by a new kernel. One of the unused flags in fs_old_flags is used to indicate that the flags have been moved. Leave the fs_old_flags word intact so that it will work properly if used on an old kernel. Change the fs_sblockloc superblock location field to be in units of bytes instead of in units of filesystem fragments. The old units did not work properly when the fragment size exceeeded the superblock size (8192). Update old fs_sblockloc values at the same time that the flags are moved. Suggested by: BOUWSMA Barry <freebsd-misuser@netscum.dyndns.dk> Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=107294
* When verifying a superblock, the lower bound on block size is MINBSIZEKirk McKusick2002-10-101-1/+1
| | | | | | | | | | (4096), not SBLOCKSIZE (8192). Submitted by: Tor.Egge@cvsup.no.freebsd.org Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=104745
* Use the standardized CHAR_BIT constant instead of NBBY in userland.Mike Barcroft2002-09-251-1/+2
| | | | Notes: svn path=/head/; revision=103949
* s/filesystem/file system/g as discussed on -developersTom Rhodes2002-08-211-4/+4
| | | | Notes: svn path=/head/; revision=102231
* Fix more breakage due to FSTYPENAMES/DKTYPENAMES split.Bosko Milekic2002-08-161-0/+1
| | | | | | | Also submitted by: David Wolfskill <david@catwhisker.org> Notes: svn path=/head/; revision=101994
* Don't '#define DKTYPENAMES', we don't use the variable it exposes fromAlfred Perlstein2002-08-161-1/+0
| | | | | | | the header file. Notes: svn path=/head/; revision=101970
* Fix a bunch of format string warnings which brokeMaxime Henrion2002-07-311-2/+3
| | | | | | | | | the sparc64 build. Tested on: sparc64, i386 Notes: svn path=/head/; revision=101037
* Warning cleanup.Poul-Henning Kamp2002-07-301-3/+2
| | | | | | | Format changes by peter Notes: svn path=/head/; revision=100935
* This commit adds basic support for the UFS2 filesystem. The UFS2Kirk McKusick2002-06-211-38/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | filesystem expands the inode to 256 bytes to make space for 64-bit block pointers. It also adds a file-creation time field, an ability to use jumbo blocks per inode to allow extent like pointer density, and space for extended attributes (up to twice the filesystem block size worth of attributes, e.g., on a 16K filesystem, there is space for 32K of attributes). UFS2 fully supports and runs existing UFS1 filesystems. New filesystems built using newfs can be built in either UFS1 or UFS2 format using the -O option. In this commit UFS1 is the default format, so if you want to build UFS2 format filesystems, you must specify -O 2. This default will be changed to UFS2 when UFS2 proves itself to be stable. In this commit the boot code for reading UFS2 filesystems is not compiled (see /sys/boot/common/ufsread.c) as there is insufficient space in the boot block. Once the size of the boot block is increased, this code can be defined. Things to note: the definition of SBSIZE has changed to SBLOCKSIZE. The header file <ufs/ufs/dinode.h> must be included before <ufs/ffs/fs.h> so as to get the definitions of ufs2_daddr_t and ufs_lbn_t. Still TODO: Verify that the first level bootstraps work for all the architectures. Convert the utility ffsinfo to understand UFS2 and test growfs. Add support for the extended attribute storage. Update soft updates to ensure integrity of extended attribute storage. Switch the current extended attribute interfaces to use the extended attribute storage. Add the extent like functionality (framework is there, but is currently never used). Sponsored by: DARPA & NAI Labs. Reviewed by: Poul-Henning Kamp <phk@freebsd.org> Notes: svn path=/head/; revision=98542
* UFS2 preparation commit:Poul-Henning Kamp2002-05-121-75/+5
| | | | | | | | | | Remove support for converting old FFS formats to newer. Submitted by: mckusick Sponspored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=96483
* Retire the bogus uses of the disklabel field d_sbsize and begin toPoul-Henning Kamp2002-05-121-3/+0
| | | | | | | | | | initialize it to zero so we don't have to have everbody and their aunt including FFS specific header files. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=96475
* When checking the alternate superblock, we used to copy any fieldsKirk McKusick2002-04-071-61/+25
| | | | | | | | | | | | | | | | | that might have changed, then did a byte-by-byte comparison with the alternate. If any unused fields got used, they had to be added to the exception list. Such changes caused too many false alarms. So, I have changed the comparison algorithm to compare a selected set of fields that are not expected to change. This new algorithm causes far fewer false hits and still does a good job of detecting problems when they have really occurred. In particular, this change should ease the transition to kernels supporting UFS2 which make some significant changes to the superblock. Sponsored by: DARPA, NAI Labs Notes: svn path=/head/; revision=94031
* o __P removedWarner Losh2002-03-201-18/+9
| | | | | | | | | | o ansi function prototypes o unifdef -D__STDC__ o __dead2 on usage prototype o remove now-bogus main prototype Notes: svn path=/head/; revision=92839
* Remove 'register' keyword.David E. O'Brien2002-03-201-4/+4
| | | | | | | | | It does not help modern compilers, and some may take some hit from it. (I also found several functions that listed *every* of its 10 local vars with "register" -- just how many free registers do people think machines have?) Notes: svn path=/head/; revision=92806
* Ignore the value of fs_active when comparing superblocks.Ian Dowse2001-12-171-0/+1
| | | | | | | Noticed by: "Niels Chr. Bank-Pedersen" <ncbp@bank-pedersen.dk> Notes: svn path=/head/; revision=88031
* Fix a large number of -Wall, -Wformat and -W compiler warnings.Ian Dowse2001-11-171-1/+3
| | | | | | | | | | | | These were mainly missing casts or wrong format strings in printf statements, but there were also missing includes, unused variables, functions and arguments. The choice of `long' vs `int' still seems almost random in a lot of places though. Notes: svn path=/head/; revision=86514
* Ignore the new superblock fields fs_pendingblocks and fs_pendinginodesIan Dowse2001-05-291-0/+2
| | | | | | | | | | when comparing with the alternate superblock. These fields are used for temporary in-core information only. This should fix the "VALUES IN SUPER BLOCK DISAGREE WITH THOSE IN FIRST ALTERNATE" error from fsck_ffs that has been seen a lot recently. Notes: svn path=/head/; revision=77436
* In fsdb, call sblock_init() which is now necessary to initialiseIan Dowse2001-04-231-0/+1
| | | | | | | | the global variable dev_bsize. Add a prototype for sblock_init() to fsck.h, and set the return type correctly. Notes: svn path=/head/; revision=75884
* Minor background cleanups:Kirk McKusick2001-04-161-18/+22
| | | | | | | | | | | | | | 1) Set the FS_NEEDSFSCK flag when unexpected problems are encountered. 2) Clear the FS_NEEDSFSCK flag after a successful foreground cleanup. 3) Refuse to run in background when the FS_NEEDSFSCK flag is set. 4) Avoid taking and removing a snapshot when the filesystem is already clean. 5) Properly implement the force cleaning (-f) flag when in preen mode. Note that you need to have revision 1.21 (date: 2001/04/14 05:26:28) of fs.h installed in <ufs/ffs/fs.h> defining FS_NEEDSFSCK for this to compile. Notes: svn path=/head/; revision=75557
* Catch up to the dirpref changes by copying new fields in the alternateJohn Baldwin2001-04-101-0/+3
| | | | | | | | superblock from the original superblock so that differences in those new fields are ignored. Notes: svn path=/head/; revision=75395
* Additions to run checks on live filesystems. This change will notKirk McKusick2001-03-211-7/+55
| | | | | | | | | | | | affect current systems until fsck is modified to use these new facilities. To try out this change, set the fsck passno to zero in /etc/fstab to cause the filesystem to be mounted without running fsck, then run `fsck_ffs -p -B <filesystem>' after the system has been brought up multiuser to run a background cleanup on <filesystem>. Note that the <filesystem> in question must have soft updates enabled. Notes: svn path=/head/; revision=74556
* Fsck_ffs did not properly range-check the inode 'di_size'Ian Dowse2001-01-311-0/+2
| | | | | | | | | | | | | | | | | | | | | | field, so it was possible for a filesystem marked clean by fsck_ffs to cause kernel crashes later when mounted. This could occur when fsck_ffs was used to repair a badly corrupted filesystem. As pointed out by bde, it is not sufficient to restrict di_size to just the superblock fs_maxfilesize limit. The use of 32-bit logical block numbers (both in fsck and the kernel) induces another file size limit which is usually lower than fs_maxfilesize. Also, the old 4.3BSD filesystem does not have fs_maxfilesize initialised. Following this change, fsck_ffs will enforce exactly the same file size limits as are used by the kernel. PR: kern/15065 Discussed with: bde Reviewed by: bde, mckusick Notes: svn path=/head/; revision=71884
* The ffs superblock includes a 128-byte region for use by temporaryIan Dowse2001-01-151-3/+4
| | | | | | | | | | | | | | | | | | | | | | | in-core pointers to summary information. An array in this region (fs_csp) could overflow on filesystems with a very large number of cylinder groups (~16000 on i386 with 8k blocks). When this happens, other fields in the superblock get corrupted, and fsck refuses to check the filesystem. Solve this problem by replacing the fs_csp array in 'struct fs' with a single pointer, and add padding to keep the length of the 128-byte region fixed. Update the kernel and userland utilities to use just this single pointer. With this change, the kernel no longer makes use of the superblock fields 'fs_csshift' and 'fs_csmask'. Add a comment to newfs/mkfs.c to indicate that these fields must be calculated for compatibility with older kernels. Reviewed by: mckusick Notes: svn path=/head/; revision=71073
* Teach fsck about snapshot files. These changes should have noKirk McKusick2000-07-061-3/+10
| | | | | | | | | | effect on operation of fsck on filesystems without snapshots. If you get compilation errors, be sure that you have copies of /usr/include/sys/mount.h (1.94), /usr/include/sys/stat.h (1.21), and /usr/include/ufs/ffs/fs.h (1.16) as of July 4, 2000 or later. Notes: svn path=/head/; revision=62668
* Yesterday I had to fix a badly broken disk, and found that fsck kept dying:Kirk McKusick2000-02-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DIR I=64512 CONNECTED. PARENT WAS I=4032 fsck: cannot find inode 995904 fsdb found the inodes with no problem: fsdb (inum: 64512)> inode 995904 current inode: directory I=995904 MODE=40777 SIZE=512 MTIME=Feb 14 15:27:07 2000 [0 nsec] CTIME=Feb 14 15:27:07 2000 [0 nsec] ATIME=Feb 24 10:31:58 2000 [0 nsec] OWNER=nobody GRP=nobody LINKCNT=4 FLAGS=0 BLKCNT=2 GEN=38a41386 Direct blocks: 8094568 0 0 0 0 0 0 0 0 0 0 0 Indirect blocks: 0 0 0 The problem turns out to be a program logic error in fsck. It stores directory inodes internally in hash lists, using the number of directories to form the hash key: inpp = &inphead[inumber % numdirs]; Elsewhere, however, it increments numdirs when it finds unattached directories. I've made the following fix, which solved the problem in the case in hand. Submitted by: Greg Lehey <grog@lemis.com> Reviewed by: Matthew Dillon <dillon@apollo.backplane.com> Approved by: Kirk McKusick <mckusick@mckusick.com> Notes: svn path=/head/; revision=57573
* Make fsck even more char/blk dev tolerant.Poul-Henning Kamp1999-11-271-2/+3
| | | | Notes: svn path=/head/; revision=53781
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50476
* Cosmetic and documentation changes brought from earlier FreeBSD versions.Julian Elischer1998-12-031-1/+4
| | | | | | | (e.g. RCS Id:) Notes: svn path=/head/; revision=41477
* Reviewed by: Don Lewis <Don.Lewis@tsc.tdk.com>Julian Elischer1998-12-031-32/+17
| | | | | | | | | | | | | | | Submitted by: Kirk McKusick <mckusick@McKusick.COM> Obtained from: Mckusick, BSDI and a host of others This exactly matches Kirks sources imported under the Tag MCKUSICK2. These are as supplied by kirk with one small change needed to compile under freeBSD. Some FreeBSD patches will be added back, though many have been added to Kirk's sources already. Notes: svn path=/head/; revision=41474
* Fixed printf format errors.Bruce Evans1998-06-281-2/+3
| | | | Notes: svn path=/head/; revision=37236
* Correct use of .Nm. Add rcsid. Remove unused #includes. Use err(3).Philippe Charnier1998-06-151-2/+4
| | | | Notes: svn path=/head/; revision=37000
* Reviewed by: dyson@freebsd.org (john Dyson), dg@root.com (david greenman)Julian Elischer1998-03-081-1/+7
| | | | | | | | Submitted by: Kirk McKusick (mcKusick@mckusick.com) Obtained from: WHistle development tree Notes: svn path=/head/; revision=34266
* If numdirs is zero, print a helpful message instead of divding by zero later.Poul-Henning Kamp1998-03-041-0/+4
| | | | Notes: svn path=/head/; revision=34033
* Guard against a block size of 0 in the label. When the firstBruce Evans1998-01-191-0/+5
| | | | | | | | | | | | | | | | | | | | superblock is invalid, fsck looks at the label to help guess where the next superblock should be. If the partition type is 4.2BSD, fsck assumed that the block size was valid and divided by it, so it dumped core if the size was 0. Initialization of the label was broken almost 3 years ago in rev.1.9 of newfs/newfs.c. Newfs does not change the label at all, so there is no problem (except the breakage of the automatic search for backup superblocks) unless something else sets the partition type to 4.2BSD. However, it is too easy to set partition types to 4.2.BSD by copying an old label or by using a disktab entry to create the label. PR: 2537 Notes: svn path=/head/; revision=32622
* Kill the Lite2 early "filesystem clean abort" check and go back toPeter Wemm1997-03-131-4/+6
| | | | | | | | | | | something closer to how we used to do it. The Lite2 way is to check the "fsclean" flag in the superblock and stop there if so (during preen). We now do the various superblock sanity checks that we used to do before since it's cheap. We now get the filesystem state summary again instead of "FILESYSTEM CLEAN; CHECKING SKIPPED" (or whatever). Notes: svn path=/head/; revision=23844
* Finished (?) merging with Lite2: cleaned up #include mess.Bruce Evans1997-03-121-2/+0
| | | | Notes: svn path=/head/; revision=23799
* Merge from Lite2. Note that Lite2 has it's own filesystem clean checkPeter Wemm1997-03-111-33/+60
| | | | | | | | skipping code that overrides ours sooner. One should be eliminated, but for now it works. Notes: svn path=/head/; revision=23675
* Remove trailing whitespace.Rodney W. Grimes1995-05-301-4/+4
| | | | Notes: svn path=/head/; revision=8871
* Submitted by: phk, added to by bdeBruce Evans1995-04-021-4/+14
| | | | | | | Fix all the warnings from `gcc -Wall'. Notes: svn path=/head/; revision=7585