Home | History | Annotate | Download | only in fsck_ffs
History log of /src/sbin/fsck_ffs/pass5.c
RevisionDateAuthorComments
 1.58  04-Jul-2023  riastradh fsck_ffs(8): Fix whitespace issues.

- Nix trailing whitespace.
- Omit excessive blank lines.
- Insert missing blank lines between $NetBSD$ and copyright.

No functional change intended.
 1.57  08-Jan-2023  chs ufs: more signed/unsigned fixes

Fix the previous signed/unsigned fixes to build on 32-bit,
including applying this commit from FreeBSD:

commit 2d34afcd04207cf3fa3d5b7f467a890eae75da41
Author: Kirk McKusick <mckusick@FreeBSD.org>
Date: Sun Oct 25 21:04:07 2020 +0000

Use proper type (ino_t) for inode numbers to avoid improper sign extention
in the Pass 5 checks. The manifestation was fsck_ffs exiting with this error:

** Phase 5 - Check Cyl groups
fsck_ffs: inoinfo: inumber 18446744071562087424 out of range

The error only manifests itself for filesystems bigger than about 100Tb.

Reported by: Nikita Grechikhin <ngrechikhin at yandex.ru>
MFC after: 2 weeks
Sponsored by: Netflix
 1.56  07-Jan-2023  chs ufs: fixed signed/unsigned bugs affecting large file systems

Apply these commits from FreeBSD:

commit e870d1e6f97cc73308c11c40684b775bcfa906a2
Author: Kirk McKusick <mckusick@FreeBSD.org>
Date: Wed Feb 10 20:10:35 2010 +0000

This fix corrects a problem in the file system that treats large
inode numbers as negative rather than unsigned. For a default
(16K block) file system, this bug began to show up at a file system
size above about 16Tb.

To fully handle this problem, newfs must be updated to ensure that
it will never create a filesystem with more than 2^32 inodes. That
patch will be forthcoming soon.

Reported by: Scott Burns, John Kilburg, Bruce Evans
Followup by: Jeff Roberson
PR: 133980
MFC after: 2 weeks

commit 81479e688b0f643ffacd3f335b4b4bba460b769d
Author: Kirk McKusick <mckusick@FreeBSD.org>
Date: Thu Feb 11 18:14:53 2010 +0000

One last pass to get all the unsigned comparisons correct.


In additional to the changes from FreeBSD, this commit includes quite a few
related changes to appease -Wsign-compare.
 1.55  17-Nov-2022  chs branches: 1.55.2;
Restore backward compatibility of UFS2 with previous NetBSD releases by
disabling support in UFS2 for extended attributes (including ACLs).
Add a new variant of UFS2 called "UFS2ea" that does support extended attributes.
Add new fsck_ffs operations "-c ea" and "-c no-ea" to convert file systems
from UFS2 to UFS2ea and vice-versa (both of which delete all existing extended
attributes in the process).
 1.54  23-Jun-2013  dholland Stick ffs_ in front of the following macros:
fragstoblks()
blkstofrags()
fragnum()
blknum()

to finish the job of distinguishing them from the lfs versions, which
Christos renamed the other day.

I believe this is the last of the overtly ambiguous exported symbols
from ffs... or at least, the last of the ones that conflicted with lfs.
ffs still pollutes the C namespace very broadly (as does ufs) and this
needs quite a bit more cleanup.

XXX: boo on macros with lowercase names. But I'm not tackling that just yet.
 1.53  23-Jun-2013  dholland Stick ffs_, ext2_, chfs_, filecore_, cd9660_, or mfs_ in front of
the following symbols so as to disambiguate fully. (Christos already
did the lfs ones.)

lblkno
lblktosize
lfragtosize
numfrags
blkroundup
fragroundup
 1.52  23-Jun-2013  dholland fsbtodb() -> FFS_FSBTODB(), EXT2_FSBTODB(), or MFS_FSBTODB()
dbtofsb() -> FFS_DBTOFSB() or EXT2_DBTOFSB()

(Christos already did the lfs ones a few days back)
 1.51  22-Jan-2013  dholland Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.
 1.50  26-Aug-2012  dholland branches: 1.50.2;
stdlib.h, not malloc.h
 1.49  14-Aug-2011  christos branches: 1.49.2;
WARNS=4
 1.48  23-Feb-2008  christos Make sure that the exit values are always sane, and use symbolic instead
of magic constants. Reviewed by go@
 1.47  14-Nov-2006  apb branches: 1.47.8; 1.47.16; 1.47.18;
Improve the progress bar displayed by fsck_ffs -p -P.

The progress bar will now travel from 0 to 20% during pass 1, from 20%
to 95% during pass 2, and from 95% to 100% during passes 3, 4, and 5.
Previously, the progress bar was not displayed at all during pass 1,
slowly traveled from 0 to about 50% during pass 2, and then very rapidly
traveled from 50% to 100% during passes 3, 4, and 5.

Note that fsck_ffs is the only user of fsck/progress.{c,h}.
 1.46  27-Jun-2005  christos sprinkle const.
 1.45  20-Jan-2005  xtraeme branches: 1.45.2;
whitespace (pointed out by wiz@)
 1.44  19-Jan-2005  xtraeme Kill __P(), ANSIfy and WARNS=2
 1.43  13-Jan-2005  christos Use -DPROGRESS to enable the progress bar, don't depend on SMALL.
 1.42  13-Jan-2005  christos Add a progress meter to fsck_ffs based on the work by thorpej presented
to the mailing lists last January. This is optional.
 1.41  09-Oct-2004  ragge Cast to (long long int) to make last change compile on amd64.
 1.40  08-Oct-2004  dbj if debug, print found/expected block & inode counts when incorrect
 1.39  09-Jan-2004  dbj do not upgrade superblock or set FS_FLAGS_UPDATED unless -c 4 option
is provided.
add compatibility for filesystems before FFSv2 integration
these patches are from pr port-macppc/23925 and should also
fix problems discussed in pr kern/21404 and pr kern/21283
 1.38  19-Sep-2003  itojun realloc pedant
 1.37  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.36  04-Apr-2003  fvdl When fixing the cstotal structure, use the right size to copy it back.
Also, remove some accidentally committed debug code from the previous
commit.
 1.35  04-Apr-2003  fvdl Initialize cg_irotor correctly in newcg, to avoid false positives
for bad cylinder groups.
 1.34  02-Apr-2003  fvdl Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.33  14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.32  24-Jan-2003  fvdl Bump daddr_t to 64 bits. Replace it with int32_t in all places where
it was used on-disk, so that on-disk formats remain the same.
Remove ufs_daddr_t and ufs_lbn_t for the time being.
 1.31  28-Sep-2002  dbj Add support for the Apple UFS variation on ffs
This is the bulk of PR #17345

The general approach is to use a run time deteriminable value
for DIRBLKSIZ. Additional allowances are included for using
MAXSYMLINKLEN with FS_42INODEFMT and a shift in the cylinder group
cluster summary count array. Support is added for managing
the Apple UFS volume label.
 1.30  30-Jun-2002  dbj commit fix from pr bin/15449
this fixes FS_42POSTBLFMT compatibility
 1.29  06-May-2002  lukem If SIGINFO is received, display summary information to stderr.
Based on changes in FreeBSD, via Chuck Cranor <chuck@research.att.com>
 1.28  10-Apr-2002  mycroft Some manual strength reduction.
 1.27  17-Aug-2001  lukem remove third argument (`int ns') from ffs_sb_swap(), and let ffs_sb_swap()
determine the endianness of the `struct fs *o' superblock from o->fs_magic
and set needswap as necessary, rather than trusting the caller to get
it right. invariably, almost every caller of ffs_sb_swap() was calling it
with ns set to the wrong value for ns anyway!
ansi KNF ffs_bswap.c declarations whilst here.

this fixes all sorts of problems when trying to use other-endian file systems,
notably the kernel trying to access memory *way* off, possibly corrupting or
panicing, and userland programs SEGVing and/or corrupting things (e.g,
"fsck_ffs -B" to swap a file system endianness).

whilst the previous rev of ffs_bswap.c (1.10, 2000/12/23) made this problem
worse, i suspect that the problem was always there and previous versions
just happened not to trash things at the wrong time.

FFS_EI should now be a lot more stable.
 1.26  26-Jan-2001  thorpej In pass 5, check alternate superblocks for consistency with
the current in-core master superblock, and fix them up if
they're incorrect. Move the code that writes the alternate
superblocks if (cvtlevel || doswap) into pass 5 for efficiency.

Reviewd by Charles Hannum, and used by me to fix up a curdled
file system.
 1.25  09-Jan-2001  mycroft Make sure the rotor values are non-negative.
 1.24  14-Jul-2000  mycroft Add a missing newline in one message.
(The fact that I got this message using softdep should probably disturb
someone...)
 1.23  28-Nov-1999  bouyer branches: 1.23.4;
Add a missing '\n'.
 1.22  15-Nov-1999  fvdl Fix %d <-> long mismatch.
 1.21  15-Nov-1999  fvdl Changes for softdep code.
 1.20  25-Aug-1998  ross branches: 1.20.4; 1.20.8;
from Erik Bertelsen <erik@mediator.uni-c.dk>
{ put } { in } { lots } { of } { these } { to } { shut } { up } { egcs }
 1.19  18-Mar-1998  bouyer Add support for non-native byteorder FFS, and converting byteorder.
Also, be a bit more conservative with the clean flag: don't mark the FS
clean when we know there may still be errors (user anserwed 'n' to
a question, or fsck says "you must rerun fsck").
 1.18  16-Sep-1997  lukem resolve conflicts from lite-2 merge.
 1.17  14-Sep-1997  lukem * cleanup for WARNS=1
* deprecate register
* cleanup manpage
* remove unused docheck() func
* prefix hex numbers with '0x'
* getopt returns -1 not EOF
 1.16  27-Sep-1996  christos - util.h -> fsutil.h
 1.15  23-Sep-1996  christos - fixed all printf formats [there were a lot of %l? <-> %? mistakes]
- added missing prototypes, and made local functions static
- removed parallel preening code; this is part of fsck(8)
- use printing utilities from fsck(8)
- Makefile does not make links to fsck and fsck.8
- removed -l maxparallel option. It has no meaning anymore.
 1.14  21-Mar-1995  cgd type sizes
 1.13  18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.12  28-Dec-1994  mycroft Mostly sync with CSRG.
 1.11  18-Dec-1994  cgd light clean, and make it compile against new header files.
 1.10  05-Dec-1994  cgd more cleanups from Jim Jegers, passed over by me.
 1.9  28-Oct-1994  mycroft Use the S_IS*() macros, and make this compile again after Chris's changes to ufs.
 1.8  23-Sep-1994  mycroft Remove some more uses of obsolete functions.
 1.7  23-Sep-1994  mycroft Eliminate uses of some obsolete functions.
 1.6  08-Jun-1994  mycroft Update from 4.4-Lite, with local changes.
 1.5  25-Apr-1994  cgd need <sys/time.h>
 1.4  01-Aug-1993  mycroft Add RCS identifiers.
 1.3  23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2  22-Mar-1993  cgd added rcs ids to all files
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3  16-Sep-1997  lukem imported from lite-2
 1.1.1.2  13-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.20.8.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.20.4.3  26-Oct-1999  fvdl Fix some merge mistakes.
 1.20.4.2  26-Oct-1999  fvdl Remove unused variable decl. From Ethan Solomita.
 1.20.4.1  19-Oct-1999  fvdl Bring in Kirk McKusick's FFS softdep code on a branch.
 1.23.4.3  25-Nov-2001  he Pull up revision 1.27 (requested by lukem):
Call ffs_sb_swap() with the correct arguments. Fixes problems
with using other-endian file systems.
 1.23.4.2  24-Nov-2001  he Pull up revisions 1.25-1.26 (requested by lukem):
Jumbo pullup for fsck_ffs:
o fix incorrect error message
o mark initialized globals with ``extern''
o make reconnect algorithm O(n) instead of O(n^4)
o remove dead code
o don't swap cg_clustersum(cg)[0], it's a bitmap
o ensure rotor values are positive
o some code restructuring
o fix byte swapping bug
o pass5: check alternate superblocks for consistency with in-core master
o fix usage message
 1.23.4.1  27-Jul-2000  mycroft Approved by thorpej:
Add a missing newline to message.

basesrc/sbin/fsck_ffs/pass5.c 1.23 -> 1.24
 1.45.2.1  20-Nov-2006  tron Pull up following revision(s) (requested by ghen in ticket #1590):
sbin/fsck_ffs/pass4.c: revision 1.23
sbin/fsck_ffs/pass5.c: revision 1.47
sbin/fsck_ffs/pass2.c: revision 1.44
sbin/fsck_ffs/pass1.c: revision 1.43
sbin/fsck_ffs/pass3.c: revision 1.19
sbin/fsck/progress.c: revision 1.3
sbin/fsck_ffs/main.c: revision 1.61
sbin/fsck/progress.h: revision 1.2
Improve the progress bar displayed by fsck_ffs -p -P.
The progress bar will now travel from 0 to 20% during pass 1, from 20%
to 95% during pass 2, and from 95% to 100% during passes 3, 4, and 5.
Previously, the progress bar was not displayed at all during pass 1,
slowly traveled from 0 to about 50% during pass 2, and then very rapidly
traveled from 50% to 100% during passes 3, 4, and 5.
Note that fsck_ffs is the only user of fsck/progress.{c,h}.
 1.47.18.1  03-Apr-2008  mjf Sync with HEAD.
 1.47.16.1  24-Mar-2008  keiichi sync with head.
 1.47.8.1  23-Mar-2008  matt sync with HEAD
 1.49.2.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.49.2.2  23-Jan-2013  yamt sync with head
 1.49.2.1  30-Oct-2012  yamt sync with head
 1.50.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.50.2.1  25-Feb-2013  tls resync with head
 1.55.2.2  13-May-2023  martin Pull up following revision(s) (requested by chs in ticket #161):

sbin/fsck_ffs/setup.c: revision 1.106
sbin/fsck_ffs/pass5.c: revision 1.57

ufs: more signed/unsigned fixes

Fix the previous signed/unsigned fixes to build on 32-bit,
including applying this commit from FreeBSD:

commit 2d34afcd04207cf3fa3d5b7f467a890eae75da41
Author: Kirk McKusick <mckusick@FreeBSD.org>
Date: Sun Oct 25 21:04:07 2020 +0000
Use proper type (ino_t) for inode numbers to avoid improper sign extention
in the Pass 5 checks. The manifestation was fsck_ffs exiting with this error:
** Phase 5 - Check Cyl groups
fsck_ffs: inoinfo: inumber 18446744071562087424 out of range
The error only manifests itself for filesystems bigger than about 100Tb.
Reported by: Nikita Grechikhin <ngrechikhin at yandex.ru>
MFC after: 2 weeks
Sponsored by: Netflix
 1.55.2.1  13-May-2023  martin Pull up following revision(s) (requested by chs in ticket #160):

usr.sbin/makefs/ffs/ffs_alloc.c: revision 1.31
sbin/tunefs/tunefs.c: revision 1.58
sbin/fsck_ffs/setup.c: revision 1.105
sbin/fsck_ffs/pass5.c: revision 1.56
usr.sbin/makefs/ffs.c: revision 1.74
usr.sbin/makefs/ffs/mkfs.c: revision 1.42
usr.sbin/makefs/Makefile: revision 1.40
sys/ufs/ffs/fs.h: revision 1.71
sbin/fsdb/fsdb.c: revision 1.54
sbin/resize_ffs/resize_ffs.c: revision 1.58
sbin/fsck_ffs/pass4.c: revision 1.29
usr.sbin/makefs/ffs/ffs_extern.h: revision 1.9
sbin/newfs/mkfs.c: revision 1.133
sys/ufs/ffs/ffs_alloc.c: revision 1.172
sbin/fsck_ffs/pass1b.c: revision 1.24
usr.sbin/dumpfs/dumpfs.c: revision 1.68
sys/ufs/ffs/ffs_extern.h: revision 1.88
usr.sbin/quotacheck/quotacheck.c: revision 1.51
sys/ufs/ffs/ffs_subr.c: revision 1.54
sbin/fsck_ffs/main.c: revision 1.91
sbin/fsck_ffs/pass1.c: revision 1.63

ufs: fixed signed/unsigned bugs affecting large file systems

Apply these commits from FreeBSD:
commit e870d1e6f97cc73308c11c40684b775bcfa906a2
Author: Kirk McKusick <mckusick@FreeBSD.org>
Date: Wed Feb 10 20:10:35 2010 +0000
This fix corrects a problem in the file system that treats large
inode numbers as negative rather than unsigned. For a default
(16K block) file system, this bug began to show up at a file system
size above about 16Tb.
To fully handle this problem, newfs must be updated to ensure that
it will never create a filesystem with more than 2^32 inodes. That
patch will be forthcoming soon.
Reported by: Scott Burns, John Kilburg, Bruce Evans
Followup by: Jeff Roberson
PR: 133980
MFC after: 2 weeks

commit 81479e688b0f643ffacd3f335b4b4bba460b769d
Author: Kirk McKusick <mckusick@FreeBSD.org>
Date: Thu Feb 11 18:14:53 2010 +0000
One last pass to get all the unsigned comparisons correct.

In additional to the changes from FreeBSD, this commit includes quite a few
related changes to appease -Wsign-compare.

RSS XML Feed