History log of /freebsd-10.0-release/sbin/fsck_ffs/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
259065 07-Dec-2013 gjb

- Copy stable/10 (r259064) to releng/10.0 as part of the
10.0-RELEASE cycle.
- Update __FreeBSD_version [1]
- Set branch name to -RC1

[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so
start releng/10.0 at '100' so the branch is started with
a value ending in zero.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


254553 20-Aug-2013 des

Fix the zeroing loop. I must have been drunk when I wrote this...

MFC after: 3 days


253828 31-Jul-2013 scottl

Document the -S flag to fsck_ffs

Obtained from: Netflix


253822 30-Jul-2013 scottl

Add a 'surrender' mode to fsck_ffs. With the -S flag, once hard read errors
are encountered, the fsck will stop instead of wasting time chewing through
possibly other errors.

Obtained from: Netflix
MFC after: 3 days


250057 29-Apr-2013 des

Style nit.


250056 29-Apr-2013 des

Add a -Z option which zeroes unused blocks. It can be combined with -E,
in which case unused blocks are first zeroed and then erased.

Reviewed by: mckusick
MFC after: 3 weeks


248691 24-Mar-2013 mckusick

Note that output is in seconds, not msec.
KNF indentation.
No functional change.
No change to printf strings.
No change to casting of printf arguments.

Reported by: Bruce Evans


248680 24-Mar-2013 sbruno

Resolve clang compile errors on amd64/i386 for certain by casting.

compile tested with clang on i386, amd64
compile tested with gcc on i386, amd64, sparc64

Submitted by: delphij


248673 24-Mar-2013 sbruno

Minor formatting fix for printf() to fix clang builds.

Submitted by: db
Reviewed by: gjb


248658 23-Mar-2013 mckusick

Revert 248634 and 248643 (e.g., restoring 248625 and 248639).

Build verified by: Glen Barber (gjb@)


248634 23-Mar-2013 sbruno

Revert svn r248625

Clang errors around printf could be trivially fixed, but the breakage in
sbin/fsdb were to significant for this type of change.

Submitter of this changeset has been notified and hopefully this can be
restored soon.


248625 22-Mar-2013 mckusick

Speed up fsck by caching the cylinder group maps in pass1 so
that they do not need to be read again in pass5. As this nearly
doubles the memory requirement for fsck, the cache is thrown away
if other memory needs in fsck would otherwise fail. Thus, the
memory footprint of fsck remains unchanged in memory constrained
environments.

This work was inspired by a paper presented at Usenix's FAST '13:
www.usenix.org/conference/fast13/ffsck-fast-file-system-checker

Details of this implementation appears in the April 2013 of ;login:
www.usenix.org/publications/login/april-2013-volume-38-number-2.
A copy of the April 2013 ;login: paper can also be downloaded
from: www.mckusick.com/publications/faster_fsck.pdf.

Reviewed by: kib
Tested by: Peter Holm
MFC after: 4 weeks


247269 25-Feb-2013 kientzle

Fix ARM build by assigning the computed time here to
a variable of the right type for printf.


247212 24-Feb-2013 mckusick

When running with the -d option, instrument fsck_ffs to track the number,
data type, and running time of its I/O operations.

No functional changes.


246812 15-Feb-2013 mckusick

Update fsck_ffs buffer cache manager to use TAILQ macros.
No functional changes.


243017 14-Nov-2012 jeff

- blk_equals() is too strict. If the journal entry defines more frags
than we're claiming it should still be considered an exact match. This
would previously leak frags that had been extended.
- If there is a sequence number problem in the journal print the sequence
numbers we've seen so far for debugging.
- Clean up the block mask related debuging printfs. Some are redundant.

MFC after: 1 week


241035 28-Sep-2012 mdf

Fix some nearby type and style errors.

Pointed out by: bde


241013 27-Sep-2012 mdf

Fix sbin/ build with a 64-bit ino_t.

Original code by: Gleb Kurtsou


241012 27-Sep-2012 mdf

Fix fsck_ffs build with a 64-bit ino_t.

Original code by: Gleb Kurtsou


240463 13-Sep-2012 zont

- Fix a typo in debug message.

Approved by: kib (mentor)
MFC after: 3 days


240406 12-Sep-2012 obrien

Remove needless (int) casts of write(2)'s 3rd argument.
Also change blwrite() 'size' parameter to a ssize_t to better match
write(2).


240405 12-Sep-2012 obrien

Simply printf-like strings and outdent strings so that it is easy to see
if they fit on a standard terminal.


238984 02-Aug-2012 kib

fsck_ffs shall accept the configured journal size, and not refuse to
operate on it if journal size is greater then SUJ_MAX. The later
constant is only to select maximal journal size when user did not
specified size explicitely.

Submitted by: Andrey Zonov <andrey@zonov.org>
Reviewed by: mckusick
MFC after: 1 week


236976 12-Jun-2012 kib

For incompleted block allocations or frees, the inode block count usage
must be recalculated. The blk_check pass of suj checker explicitely marks
inodes which owned such blocks as needing block count adjustment. But
ino_adjblks() is only called by cg_trunc pass, which is performed before
blk_check. As result, the block use count for such inodes is left wrong.
This causes full fsck run after journaled run to still find inconsistencies
like 'INCORRECT BLOCK COUNT I=14557 (328 should be 0)' in phase 1.

Fix this issue by running additional adj_blk pass after blk_check, which
updates the field.

Reviewed by: jeff, mckusick
MFC after: 1 week


231377 10-Feb-2012 trasz

Be more helpful about alternate superblocks.


229918 10-Jan-2012 eadler

Fix warning when compiling with gcc46:
error: variable 'blksfree' set but not used

Reviewed by: pjd
Approved by: dim
MFC after: 3 days


229778 07-Jan-2012 uqs

Spelling fixes for sbin/


229403 03-Jan-2012 ed

Replace index() and rindex() calls with strchr() and strrchr().

The index() and rindex() functions were marked LEGACY in the 2001
revision of POSIX and were subsequently removed from the 2008 revision.
The strchr() and strrchr() functions are part of the C standard.

This makes the source code a lot more consistent, as most of these C
files also call into other str*() routines. In fact, about a dozen
already perform strchr() calls.


228751 20-Dec-2011 kib

Change the type of real_dev_bsize variable from long to u_int.
The DIOCGSECTORSIZE takes u_int * as an argument, using long *
causes failures on big-endian targets.

Diagnosed by: Michiel Boland <boland37 xs4all nl>
PR: sparc64/163460
Tested by: pho (x86), flo (sparc64)
MFC after: 1 week


225359 03-Sep-2011 des

Forgot this nit in r221107.

Approved by: re (kib)


225338 02-Sep-2011 delphij

Fix the check in dircheck() on namlen.

The value of namlen is copied from on-disk d_namlen, which is a 8-bit
unsigned integer which can never exceed MAXNAMLEN (255) so the test is
always true. Moreover, UFS does not allow d_namelen being zero.

Change namlen from u_int to u_int8_t, and replace the unneeded test
with a useful test.

PR: bin/160339
Submitted by: Eugene Grosbein <eugen grosbein.pp.ru>
MFC after: 2 weeks
Approved by: re (kib)


224059 15-Jul-2011 mckusick

Break out the pass 5 inode and block map updating into a separate function
so that the function can be used by the journaling soft updates recovery.


223689 30-Jun-2011 jeff

- Handle the JOP_SYNC case as appropriate.

Reported by: pho


222958 10-Jun-2011 jeff

Implement fully asynchronous partial truncation with softupdates journaling
to resolve errors which can cause corruption on recovery with the old
synchronous mechanism.

- Append partial truncation freework structures to indirdeps while
truncation is proceeding. These prevent new block pointers from
becoming valid until truncation completes and serialize truncations.
- On completion of a partial truncate journal work waits for zeroed
pointers to hit indirects.
- softdep_journal_freeblocks() handles last frag allocation and last
block zeroing.
- vtruncbuf/ffs_page_remove moved into softdep_*_freeblocks() so it
is only implemented in one place.
- Block allocation failure handling moved up one level so it does not
proceed with buf locks held. This permits us to do more extensive
reclaims when filesystem space is exhausted.
- softdep_sync_metadata() is broken into two parts, the first executes
once at the start of ffs_syncvnode() and flushes truncations and
inode dependencies. The second is called on each locked buf. This
eliminates excessive looping and rollbacks.
- Improve the mechanism in process_worklist_item() that handles
acquiring vnode locks for handle_workitem_remove() so that it works
more generally and does not loop excessively over the same worklist
items on each call.
- Don't corrupt directories by zeroing the tail in fsck. This is only
done for regular files.
- Push a fsync complete record for files that need it so the checker
knows a truncation in the journal is no longer valid.

Discussed with: mckusick, kib (ffs_pages_remove and ffs_truncate parts)
Tested by: pho


221233 29-Apr-2011 des

Add an -E option to mirror newfs's. The idea is that if you have a system
that was built before ffs grew support for TRIM, your filesystem will have
plenty of free blocks that the flash chip doesn't know are free, so it
can't take advantage of them for wear leveling. Once you've upgraded your
kernel, you enable TRIM on the filesystem (tunefs -t enable), then run
fsck_ffs -E on it before mounting it.

I tested this patch by half-filling an mdconfig'ed filesystem image,
running fsck_ffs -E on it, then verifying that the contents were not
damaged by comparing them to a pristine copy using rsync's checksum
functionality. There is no reliable way to test it on real hardware.

Many thanks to mckusick@, who provided the tricky parts of this patch and
reviewed the final version.

Reviewed by: mckusick@
MFC after: 3 weeks


221110 27-Apr-2011 des

Mechanical whitespace cleanup.

MFC after: 3 weeks


221108 27-Apr-2011 des

Fix boo-boo in previous commit.

MFC after: 3 weeks


221107 27-Apr-2011 des

Alphabetize the options. No date bump since no actual change to the text.

MFC after: 3 weeks


218604 12-Feb-2011 kib

In checker, read journal by sectors.

Due to UFS insistence to pretend that device sector size is 512 bytes,
sector size is obtained from ioctl(DIOCGSECTORSIZE) for real devices,
and from the label otherwise. The file images without label have to
be made with 512 sector size.

In collaboration with: pho
Reviewed by: jeff
Tested by: bz, pho


217769 24-Jan-2011 mckusick

The dump, fsck_ffs, fsdb, fsirand, newfs, makefs, and quot utilities
include sys/time.h instead of time.h. This include is incorrect as
per the manpages for the APIs and the POSIX definitions. This commit
replaces sys/time.h where necessary with time.h.

The commit also includes some minor style(9) header fixup in newfs.

This commit is part of a larger effort by Garrett Cooper started in
//depot/user/gcooper/posix-conformance-work/ -- to make FreeBSD more
POSIX compliant.

Submitted by: Garrett Cooper yanegomi at gmail dot com


216178 04-Dec-2010 uqs

Move most of the remaining USD/PSD/SMM papers into share/doc


211397 16-Aug-2010 joel

Fix typos, spelling, formatting and mdoc mistakes found by Nobuyuki while
translating these manual pages. Minor corrections by me.

Submitted by: Nobuyuki Koganemaru <n-kogane@syd.odn.ne.jp>


210933 06-Aug-2010 joel

Fix typos and spelling mistakes.


210793 03-Aug-2010 bz

One question mark per question; everything else is just exaggerating.
reply() will output a '?', when printing the question along with [yn],
so no need to have another here.


210415 23-Jul-2010 mckusick

Note that foreground fsck should be run after a filesystem related panic.

Suggested by: Mikhail Teterin (mi@)
MFC after: 1 week


209716 06-Jul-2010 jeff

- Permit zero length directories as a handled inconsistency. This allows
directory truncation to proceed before the link has been cleared. This
is accomplished by detecting a directory with no . or .. links and
clearing the named directory entry in the parent.
- Add a new function ino_remref() which handles the details of removing
a reference to an inode as a result of a lost directory. There were
some minor errors in various subcases of this routine.


209408 22-Jun-2010 delphij

Improve fsck robustness for SU+J cases:

- Use err/errx only when the case is really fatal. For other
cases, fall back to full fsck instead of quiting fsck.
- Plug a memory leak.
- Avoid divide by zero when printing summary.
- Output "FILE SYSTEM IS MARKED CLEAN" when a successful
journal recovering is done.
- When -f is specified, do full fsck instead of journal recovery.


208330 20-May-2010 mckusick

Add support to background fsck to delete zero-length directories.


207144 24-Apr-2010 pjd

suj.c seems to contain two versions of the code.
Remove the one that doesn't compile.


207143 24-Apr-2010 pjd

Protect fsck.h from being included twice.


207141 24-Apr-2010 jeff

- Merge soft-updates journaling from projects/suj/head into head. This
brings in support for an optional intent log which eliminates the need
for background fsck on unclean shutdown.

Sponsored by: iXsystems, Yahoo!, and Juniper.
With help from: McKusick and Peter Holm


202131 11-Jan-2010 mckusick

Cast 64-bit quantity to intptr_t rather than int so as to work properly
with 64-bit architectures (such as amd64).

Reported by: Xin LI and Josh Paetzel


202109 11-Jan-2010 mckusick

This update utilizes new fsck sysctl commands that allow fsck running
in background mode to correct expected inconsistencies that arise
during directory rename (see immediately previous update to this
file for details). If run on a kernel without the new functionality,
background fsck will simply ignore these inconsistencies rather
than fail.

Reported by: jeff


202107 11-Jan-2010 mckusick

When renaming a directory it passes through several intermediate
states. First its new name will be created causing it to have two
names (from possibly different parents). Next, if it has different
parents, its value of ".." will be changed from pointing to the old
parent to pointing to the new parent. Concurrently, its old name
will be removed bringing it back into a consistent state. When fsck
encounters an extra name for a directory, it offers to remove the
"extraneous hard link"; when it finds that the names have been
changed but the update to ".." has not happened, it offers to rewrite
".." to point at the correct parent. Both of these changes were
considered unexpected so would cause fsck in preen mode or fsck in
background mode to fail with the need to run fsck manually to fix
these problems.

This update changes these errors to be expected so that in preen
mode fsck will simply fix these transitional errors. For now,
background fsck will note these errors, but will need additional
kernel support to fix them, so will simply ignore them rather than
fail. A future update will allow background fsck to fix these
problems.

Reported by: jeff


201708 07-Jan-2010 mckusick

Add some error messages suggested in PR bin/138043. The code to
correct the problem was added in r176575 by delphij on 2008-02-25.

PR: 138043
Reported by: Heikki Suonsivu


201700 07-Jan-2010 mckusick

This corrects a bug that manifested itself as identifying the last
cylinder group of a UFS1 filesystem as bad. The error was in the check
and not in the cylinder group itself. So even though fsck fixed the
cylinder group correctly, it was still endlessly reported as bad.

PR: 141992
MFC after: 2 weeks
Reported by: Dan Strick


201145 28-Dec-2009 antoine

(S)LIST_HEAD_INITIALIZER takes a (S)LIST_HEAD as an argument.
Fix some wrong usages.
Note: this does not affect generated binaries as this argument is not used.

PR: 137213
Submitted by: Eygene Ryabinkin (initial version)
MFC after: 1 month


193372 03-Jun-2009 pjd

Correct comment.


193325 02-Jun-2009 lulf

- Use volatile for signal variables.

Suggested by: Jaakko Heinonen <jh -at- saunalahti.fi>


193059 29-May-2009 lulf

- Use sig_atomic_t for signal handler variables.

MFC after: 1 week


188110 04-Feb-2009 mckusick

Update the actions previously attempted by the -D option to make them
robust. With these changes fsck is now able to detect and reliably
rebuild corrupted cylinder group maps. The -D option is no longer
necessary as it has been replaced by a prompt asking whether the
corrupted cylinder group should be rebuilt and doing so when requested.
These actions are only offered and taken when running fsck in manual
mode. Corrupted cylinder groups found during preen mode cause the fsck
to fail.

Add the -r option to free up excess unused inodes. Decreasing the
number of preallocated inodes reduces the running time of future
runs of fsck and frees up space that can allocated to files. The -r
option is ignored when running in preen mode.

Reviewed by: Xin LI <delphij@>
Sponsored by: Rsync.net


187931 30-Jan-2009 obrien

Add the '-C' "check clean" flag. If the FS is marked clean, skip file
system checking. However, if the file system is not clean, perform a
full fsck.

Reviewed by: delphij
Obtained from: Juniper Networks


187748 27-Jan-2009 delphij

Follow up with previous commit: mention -D, not -C when cg check
failed.

Submitted by: obrien


187501 20-Jan-2009 delphij

Rename option 'C' to 'D' (damaged) in order to avoid a conflict with upcoming
Juniper 'C' (clean) flag.

Requested by: obrien
MFC after: 1 week


187079 12-Jan-2009 delphij

Fix typo.

Submitted by: Ben Kaduk <minimarmot gmail com>
MFC after: 3 days


186471 24-Dec-2008 obrien

Garbage collect 'fflags'.


183821 13-Oct-2008 kib

Background fsck applies twice some summary totals changes. The next
background fsck on the same file system might then print negative
numbers for reclaimed directories/files/fragments.

Address the issue in a limited degree, by using old summary data for
cg when bgfsck is performed.

Submitted by: tegge
MFC after: 1 week


183820 13-Oct-2008 kib

check_maps() in /usr/src/sbin/fsck_ffs/pass5.c seems to be limited to file
systems less than 1 TB, due to using 32-bits integers for file system block
numbers. This also causes incorrect error reporting for foreground fsck.

Convert it to use ufs2_daddr_t for block numbers.

PR: kern/127951
Submitted by: tegge
MFC after: 1 week


183110 17-Sep-2008 remko

Document the -F 's return statement.
If the application returns succesfully
the return code is 7 (which means the
filesystem is clean).

PR: 127432
Submitted by: edwin
MFC after: 3 days


182027 23-Aug-2008 rodrigc

Instead of passing MNT_UPDATE, MNT_SNAPSHOT, MNT_RELOAD from
userspace to kernel via nmount(), pass in the strings
"update", "snapshot", "reload".

We want to move away from passing MNT_ flags from userspace -> kernel
via nmount(), and instead favor passing the string options.


179656 08-Jun-2008 stas

- Display '-C' option in usage().

Approved by: kib


178088 10-Apr-2008 delphij

Add a new flag, '-C' which enables a special mode that is intended for
catastrophic recovery. Currently, this mode only validates whether a
cylindergroup has good signature data, and prompts the user to decide
whether to clear it as a whole.

This mode is useful when there is data damage on a disk and you are
working on copy of the original disk, as fsck_ffs(8) tends to abnormally
exit in such case, as a last resort to recover data from the disk.


177905 04-Apr-2008 rodrigc

Add comment about specifying "ro" mount option when
doing an update mount on a read-only file system.

Requested by: yar


176822 05-Mar-2008 rodrigc

For a mounted file system which is read-only, when
doing the MNT_RELOAD, pass in "ro" and "update"
string mount options to nmount() instead of MNT_RDONLY and MNT_UPDATE flags.

Due to the complexity of the mount parsing code especially
with respect to the root file system, passing in MNT_RDONLY and MNT_UPDATE
flags would do weird things and would cause fsck to convert the root
file system from a read-only mount to read-write.

To test:
- boot into single user mode
- show mounted file systems with: mount
- root file system should be mounted read-only
- fsck /
- show mounted file systems with: mount
- root file system should still be mounted read-only

PR: 120319
MFC after: 1 month
Reported by: yar


176814 05-Mar-2008 rodrigc

Remove hacks to filter out MNT_ROOTFS, since we now
do that internally inside nmount() in revision 1.267 of vfs_mount.c.


176575 26-Feb-2008 delphij

In pass1(), cap inosused to fs_ipg rather than allowing arbitrary
number read from cylinder group. Chances that we read a smarshed
cylinder group, and we can not 100% trust information it has
supplied. fsck_ffs(8) will crash otherwise for some cases.


176574 26-Feb-2008 delphij

In pass2check(): Be more strict with the inode information before further
processing the information. chk1 is more prone to crash when insane
information is provided by the on-disk inode, and does not even work
if the inode is being smarshed badly.


176573 26-Feb-2008 delphij

Be more careful when checking superblock. We have already checked
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.


172236 19-Sep-2007 rodrigc

Convert fsck_ffs to nmount(). This seems to solve
an intermittent problem where MNT_RELOAD fails
for the root file system.

Reported and tested by: phk
Approved by: re (bmah)


171800 10-Aug-2007 pjd

Fix fscking gjournaled root file system: root file system is already mounted
read-only, so we can't simply exit right after calling gjournal_check(),
instead we need to ask about super block reload.

Submitted by: Niki Denev <niki@totalterror.net>
PR: misc/113889
Approved by: re (kensmith)


163866 01-Nov-2006 ru

Fix -fstrict-aliasing warning.


163849 31-Oct-2006 pjd

Forgot to add file with gjournal specific fsck code.

Sponsored by: home.pl


163845 31-Oct-2006 pjd

Implements gjournal support. If file system has gjournal support enabled
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


150365 20-Sep-2005 delphij

Mention the default location of alternative super block on a
UFS2 file system, in fsck_ffs(8).

Submitted by: KOMATSU Shinichiro <koma2 at lovepeers ! org>
PR: docs/86362
MFC After: 3 days


143235 07-Mar-2005 delphij

Make background fsck based summary adjustments actually work by
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


142123 20-Feb-2005 delphij

The recomputation of file system summary at mount time can be a
very slow process, especially for large file systems that is just
recovered from a crash.

Since the summary is already re-sync'ed every 30 second, we will
not lag behind too much after a crash. With this consideration
in mind, it is more reasonable to transfer the responsibility to
background fsck, to reduce the delay after a crash.

Add a new sysctl variable, vfs.ffs.compute_summary_at_mount, to
control this behavior. When set to nonzero, we will get the
"old" behavior, that the summary is computed immediately at mount
time.

Add five new sysctl variables to adjust ndir, nbfree, nifree,
nffree and numclusters respectively. Teach fsck_ffs about these
API, however, intentionally not to check the existence, since
kernels without these sysctls must have recomputed the summary
and hence no adjustments are necessary.

This change has eliminated the usual tens of minutes of delay of
mounting large dirty volumes.

Reviewed by: mckusick
MFC After: 1 week


141611 10-Feb-2005 ru

Sync program's usage() with manpage's SYNOPSIS.


140368 17-Jan-2005 ru

Added the EXIT STATUS section where appropriate.


138734 12-Dec-2004 phk

Do not pass random bits as mount arguments.


136721 20-Oct-2004 rwatson

Explicitly break out NETA license from Berkeley license to clearly
indicate license grant, as well as to indicate that NETA is asserting
only two clauses, not four clauses.

Requested by: imp


136346 10-Oct-2004 imp

The got_siginfo = 0 should have been got_sigalarm=0 to match the other
passes.

Submitted by: Dworkin Muller


136281 08-Oct-2004 truckman

Eliminate linked list used to track inodes with an initial link
count of zero and instead encode this information in the inode state.
Pass 4 performed a linear search of this list for each inode in
the file system, which performs poorly if the list is long.

Reviewed by: sam & keramida (an earlier version of the patch), mckusick
MFC after: 1 month


134597 01-Sep-2004 scottl

Move back to WARNS=2


134589 01-Sep-2004 scottl

Create DIP_SET() and IBLK_SET() macros to fix lvalue warnings.

Inspired by: kan


134011 19-Aug-2004 jhb

Generalize the UFS bad magic value used to determine when a filesystem
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?


132761 28-Jul-2004 kan

Downgrade WARNS level until GCC 3.4.2 warning have been fixed.


131488 02-Jul-2004 ru

Mechanically kill hard sentence breaks.


129401 18-May-2004 scottl

Improve the delay algorithm used in bgfsck. From the author:

shuffles the timing and sleep calls in bgfsck from:

sleep timer_on io timer_off io io io io io io io
to
sleep io io io io io io io timer_on io timer_off

The original method basically guaranteed that the timed I/O included a
disk seek every time, which made bgfsck sleep for much longer than
necessary.

Submitted by: Dan Nelson
Reviewed by: kirk


128073 09-Apr-2004 markm

Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core, imp


127638 30-Mar-2004 dwmalone

Remove a stray \n from a setproctitle.

Submitted by: Niki Denev <nike_d@cytexbg.com>


126345 28-Feb-2004 scottl

In the case of a background fsck, periodically update the process title
with a progress update.


126178 23-Feb-2004 johan

style.Makefile(5):
Use WARNS?= instead of WARNS=.


125036 26-Jan-2004 cperciva

Avoid dereferencing null pointers in fsck_ffs. (pfatal may return,
so it isn't a safe way of handling [mc]alloc failures.)

PR: misc/61800
Approved by: rwatson (mentor)


124340 10-Jan-2004 simon

Add manual page links from fsck_ufs.8 and fsck_4.2bsd.8 to fsck_ffs.8,
since there are already the same links for the program binary.

Suggested by: mat


122784 16-Nov-2003 wes

Catch and report on filesystems that were interrupted during newfs,
sporting the new 'BAD' magic number. Exit with a unique error code
(11) so callers who care about this can respond appropriately.


121258 19-Oct-2003 iedowse

Change the default mode for lost+found from 01777 to 0700. The
original intention of the less restrictive permissions was to allow
users to move or delete recovered files that they own. However, it
is better to not create world-writable directories by default; the
administrator can always pre-create lost+found if different permissions
are desired.

Reviewed by: mckusick


120901 08-Oct-2003 mckusick

Create a .snap directory mode 770 group operator in the root of each
filesystem that is checked in background. Create the snapshot in this
directory rather than in the root. There are two benefits:

1) For terabyte-sized filesystems, the snapshot may require many
minutes to build. Although the filesystem will not be suspended
during most of the snapshot build, the snapshot file itself is
locked during the entire snapshot build period. Thus, if it is
accessed during the period that it is being built, the process
trying to access it will block holding its containing directory
locked. If the snapshot is in the root, the root will lock and
the system will come to a halt until the snapshot finishes. By
putting the snapshot in a subdirectory, it is out of the likely
path of any process traversing through the root and hence much
less likely to cause a lock race to the root.

2) The dump program is usually run by a non-root user running with
operator group privilege. Such a user is typically not permitted
to create files in the root of a filesystem. By having a directory
in group operator with group write access available, such a user
will be able to create a snapshot there. Having the dump program
create its snapshot in a subdirectory below the root will benefit
from point (1) as well.

Sponsored by: DARPA & NAI Labs.


118302 01-Aug-2003 ru

Spell "file system" correctly.


114589 03-May-2003 obrien

Use __FBSDID() to quiet GCC 3.3 warnings.


110884 14-Feb-2003 mckusick

Correct lines incorrectly added to the copyright message. Add missing period.

Submitted by: Bruce Evans <bde@zeta.org.au>
Sponsored by: DARPA & NAI Labs.


107829 13-Dec-2002 imp

MFp4: Make ifs consistant with rest of file.


107788 12-Dec-2002 ru

Uniformly refer to a file system as "file system".

Approved by: re


107671 07-Dec-2002 iedowse

Slow down the operation of background fsck so as to leave some disk
bandwidth for other processes. Since the sleeping is done from
userland, this avoids the locking issues that affected the kernel
version.

The algorithm used here is to measure a moving average of the times
taken by a sample of read operations and then delay 1 in 8 reads
by 16 times the measured average. This should correspond to a factor
of 3 slowdown, but in practice the factor is larger (3.5 to 4) due
to hz rounding effects.

Reviewed by: mckusick
Approved by: re


107518 02-Dec-2002 mckusick

Verify that alternate superblocks have a correct magic number before
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.


107294 27-Nov-2002 mckusick

Create a new 32-bit fs_flags word in the superblock. Add code to move
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.


107213 24-Nov-2002 julian

Fsck needs to check each CG's rotor values to ensure thay are not -ve.
It seems a common corruption to have them -ve (I've seen it several times)
and if fsck doesn't fix it, it leads to a kernel pagefault.

Reviewd by: kirk
Submitted by: Eric Jacobs <eaja@erols.com> and me independently.
MFC in: 2 days
PR: bin/40967
Approved by: re


105436 19-Oct-2002 mckusick

Clear the pending counts in the superblock after a successful run
of fsck so that the kernel does not complain about them being
non-zero when the filesystem is mounted.

Sponsored by: DARPA & NAI Labs.


104745 10-Oct-2002 mckusick

When verifying a superblock, the lower bound on block size is MINBSIZE
(4096), not SBLOCKSIZE (8192).

Submitted by: Tor.Egge@cvsup.no.freebsd.org
Sponsored by: DARPA & NAI Labs.


103949 25-Sep-2002 mike

Use the standardized CHAR_BIT constant instead of NBBY in userland.


103885 24-Sep-2002 mckusick

Add support to fsck_ffs to account for storage for extended
attributes.

Sponsored by: DARPA & NAI Labs.


103398 16-Sep-2002 phk

Add a source file where EXTATTR checks will happen and hook it in even
if it doesn't do anything yet.

Sponsored by: DARPA & NAI Labs.


102464 27-Aug-2002 trhodes

Fix some 'SYNOPSIS' and 'usage' messages.


102411 25-Aug-2002 charnier

Replace various spelling with FALLTHROUGH which is lint()able


102231 21-Aug-2002 trhodes

s/filesystem/file system/g as discussed on -developers


101994 16-Aug-2002 bmilekic

Fix more breakage due to FSTYPENAMES/DKTYPENAMES split.

Also submitted by: David Wolfskill <david@catwhisker.org>


101970 16-Aug-2002 alfred

Don't '#define DKTYPENAMES', we don't use the variable it exposes from
the header file.


101585 09-Aug-2002 phk

preen.c was a stragler after the fsck/fsck_ffs divorce.
fsck_ffs did not need it, but quotacheck did include it from fsck_ffs.

A repocopy has now moved the fsck_ffs/preen.c file to quotacheck/preen.c

quotacheck and fsck should probably use the same checkfstab() function
and it should possibly live in libufs.

Trouble is: they have diverged in the meantime.

At least now fsck_ffs is not in the equation anymore.

Sponsored by: DARPA & NAI Labs.


101037 31-Jul-2002 mux

Fix a bunch of format string warnings which broke
the sparc64 build.

Tested on: sparc64, i386


100973 30-Jul-2002 phk

Remove some additional paranoia which Kirk forgot to remove from his
UFS2 commit.

These bits in essence made any instance of "softupdates expected
corrution", (ie blocks marked allocated but not referenced by an
inode etc) result in a exit value for fsck_ffs of 2.

2 is part of the magic and appearantly undocumented protocol between
fsck_FOO and fsck and means "dump into single user mode ASAP.

Sponsored by: DARPA & NAI Labs.


100935 30-Jul-2002 phk

Warning cleanup.

Format changes by peter


98888 26-Jun-2002 iedowse

Remove the kernel file-size limit for UFS2, so that only the limit
imposed by the filesystem structure itself remains. With 16k blocks,
the maximum file size is now just over 128TB.

For now, the UFS1 file size limit is left unchanged so as to remain
consistent with RELENG_4, but it too could be removed in the future.

Reviewed by: mckusick


98879 26-Jun-2002 iedowse

Fix an integer overflow that causes fsck_ffs to crash when it
encounters very large file sizes in the filesystem.

Reviewed by: mckusick


98542 21-Jun-2002 mckusick

This commit adds basic support for the UFS2 filesystem. The UFS2
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>


96707 16-May-2002 trhodes

more file system > filesystem


96483 12-May-2002 phk

UFS2 preparation commit:
Remove support for converting old FFS formats to newer.

Submitted by: mckusick
Sponspored by: DARPA & NAI Labs.


96475 12-May-2002 phk

Retire the bogus uses of the disklabel field d_sbsize and begin to
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.


95897 02-May-2002 mckusick

Minor bug fixes uncovered while working on UFS2.
They should have no effect on existing systems.


95258 22-Apr-2002 des

Usage style sweep: spell "usage" with a small 'u'.
Also change one case of blatant __progname abuse (several more remain)
This commit does not touch anything in src/{contrib,crypto,gnu}/.


94031 07-Apr-2002 mckusick

When checking the alternate superblock, we used to copy any fields
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


93103 24-Mar-2002 markm

Replace __progname with the documented, more acceptable and functionally identical getprogname(3).


92839 20-Mar-2002 imp

o __P removed
o ansi function prototypes
o unifdef -D__STDC__
o __dead2 on usage prototype
o remove now-bogus main prototype


92806 20-Mar-2002 obrien

Remove 'register' keyword.
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?)


88413 22-Dec-2001 alfred

declare locally used globals as static.


88031 17-Dec-2001 iedowse

Ignore the value of fs_active when comparing superblocks.

Noticed by: "Niels Chr. Bank-Pedersen" <ncbp@bank-pedersen.dk>


87667 11-Dec-2001 charnier

Spelling


87360 04-Dec-2001 ru

mdoc(7) police: section 1 and 8 manpages document their exit
codes under the DIAGNOSTICS section, not RETURN VALUES, which
is for section 2, 3, and 9 manpages.


87328 04-Dec-2001 obrien

Actually I haven't enumerated the return values yet (thats why I hadn't
committed it yet). So vague'ize the wording a little bit to make up
for it.


87325 04-Dec-2001 obrien

Default to WARNS=2.
Binary builds that cannot handle this must explicitly set WARNS=0.

Reviewed by: mike


86514 17-Nov-2001 iedowse

Fix a large number of -Wall, -Wformat and -W compiler warnings.
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.


86512 17-Nov-2001 iedowse

Give a more useful diagnostic when an extraneous hard link to a
directory is encountered. This includes the full path of the
directory that will be removed if the user answers "y" to the
"REMOVE?" question.

PR: bin/226851
Submitted by: KOIE Hide <hide@koie.org>
MFC after: 1 week


81911 19-Aug-2001 kris

Silence non-constant format string warnings by marking functions
as __printflike()/__printf0like(), adding const, or adding missing "%s"
format strings, as appropriate.

MFC after: 2 weeks


79754 15-Jul-2001 dd

Remove whitespace at EOL.


77436 29-May-2001 iedowse

Ignore the new superblock fields fs_pendingblocks and fs_pendinginodes
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.


76352 08-May-2001 mckusick

Just notify us once when encountering a partially allocated inode.


76143 30-Apr-2001 mckusick

Update usage message with new options.

Submitted by: Ruslan Ermilov <ru@FreeBSD.org>


76063 27-Apr-2001 ru

mdoc(7) police:
document date updated, removed history info from the .Os call, cosmetics.


75927 24-Apr-2001 mckusick

Add support for the -F flag which determines whether a specified
filesystem needs foreground checking (usually at boot time) or
can defer to background checking (after the system is up and running).
See the manual page, fsck_ffs(8), for details on the -F and -B options.
These options are primarily intended for use by the fsck front end.

All output is directed to stdout so that the output is coherent
when redirected to a file or a pipe. Unify the code with the fsck
front end that allows either a device or a mount point to be
specified as the argument to be checked.


75884 23-Apr-2001 iedowse

In fsdb, call sblock_init() which is now necessary to initialise
the global variable dev_bsize. Add a prototype for sblock_init()
to fsck.h, and set the return type correctly.


75557 16-Apr-2001 mckusick

Minor background cleanups:
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.


75545 16-Apr-2001 ru

mdoc(7) police: prepare for mdocNG.


75395 10-Apr-2001 jhb

Catch up to the dirpref changes by copying new fields in the alternate
superblock from the original superblock so that differences in those new
fields are ignored.


75047 31-Mar-2001 mckusick

Use fs->fs_ipg rather than cg->cg_niblk as the latter is only
16-bits and may overflow.

Obtained from: Bruce Evans <bde@zeta.org.au>


74815 26-Mar-2001 ru

- Backout botched attempt to introduce MANSECT feature.
- MAN[1-9] -> MAN.


74556 21-Mar-2001 mckusick

Additions to run checks on live filesystems. This change will not
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.


74531 20-Mar-2001 ru

Set the default manual section for sbin/ to 8.


72640 18-Feb-2001 asmodai

Preceed/preceeding are not english words. Use precede or preceding.


72525 15-Feb-2001 tegge

Don't allow special devices of type NODEV (NOUDEV as seen from kernel).
They can't be created via mknod and the kernel crashes if it encounters
such an inode.
Approved by: mckusick


72417 12-Feb-2001 nik

Use ".Nm fsck_ffs", so that this turns up in whatis(1), and others.
Add .Xr to fsck.

Prompted by: JM Jr's script that shows binaries with no whatis info
Reviewed by: adrian


71884 31-Jan-2001 iedowse

Fsck_ffs did not properly range-check the inode 'di_size'
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


71073 15-Jan-2001 iedowse

The ffs superblock includes a 128-byte region for use by temporary
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


70633 03-Jan-2001 iedowse

Document fsck_ffs's new SIGINFO handler.

Reviewed by: sheldonh


70166 18-Dec-2000 phk

Add a missing period and newline to a message.

PR: 23334
Submitted by: Rich Morin <rdm@cfcl.com>


70152 18-Dec-2000 ru

Prepare for mdoc(7)NG.


70050 15-Dec-2000 iedowse

Add a simple SIGINFO handler to fsck_ffs. Shortly after receipt of
a SIGINFO (normally via Ctrl-T), a line will be output indicating
the current phase number and progress information relevant to the
current phase.

Approved by: mckusick


69800 09-Dec-2000 tomsoft

added growfs(8) including ffsinfo(8) to the freebsd base system

Reviewed by: grog


68960 20-Nov-2000 ru

mdoc(7) police: use the new features of the Nm macro.


66866 09-Oct-2000 adrian

.. forgot a ; at the end of the $FreeBSD$ string. How did I actually forget
this? :-)

It builds again.


66864 09-Oct-2000 adrian

Some missed magic in the fsck wrapper commit which is required by other
utilities which use bits of fsck_ffs - namely quotacheck and fsdb.
In depth, utilities.c contains blockcheck() which is needed by both,
but also a slew of routines which require bits of the FFS code to be
compiled in. This breaks the fs-specific and non-fs-specific code
up into two files (well, blockcheck() is the only routine in utilities.c,
that'll change later) which makes building fsck_ffs, quotacheck and
fsdb work yet again.

(You won't find commits to fsdb and quotacheck here before I haven't
committed the post-fsck-wrappers version of them yet.)


66861 09-Oct-2000 adrian

Reviewed by: rwatson, bp
Approved by: rwatson
Obtained from: NetBSD-current source tree

The beginnings of the fsck wrappers stuff from NetBSD. This particular commit
brings a newly repo-copied sbin/fsck_ffs/ (from sbin/fsck/) into fsck wrappers
mode.

A quick overview (the code reflects this):

* Documentation changed to reflect fsck_ffs instead of fsck
* Simply acts on a single filesystem, doesn't try to do any multiple filesystem
magic - this is done by the fsck wrappers now

And then specific to fsck_ffs:

* link to /sbin/fsck_4.2bsd and /sbin/fsck_ufs. This is because right now
the filesystem is of type ufs not ffs, and that during autodetection the
labeltype rather than the VFS type is used - this is because when doing
an autodetection of filesystem type in the fsck wrapper program, it does
not have any link between label type (4.2bsd, vinum, etc) and VFS string.

Note that this shouldn't break a build since the required buildworld Makefile
magic and import of the fsck wrapper code into src/sbin/fsck/ will happen
in a seperate commit.


66773 06-Oct-2000 kris

Format string fix.


63810 24-Jul-2000 mckusick

If the lost+found directory is created by fsck, it will do a cacheino()
which sets the inoinfo's i_parent and i_dotdot to 0, but they never get
set to ROOTINO. This means that propagate will never find lost+found and
its descendents, subdirectories will remain DSTATE (instead of DFOUND)
even though they *are* correctly linked in, and pass4.c will try to
clear them unsuccessfully, thinking that there is no link count from the
DSTATE directory's parent. The result is that you need to run fsck twice
and get link count increasing errors (which are unexpected and fatal
when running in preen mode). The fix is to set i_parent and i_dotdot to
"parent" after the second cacheino() call in dir.c:allocdir().

Obtained from: "Ethan Solomita" <ethan@geocast.com> (of the NetBSD Project)


63231 15-Jul-2000 mckusick

Make a tighter test for valid inode numbers in getnextinode().


63003 12-Jul-2000 mckusick

Ensure that block and character devices as well as fifo's and sockets
all have zero length. A non-zero length panic's the kernel when one
of these is deleted.

PR: 19426
Submitted by: Ian Dowse <iedowse@maths.tcd.ie>
Reviewed by: dwmalone@FreeBSD.org


62668 06-Jul-2000 mckusick

Teach fsck about snapshot files. These changes should have no
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.


57573 28-Feb-2000 mckusick

Yesterday I had to fix a badly broken disk, and found that fsck kept dying:

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>


55773 10-Jan-2000 peter

Fix the use of an uninitialized variable in the previous commit.

Also, in addition to the previous log message, the last change had a fix
for the case where where f.mntfromname is a relative path like da0a.

Submitted by: bde


55725 10-Jan-2000 peter

- Style/bde changes.
- Don't use realpath as stat does the right thing.
- Only check ufs filesystems in getmntpt.
- Dont' bother checking that the ufs-mounted-on
device is a special file. It *must* be a special
file, or ufs wouldn't have mounted it.

Submitted by: Paul Saab <ps@yahoo-inc.com>


55724 10-Jan-2000 peter

- Forgot to nuke hotroot completely.

Submitted by: Paul Saab <ps@yahoo-inc.com>


55275 30-Dec-1999 peter

Make fsck(8) do a MNT_RELOAD after cleaning for all read-only mounted
filesystems, not just for the root fs.

Reviewed by: mckusick
Submitted by: Paul Saab <ps@yahoo-inc.com>


53781 27-Nov-1999 phk

Make fsck even more char/blk dev tolerant.


53754 27-Nov-1999 phk

Allow root-reloading also for chr devices.


50476 28-Aug-1999 peter

$Id$ -> $FreeBSD$


48935 20-Jul-1999 phk

Also check against chardevs when looking for root.


41477 03-Dec-1998 julian

Cosmetic and documentation changes brought from earlier FreeBSD versions.
(e.g. RCS Id:)


41474 03-Dec-1998 julian

Reviewed by: Don Lewis <Don.Lewis@tsc.tdk.com>
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.


40918 05-Nov-1998 mjacob

For large filesystems you can run past default resource limits causing
fsck to exit unhappily. Fix this by doing a getrlimit/setrlimit for
RLIMIT_DATA. I made the same fix in NetBSD.

Reviewed by: dg@root.com


39584 23-Sep-1998 nate

- Back out softupdate change that already existed in FreeBSD from V1.6,
which caused the reference count of a directory to get doubly
decremented.

PR: bin/8030
Reviewed by: nate
Submitted by: Don Lewis <Don.Lewis@tsc.tdk.com>


38328 15-Aug-1998 dfr

Use explicitly sized types when laying out the cylinder groups. This
bug was the cause of the 'freeing free frag' panics that people have been
seeing with FreeBSD/alpha. I have a similar patch to newfs but I've not
finished testing it.


38067 04-Aug-1998 phk

There seem to be two messages that were added with soft-updates
support, which need a final "\n". I only observed one line of
mangled output, but I think there is another one which suffers
from the same problem, and thus I provide a patch that covers
both.

PR: 7483
Reviewed by: phk
Submitted by: Stefan Esser <se@FreeBSD.org>


38002 01-Aug-1998 dfr

Avoid trying to malloc > (1<<32) bytes of memory due to an arithmetic
underflow on the alpha.


37443 06-Jul-1998 bde

Restored rev.1.11, which I somehow clobbered in rev.1.12.


37236 28-Jun-1998 bde

Fixed printf format errors.


37000 15-Jun-1998 charnier

Correct use of .Nm. Add rcsid. Remove unused #includes. Use err(3).


36681 05-Jun-1998 julian

Reviewed by: Kirk Mckusick (mckusick@mckusick.com)
Submitted by: luoqi Chen
fix a type in fsck.
(also add a comment that got picked up by mistake but is worth adding)


35095 07-Apr-1998 bde

Guess the position of the drive number in the device name better so
that `fsck -p' doesn't check multiple slices on the same drive
concurrently. Don't invoke undefined behaviour when searching for
the drive number in strange device names.

PR: 6129
Reviewed by: phk
Submitted by: Yuichi MATSUTAKA <matutaka@osa.att.ne.jp>, but rewritten
by me.


34266 08-Mar-1998 julian

Reviewed by: dyson@freebsd.org (john Dyson), dg@root.com (david greenman)
Submitted by: Kirk McKusick (mcKusick@mckusick.com)
Obtained from: WHistle development tree


34033 04-Mar-1998 phk

If numdirs is zero, print a helpful message instead of divding by zero later.


33139 06-Feb-1998 jhay

opt_diagnostic.h isn't needed anymore.


33118 05-Feb-1998 jhay

fsdb and fsck use the ffs code which needs opt_diagnostic.h.


32622 19-Jan-1998 bde

Guard against a block size of 0 in the label. When the first
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


31910 21-Dec-1997 bde

Fixed overflow in chkrange(). Some out of bounds block numbers,
e.g. -1, were not detected. Use a bulletproof check that doesn't
depend on special properties of the args or the limit.

PR: 3528


31904 20-Dec-1997 bde

Fixed style bugs in the printing of statistics after preening. Use
floating point better in the percentage calculation there to avoid
overflow when there are more than about 20 million fragments. Start
using floating point in the other percentage calculation to avoid
overflow when there are more than about 2 million fragments.

Fixed printf format strings.

Converted sccsid to rcsid.


31903 20-Dec-1997 bde

Don't attempt to print the statistics for a "clean" preened filesystem
when there isn't even a filesystem. Attempting to print them tended
to cause SIGSEGV or SIGFPE depending on how far setup() got before it
returned 0. This was broken in the previous revision by removing a
return statement that the previous case depended on falling into.

PR: 4840 (fixed by this commit)
PR: 2537 (possibly fixed by Lite2 merge and later changes. setup()
does more checking now)


24002 18-Mar-1997 peter

patch up some "int *" vs. "time_t *" (long) mismatches. They could be
nasty if sizeof(int) != sizeof(long).


23999 18-Mar-1997 peter

Restore check for ridiculous directory sizes.


23844 13-Mar-1997 peter

Kill the Lite2 early "filesystem clean abort" check and go back to
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).


23799 12-Mar-1997 bde

Finished (?) merging with Lite2: cleaned up #include mess.


23798 12-Mar-1997 bde

Finished (?) merging with Lite2: cleaned up #include mess.

Fixed style bugs in FreeBSD changes.


23797 12-Mar-1997 bde

Finished (?) merging with Lite2: cleaned up #include mess and fixed a
style bug.

Removed a redundant declaration.


23796 12-Mar-1997 bde

Finished (?) merging with Lite2: cleaned up #include mess.

Fixed misformatting in a comment.


23795 12-Mar-1997 bde

Finished (?) merging with Lite2: cleaned up #include mess.

Updated getopt() usage.


23794 12-Mar-1997 bde

Restored lost reference to fsdb(8).

Fixed weird quoting of $Id$.


23675 11-Mar-1997 peter

Merge from Lite2. Note that Lite2 has it's own filesystem clean check
skipping code that overrides ours sooner. One should be eliminated,
but for now it works.


22990 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


21635 13-Jan-1997 wosch

Sort cross references.


19702 13-Nov-1996 julian

Submitted by: Archie@whistle.com

clear the fmod flag if it's set.


19212 27-Oct-1996 phk

Don't give up just because we cant find the blkdev that corresponds
to the name given as a chardev.


19185 25-Oct-1996 joerg

Allow the specification of a mountpoint, and resolve it s disk device
using the fstab.

Closes PR bin/129.

Submitted by: jmg@nike.efn.org (John-Mark Gurney)


18808 08-Oct-1996 guido

Fix the case where fsck would not see sparse directories and the kernel would
panic. If such a thing is fixed fsck needs a rerun (and bugs the user to do
so).

Reviewed by: Kirk McKusick


18405 20-Sep-1996 nate

ts_sec -> tv_sec
ts_nsec -> tv_nsec


18286 14-Sep-1996 bde

Don't use __dead or __pure in user code. They were obfuscations
for gcc >= 2.5 and no-ops for gcc >= 2.6. Converted to use __dead2
or __pure2 where it wasn't already done, except in math.h where use
of __pure was mostly wrong.


15699 09-May-1996 nate

From: Terry Lambert <terry@lambert.org>
Subject: Fix for annoying fsck bug
Date: Wed, 24 Jan 1996 13:33:29 -0700 (MST)

The following small diff fixes the annoying fsck bug that causes it to
need to be run twice to end up with correct reference counts for inodes
for directories that had subdirectories relocated into the lost+found
directory.

I found the need to rerun *extremely* annoying. This fix causes the
count to be correctly adjusted later in pass 4 by correctly stating
the parent reference count.

Note that the parent reference count is incremented when the directory
entry is made (for ".."), but is not really there in the case of a
directory that does not make an entry in its parent dir.

This can be tested by waiting for the inode sync after cd'ing from a
shell into a test fs. Then you "mkdir xxx yyy zzz", wait a second,
and hit the machine reset button.

Reviewed by: nate (Tested lots of crashes :)
Submitted by: Terry Lambert <terry@lambert.org>


13922 05-Feb-1996 mpp

Correct some man page cross references and some file
locations.


11750 23-Oct-1995 ache

Remove unneeded ctype.h


8871 30-May-1995 rgrimes

Remove trailing whitespace.


7601 02-Apr-1995 bde

Update declaration to match the change made to dir.c a few hours ago.


7586 02-Apr-1995 bde

Submitted by: Philippe Charnier <charnier@lirmm.fr>, distilled by bde

Fix a couple more bogus types that aren't reported by `gcc -Wall'.


7585 02-Apr-1995 bde

Submitted by: phk, added to by bde

Fix all the warnings from `gcc -Wall'.


7106 17-Mar-1995 phk

Remove reference to fsdb(8). We don't have it.


6405 15-Feb-1995 dg

Slight change of wording on clean flag not set message to appease some
complaints.


6404 15-Feb-1995 dg

>The fix for the missing ".." in the root directory is enclosed below.

Submitted by: Kirk McKusick


6280 09-Feb-1995 bde

Don't allow the alternate superblock block number for one file system
to apply to others (except when it is given on the command line).


2605 09-Sep-1994 dg

Woops, last patch was by Wolfgang Solfrank.


2603 09-Sep-1994 dg

Two fixes from the NetBSD group (Charles Hannum):

1) dir.c: get byte order right in mkentry()
2) pass1.c: When doing -c2 conversion, do secsize reads for a symlink -
not doing so was causing the conversion to fail because the device
driver can't deal with short reads.


2179 21-Aug-1994 dg

Better support for clean bit: prompt the user to fix it if it's wrong
when not preening, and indicate if it was fixed when preening.


2153 20-Aug-1994 dg

Added filesystem clean bit support. This only affects fsck during a
preen (-p), and in that case the filesystem is skipped if it is clean.
A new flag "-f" for 'force' has been added which basically gives back
the old behavior of checking all the filesystems all the time. This
very closely models the behavior of SunOS and Ultrix.


1855 05-Aug-1994 wollman

Convert to our man installation style. Also fixed long-standing bug
in `fastboot'/`fasthalt' in which the interpreter would hang around
after `reboot' or `halt' is run, causing an irritating ``Killed'' message.


1820 02-Aug-1994 dg

Fixed so that it can grok old style "fastlinks".


1558 26-May-1994 rgrimes

BSD 4.4 Lite sbin Sources

Note: XNSrouted and routed NOT imported here, they shall be imported with
usr.sbin.