History log of /netbsd-current/sbin/fsck_ffs/setup.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.109 05-Jul-2023 riastradh

Revert "fsck_ffs(8): Ensure A divides S before aligned_alloc(A, S)."

C17 lifted this restriction.


# 1.108 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.107 04-Jul-2023 riastradh

fsck_ffs(8): Ensure A divides S before aligned_alloc(A, S).

Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2,
p. 348:

The value of alignment shall be a valid alignment supported by the
implementation and the value of size shall be an integral multiple
of alignment.

XXX pullup-10


# 1.106 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.105 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.


Revision tags: netbsd-10-base
# 1.104 17-Nov-2022 chs

branches: 1.104.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).


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base phil-wifi-20200421
# 1.103 17-Apr-2020 jdolecek

align buffers used for I/O to DEV_BSIZE so it's executed more optimally
when run for xbd(4) raw (character) device


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.102 05-Oct-2018 hannken

Add a test for duplicate inodes on the persistent snapshot list.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.101 08-Feb-2017 rin

branches: 1.101.4; 1.101.10; 1.101.12;
Add smaller versions of fsck_ffs(8) and newfs(8) for install media, where
support for Endian-Independent FFS and Apple UFS is disabled unless FFS_EI=1
and APPLE_UFS=1 are added to CRUNCHENV, respectively.

This reduces the size of ramdisk image for atari by over 15KB.

Thanks tsutsui and christos for their useful comments.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base tls-maxphys-base
# 1.100 23-Jun-2013 dholland

branches: 1.100.10; 1.100.14;
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.99 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.98 19-Jun-2013 dholland

Rename ambiguous macros:
MAXDIRSIZE -> UFS_MAXDIRSIZE or LFS_MAXDIRSIZE
NINDIR -> FFS_NINDIR, EXT2_NINDIR, LFS_NINDIR, or MFS_NINDIR
INOPB -> FFS_INOPB, LFS_INOPB
INOPF -> FFS_INOPF, LFS_INOPF
blksize -> ffs_blksize, ext2_blksize, or lfs_blksize
sblksize -> ffs_blksize

These are not the only ambiguously defined filesystem macros, of
course, there's a pile more. I may not have found all the ambiguous
definitions of blksize(), too, as there are a lot of other things
called 'blksize' in the system.


# 1.97 09-Jun-2013 dholland

Stick UFS_ in front of these symbols:
DIRBLKSIZ
DIRECTSIZ
DIRSIZ
OLDDIRFMT
NEWDIRFMT

Part of PR 47909.


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.96 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.95 29-Jan-2012 nonaka

branches: 1.95.6;
use FS_UFS[12]_MAGIC_SWAPPED instead of bswap32(FS_UFS[12]_MAGIC).


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.94 14-Aug-2011 christos

branches: 1.94.2;
WARNS=4


# 1.93 09-Jun-2011 christos

share more code.


Revision tags: cherry-xenmp-base
# 1.92 20-Mar-2011 bouyer

branches: 1.92.2;
initialise memory allocated for uquot_user_hash & uquot_group_hash.
Pointed out by Nicolas Joly.


# 1.91 06-Mar-2011 bouyer

merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.90 31-Jan-2010 mlelstv

branches: 1.90.2;
Skip handling of APPLEUFS_LABEL if it is smaller than a device block.
In particular:

- newfs will not try to erase the label
- fsck_ffs will not try to validate the label

This lets newfs and fsck work on 2048-byte-per-sector media.

Does Apple UFS support such media and how?


Revision tags: matt-premerge-20091211
# 1.89 27-Sep-2009 bouyer

Restore changes from 1.86 and 1.87 after commit of 1.88.


# 1.88 13-Sep-2009 bouyer

Do some basic checks of the WAPBL journal, to abort the boot before the
kernel refuse to mount a filesystem read-write (booting a system
multiuser with critical filesystems read-only is bad):
Add a check_wapbl() which will check some WAPBL values in the superblock,
and try to read the journal via wapbl_replay_start() if there is one.
pfatal() if one of these fail (abort boot if in preen mode,
as "CONTINUE" otherwise). In non-preen mode the bogus journal will
be cleared.
check_wapbl() is always called if the superblock supports WAPBL.
Even if FS_DOWAPBL is not there, there could be flags asking the
kernel to clear or create a log with bogus values which would cause the
kernel refuse to mount the filesystem.
Discussed in
http://mail-index.netbsd.org/tech-kern/2009/08/17/msg005896.html
and followups.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.87 07-Apr-2009 mrg

fix a logic error in the previous, as point out by frank kardel.


# 1.86 25-Mar-2009 mrg

don't ignore "fsck -f" when given with "-p" on a wapbl filesystem.
ie, "fsck -fp" actually forces the check in preen mode now.


# 1.85 25-Feb-2009 christos

don't copy the address of a pointer. Noticed by Anon Ymous


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 mjf-devfs2-base
# 1.84 30-Aug-2008 bouyer

branches: 1.84.2; 1.84.4; 1.84.8;
Add fss(4) snapshot support to fsck_ffs(8) (via -x or -X options, like
dump(8)). This allows fsck_ffs -n to work on a snapshot of a R/W mounted
filesystem, and avoid errors related to filesystem activity.


# 1.83 31-Jul-2008 simonb

Merge the simonb-wapbl branch. From the original branch commit:

Add Wasabi System's WAPBL (Write Ahead Physical Block Logging)
journaling code. Originally written by Darrin B. Jewell while
at Wasabi and updated to -current by Antti Kantee, Andy Doran,
Greg Oster and Simon Burge.

OK'd by core@, releng@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.82 23-Feb-2008 christos

branches: 1.82.4; 1.82.6;
Make sure that the exit values are always sane, and use symbolic instead
of magic constants. Reviewed by go@


Revision tags: matt-armv6-prevmlocking cube-autoconf-base mjf-devfs-base matt-armv6-base
# 1.81 22-Aug-2007 christos

branches: 1.81.2; 1.81.8; 1.81.10;
Avoid zero-divides from Anon Ymous


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base netbsd-4-base
# 1.80 26-Aug-2006 christos

- Deal with wedges and the new disk geometry structures, instead of using
struct disklabel.

Functionality lost:
1. struct disklabel used to be updated to contain bsize, fsize, cpg.
This information was used to locate the alternative superblock in
the filesystem if the primary superblock was corrupted. We need
to find a new place to store this information if we need this
functionality.
2. On vax SMD drives that contained bad sector lists, the newfs program
knew how to get the offset and skip to the correct location in order
to place the label.


Revision tags: abandoned-netbsd-4-base
# 1.79 17-Mar-2006 rumble

Check for allocation failures in malloc, calloc, realloc, asprintf, and
vasprintf and try to handle them.


# 1.78 27-Jun-2005 christos

sprinkle const.


# 1.77 02-Jun-2005 dbj

for ufs2, assume FS_44INODEFMT
this is necessary for freebsd compatbility, since they do not initialize
the old field.


# 1.76 02-Jun-2005 lukem

appease gcc -Wuninitialized


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.75 19-Jan-2005 xtraeme

Kill __P(), ANSIfy and WARNS=2


# 1.74 29-Oct-2004 dsl

Rewrite getdisklabelpart() to avoid problems with isdigit(*ch_ptr) and
an incorrect check for a (probably impossible) empty string.
Add comments to avoid confusion...


# 1.73 14-Apr-2004 dbj

add support for downgrading a filesystem fslevel from 4 to 3


# 1.72 14-Apr-2004 dbj

set fs_old_nrpos to 1 when doing -c4 upgrade.
This isn't used by kernel, but does affect cg layout slightly


# 1.71 12-Apr-2004 dbj

fix whitespace in debug printf


Revision tags: netbsd-2-0-base
# 1.70 21-Mar-2004 dsl

branches: 1.70.2;
Don't use an ffsv1 superblock from 64k (SBLOCK_UFS2) when looking
for the main filesystem superblock.
64k is the offset of the first alternate if the blocksize if 64k.
Fixes part of PR kern/24809


# 1.69 20-Jan-2004 dbj

don't calculate fake superblock used for finding alternate superblocks
if the disklabel is missing the cpg parameter. Also print a warning
if this is skipped because of a missing fsize, frag or cpg disklabel parameter
this fixes a divide by zero error reported by martin@


# 1.68 12-Jan-2004 dbj

change the message "COVERTING TO FFSv2 SUPERBLOCK" to
"CONVERT TO NEW SUPERBLOCK LAYOUT" to help avoid confusion


# 1.67 10-Jan-2004 mrg

- some KNF (80 cols)
- fix a printf format issue


# 1.66 09-Jan-2004 dbj

use %#llx instead of %llx when printing incorrect qfmask or qbmask


# 1.65 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.64 02-Jan-2004 dbj

add uuid field to apple ufs volume label


# 1.63 20-Oct-2003 dsl

Add a -q (quiet) option to print nothing for clean filesystems.
Support in fsck_ffs and stub in fsck_xxx.
Push a few more messages through pwarn() instead of printf() to ensure
disk name is shown.


# 1.62 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.61 11-Apr-2003 enami

Correctly detect a UFS1 file system of non-native endian.


# 1.60 06-Apr-2003 fvdl

Write update some old fields when writing the superblock, similar to
ffs_oldfscompat_write() in the kernel. Use the old totals when
time < old_time (i.e. an old kernel or fsck wrote the filesystem last).
When setting the date back on a new kernel, that works out ok, since
new kernels always update both fields.


# 1.59 05-Apr-2003 fvdl

Skip checks for old 4.2BSD filesystem; as it stands, we can't deal with
writing them. Could be fixed, but doesn't have a high priority.


# 1.58 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.57 21-Feb-2003 fvdl

Only check relevant fields when comparing the superblock to an alternate
superblock. Avoids false positives should fsck_ffs be run on a filesystem
that was created after the UFS2 code has been merged.

This commit is mostly a forward compatibility patch that can be pulled
up in to the 1.6 branch.

From Kirk Mckusick in FreeBSD (setup.c rev. 1.30). Original commit message:


# 1.106 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.105 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.


Revision tags: netbsd-10-base
# 1.104 17-Nov-2022 chs

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).


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base phil-wifi-20200421
# 1.103 17-Apr-2020 jdolecek

align buffers used for I/O to DEV_BSIZE so it's executed more optimally
when run for xbd(4) raw (character) device


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.102 05-Oct-2018 hannken

Add a test for duplicate inodes on the persistent snapshot list.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.101 08-Feb-2017 rin

branches: 1.101.4; 1.101.10; 1.101.12;
Add smaller versions of fsck_ffs(8) and newfs(8) for install media, where
support for Endian-Independent FFS and Apple UFS is disabled unless FFS_EI=1
and APPLE_UFS=1 are added to CRUNCHENV, respectively.

This reduces the size of ramdisk image for atari by over 15KB.

Thanks tsutsui and christos for their useful comments.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base tls-maxphys-base
# 1.100 23-Jun-2013 dholland

branches: 1.100.10; 1.100.14;
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.99 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.98 19-Jun-2013 dholland

Rename ambiguous macros:
MAXDIRSIZE -> UFS_MAXDIRSIZE or LFS_MAXDIRSIZE
NINDIR -> FFS_NINDIR, EXT2_NINDIR, LFS_NINDIR, or MFS_NINDIR
INOPB -> FFS_INOPB, LFS_INOPB
INOPF -> FFS_INOPF, LFS_INOPF
blksize -> ffs_blksize, ext2_blksize, or lfs_blksize
sblksize -> ffs_blksize

These are not the only ambiguously defined filesystem macros, of
course, there's a pile more. I may not have found all the ambiguous
definitions of blksize(), too, as there are a lot of other things
called 'blksize' in the system.


# 1.97 09-Jun-2013 dholland

Stick UFS_ in front of these symbols:
DIRBLKSIZ
DIRECTSIZ
DIRSIZ
OLDDIRFMT
NEWDIRFMT

Part of PR 47909.


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.96 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.95 29-Jan-2012 nonaka

branches: 1.95.6;
use FS_UFS[12]_MAGIC_SWAPPED instead of bswap32(FS_UFS[12]_MAGIC).


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.94 14-Aug-2011 christos

branches: 1.94.2;
WARNS=4


# 1.93 09-Jun-2011 christos

share more code.


Revision tags: cherry-xenmp-base
# 1.92 20-Mar-2011 bouyer

branches: 1.92.2;
initialise memory allocated for uquot_user_hash & uquot_group_hash.
Pointed out by Nicolas Joly.


# 1.91 06-Mar-2011 bouyer

merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.90 31-Jan-2010 mlelstv

branches: 1.90.2;
Skip handling of APPLEUFS_LABEL if it is smaller than a device block.
In particular:

- newfs will not try to erase the label
- fsck_ffs will not try to validate the label

This lets newfs and fsck work on 2048-byte-per-sector media.

Does Apple UFS support such media and how?


Revision tags: matt-premerge-20091211
# 1.89 27-Sep-2009 bouyer

Restore changes from 1.86 and 1.87 after commit of 1.88.


# 1.88 13-Sep-2009 bouyer

Do some basic checks of the WAPBL journal, to abort the boot before the
kernel refuse to mount a filesystem read-write (booting a system
multiuser with critical filesystems read-only is bad):
Add a check_wapbl() which will check some WAPBL values in the superblock,
and try to read the journal via wapbl_replay_start() if there is one.
pfatal() if one of these fail (abort boot if in preen mode,
as "CONTINUE" otherwise). In non-preen mode the bogus journal will
be cleared.
check_wapbl() is always called if the superblock supports WAPBL.
Even if FS_DOWAPBL is not there, there could be flags asking the
kernel to clear or create a log with bogus values which would cause the
kernel refuse to mount the filesystem.
Discussed in
http://mail-index.netbsd.org/tech-kern/2009/08/17/msg005896.html
and followups.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.87 07-Apr-2009 mrg

fix a logic error in the previous, as point out by frank kardel.


# 1.86 25-Mar-2009 mrg

don't ignore "fsck -f" when given with "-p" on a wapbl filesystem.
ie, "fsck -fp" actually forces the check in preen mode now.


# 1.85 25-Feb-2009 christos

don't copy the address of a pointer. Noticed by Anon Ymous


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 mjf-devfs2-base
# 1.84 30-Aug-2008 bouyer

branches: 1.84.2; 1.84.4; 1.84.8;
Add fss(4) snapshot support to fsck_ffs(8) (via -x or -X options, like
dump(8)). This allows fsck_ffs -n to work on a snapshot of a R/W mounted
filesystem, and avoid errors related to filesystem activity.


# 1.83 31-Jul-2008 simonb

Merge the simonb-wapbl branch. From the original branch commit:

Add Wasabi System's WAPBL (Write Ahead Physical Block Logging)
journaling code. Originally written by Darrin B. Jewell while
at Wasabi and updated to -current by Antti Kantee, Andy Doran,
Greg Oster and Simon Burge.

OK'd by core@, releng@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.82 23-Feb-2008 christos

branches: 1.82.4; 1.82.6;
Make sure that the exit values are always sane, and use symbolic instead
of magic constants. Reviewed by go@


Revision tags: matt-armv6-prevmlocking cube-autoconf-base mjf-devfs-base matt-armv6-base
# 1.81 22-Aug-2007 christos

branches: 1.81.2; 1.81.8; 1.81.10;
Avoid zero-divides from Anon Ymous


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base netbsd-4-base
# 1.80 26-Aug-2006 christos

- Deal with wedges and the new disk geometry structures, instead of using
struct disklabel.

Functionality lost:
1. struct disklabel used to be updated to contain bsize, fsize, cpg.
This information was used to locate the alternative superblock in
the filesystem if the primary superblock was corrupted. We need
to find a new place to store this information if we need this
functionality.
2. On vax SMD drives that contained bad sector lists, the newfs program
knew how to get the offset and skip to the correct location in order
to place the label.


Revision tags: abandoned-netbsd-4-base
# 1.79 17-Mar-2006 rumble

Check for allocation failures in malloc, calloc, realloc, asprintf, and
vasprintf and try to handle them.


# 1.78 27-Jun-2005 christos

sprinkle const.


# 1.77 02-Jun-2005 dbj

for ufs2, assume FS_44INODEFMT
this is necessary for freebsd compatbility, since they do not initialize
the old field.


# 1.76 02-Jun-2005 lukem

appease gcc -Wuninitialized


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.75 19-Jan-2005 xtraeme

Kill __P(), ANSIfy and WARNS=2


# 1.74 29-Oct-2004 dsl

Rewrite getdisklabelpart() to avoid problems with isdigit(*ch_ptr) and
an incorrect check for a (probably impossible) empty string.
Add comments to avoid confusion...


# 1.73 14-Apr-2004 dbj

add support for downgrading a filesystem fslevel from 4 to 3


# 1.72 14-Apr-2004 dbj

set fs_old_nrpos to 1 when doing -c4 upgrade.
This isn't used by kernel, but does affect cg layout slightly


# 1.71 12-Apr-2004 dbj

fix whitespace in debug printf


Revision tags: netbsd-2-0-base
# 1.70 21-Mar-2004 dsl

branches: 1.70.2;
Don't use an ffsv1 superblock from 64k (SBLOCK_UFS2) when looking
for the main filesystem superblock.
64k is the offset of the first alternate if the blocksize if 64k.
Fixes part of PR kern/24809


# 1.69 20-Jan-2004 dbj

don't calculate fake superblock used for finding alternate superblocks
if the disklabel is missing the cpg parameter. Also print a warning
if this is skipped because of a missing fsize, frag or cpg disklabel parameter
this fixes a divide by zero error reported by martin@


# 1.68 12-Jan-2004 dbj

change the message "COVERTING TO FFSv2 SUPERBLOCK" to
"CONVERT TO NEW SUPERBLOCK LAYOUT" to help avoid confusion


# 1.67 10-Jan-2004 mrg

- some KNF (80 cols)
- fix a printf format issue


# 1.66 09-Jan-2004 dbj

use %#llx instead of %llx when printing incorrect qfmask or qbmask


# 1.65 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.64 02-Jan-2004 dbj

add uuid field to apple ufs volume label


# 1.63 20-Oct-2003 dsl

Add a -q (quiet) option to print nothing for clean filesystems.
Support in fsck_ffs and stub in fsck_xxx.
Push a few more messages through pwarn() instead of printf() to ensure
disk name is shown.


# 1.62 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.61 11-Apr-2003 enami

Correctly detect a UFS1 file system of non-native endian.


# 1.60 06-Apr-2003 fvdl

Write update some old fields when writing the superblock, similar to
ffs_oldfscompat_write() in the kernel. Use the old totals when
time < old_time (i.e. an old kernel or fsck wrote the filesystem last).
When setting the date back on a new kernel, that works out ok, since
new kernels always update both fields.


# 1.59 05-Apr-2003 fvdl

Skip checks for old 4.2BSD filesystem; as it stands, we can't deal with
writing them. Could be fixed, but doesn't have a high priority.


# 1.58 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.57 21-Feb-2003 fvdl

Only check relevant fields when comparing the superblock to an alternate
superblock. Avoids false positives should fsck_ffs be run on a filesystem
that was created after the UFS2 code has been merged.

This commit is mostly a forward compatibility patch that can be pulled
up in to the 1.6 branch.

From Kirk Mckusick in FreeBSD (setup.c rev. 1.30). Original commit message:


# 1.104 17-Nov-2022 chs

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).


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base phil-wifi-20200421
# 1.103 17-Apr-2020 jdolecek

align buffers used for I/O to DEV_BSIZE so it's executed more optimally
when run for xbd(4) raw (character) device


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.102 05-Oct-2018 hannken

Add a test for duplicate inodes on the persistent snapshot list.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.101 08-Feb-2017 rin

branches: 1.101.4; 1.101.10; 1.101.12;
Add smaller versions of fsck_ffs(8) and newfs(8) for install media, where
support for Endian-Independent FFS and Apple UFS is disabled unless FFS_EI=1
and APPLE_UFS=1 are added to CRUNCHENV, respectively.

This reduces the size of ramdisk image for atari by over 15KB.

Thanks tsutsui and christos for their useful comments.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base tls-maxphys-base
# 1.100 23-Jun-2013 dholland

branches: 1.100.10; 1.100.14;
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.99 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.98 19-Jun-2013 dholland

Rename ambiguous macros:
MAXDIRSIZE -> UFS_MAXDIRSIZE or LFS_MAXDIRSIZE
NINDIR -> FFS_NINDIR, EXT2_NINDIR, LFS_NINDIR, or MFS_NINDIR
INOPB -> FFS_INOPB, LFS_INOPB
INOPF -> FFS_INOPF, LFS_INOPF
blksize -> ffs_blksize, ext2_blksize, or lfs_blksize
sblksize -> ffs_blksize

These are not the only ambiguously defined filesystem macros, of
course, there's a pile more. I may not have found all the ambiguous
definitions of blksize(), too, as there are a lot of other things
called 'blksize' in the system.


# 1.97 09-Jun-2013 dholland

Stick UFS_ in front of these symbols:
DIRBLKSIZ
DIRECTSIZ
DIRSIZ
OLDDIRFMT
NEWDIRFMT

Part of PR 47909.


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.96 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.95 29-Jan-2012 nonaka

branches: 1.95.6;
use FS_UFS[12]_MAGIC_SWAPPED instead of bswap32(FS_UFS[12]_MAGIC).


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.94 14-Aug-2011 christos

branches: 1.94.2;
WARNS=4


# 1.93 09-Jun-2011 christos

share more code.


Revision tags: cherry-xenmp-base
# 1.92 20-Mar-2011 bouyer

branches: 1.92.2;
initialise memory allocated for uquot_user_hash & uquot_group_hash.
Pointed out by Nicolas Joly.


# 1.91 06-Mar-2011 bouyer

merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.90 31-Jan-2010 mlelstv

branches: 1.90.2;
Skip handling of APPLEUFS_LABEL if it is smaller than a device block.
In particular:

- newfs will not try to erase the label
- fsck_ffs will not try to validate the label

This lets newfs and fsck work on 2048-byte-per-sector media.

Does Apple UFS support such media and how?


Revision tags: matt-premerge-20091211
# 1.89 27-Sep-2009 bouyer

Restore changes from 1.86 and 1.87 after commit of 1.88.


# 1.88 13-Sep-2009 bouyer

Do some basic checks of the WAPBL journal, to abort the boot before the
kernel refuse to mount a filesystem read-write (booting a system
multiuser with critical filesystems read-only is bad):
Add a check_wapbl() which will check some WAPBL values in the superblock,
and try to read the journal via wapbl_replay_start() if there is one.
pfatal() if one of these fail (abort boot if in preen mode,
as "CONTINUE" otherwise). In non-preen mode the bogus journal will
be cleared.
check_wapbl() is always called if the superblock supports WAPBL.
Even if FS_DOWAPBL is not there, there could be flags asking the
kernel to clear or create a log with bogus values which would cause the
kernel refuse to mount the filesystem.
Discussed in
http://mail-index.netbsd.org/tech-kern/2009/08/17/msg005896.html
and followups.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.87 07-Apr-2009 mrg

fix a logic error in the previous, as point out by frank kardel.


# 1.86 25-Mar-2009 mrg

don't ignore "fsck -f" when given with "-p" on a wapbl filesystem.
ie, "fsck -fp" actually forces the check in preen mode now.


# 1.85 25-Feb-2009 christos

don't copy the address of a pointer. Noticed by Anon Ymous


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 mjf-devfs2-base
# 1.84 30-Aug-2008 bouyer

branches: 1.84.2; 1.84.4; 1.84.8;
Add fss(4) snapshot support to fsck_ffs(8) (via -x or -X options, like
dump(8)). This allows fsck_ffs -n to work on a snapshot of a R/W mounted
filesystem, and avoid errors related to filesystem activity.


# 1.83 31-Jul-2008 simonb

Merge the simonb-wapbl branch. From the original branch commit:

Add Wasabi System's WAPBL (Write Ahead Physical Block Logging)
journaling code. Originally written by Darrin B. Jewell while
at Wasabi and updated to -current by Antti Kantee, Andy Doran,
Greg Oster and Simon Burge.

OK'd by core@, releng@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.82 23-Feb-2008 christos

branches: 1.82.4; 1.82.6;
Make sure that the exit values are always sane, and use symbolic instead
of magic constants. Reviewed by go@


Revision tags: matt-armv6-prevmlocking cube-autoconf-base mjf-devfs-base matt-armv6-base
# 1.81 22-Aug-2007 christos

branches: 1.81.2; 1.81.8; 1.81.10;
Avoid zero-divides from Anon Ymous


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base netbsd-4-base
# 1.80 26-Aug-2006 christos

- Deal with wedges and the new disk geometry structures, instead of using
struct disklabel.

Functionality lost:
1. struct disklabel used to be updated to contain bsize, fsize, cpg.
This information was used to locate the alternative superblock in
the filesystem if the primary superblock was corrupted. We need
to find a new place to store this information if we need this
functionality.
2. On vax SMD drives that contained bad sector lists, the newfs program
knew how to get the offset and skip to the correct location in order
to place the label.


Revision tags: abandoned-netbsd-4-base
# 1.79 17-Mar-2006 rumble

Check for allocation failures in malloc, calloc, realloc, asprintf, and
vasprintf and try to handle them.


# 1.78 27-Jun-2005 christos

sprinkle const.


# 1.77 02-Jun-2005 dbj

for ufs2, assume FS_44INODEFMT
this is necessary for freebsd compatbility, since they do not initialize
the old field.


# 1.76 02-Jun-2005 lukem

appease gcc -Wuninitialized


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.75 19-Jan-2005 xtraeme

Kill __P(), ANSIfy and WARNS=2


# 1.74 29-Oct-2004 dsl

Rewrite getdisklabelpart() to avoid problems with isdigit(*ch_ptr) and
an incorrect check for a (probably impossible) empty string.
Add comments to avoid confusion...


# 1.73 14-Apr-2004 dbj

add support for downgrading a filesystem fslevel from 4 to 3


# 1.72 14-Apr-2004 dbj

set fs_old_nrpos to 1 when doing -c4 upgrade.
This isn't used by kernel, but does affect cg layout slightly


# 1.71 12-Apr-2004 dbj

fix whitespace in debug printf


Revision tags: netbsd-2-0-base
# 1.70 21-Mar-2004 dsl

branches: 1.70.2;
Don't use an ffsv1 superblock from 64k (SBLOCK_UFS2) when looking
for the main filesystem superblock.
64k is the offset of the first alternate if the blocksize if 64k.
Fixes part of PR kern/24809


# 1.69 20-Jan-2004 dbj

don't calculate fake superblock used for finding alternate superblocks
if the disklabel is missing the cpg parameter. Also print a warning
if this is skipped because of a missing fsize, frag or cpg disklabel parameter
this fixes a divide by zero error reported by martin@


# 1.68 12-Jan-2004 dbj

change the message "COVERTING TO FFSv2 SUPERBLOCK" to
"CONVERT TO NEW SUPERBLOCK LAYOUT" to help avoid confusion


# 1.67 10-Jan-2004 mrg

- some KNF (80 cols)
- fix a printf format issue


# 1.66 09-Jan-2004 dbj

use %#llx instead of %llx when printing incorrect qfmask or qbmask


# 1.65 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.64 02-Jan-2004 dbj

add uuid field to apple ufs volume label


# 1.63 20-Oct-2003 dsl

Add a -q (quiet) option to print nothing for clean filesystems.
Support in fsck_ffs and stub in fsck_xxx.
Push a few more messages through pwarn() instead of printf() to ensure
disk name is shown.


# 1.62 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.61 11-Apr-2003 enami

Correctly detect a UFS1 file system of non-native endian.


# 1.60 06-Apr-2003 fvdl

Write update some old fields when writing the superblock, similar to
ffs_oldfscompat_write() in the kernel. Use the old totals when
time < old_time (i.e. an old kernel or fsck wrote the filesystem last).
When setting the date back on a new kernel, that works out ok, since
new kernels always update both fields.


# 1.59 05-Apr-2003 fvdl

Skip checks for old 4.2BSD filesystem; as it stands, we can't deal with
writing them. Could be fixed, but doesn't have a high priority.


# 1.58 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.57 21-Feb-2003 fvdl

Only check relevant fields when comparing the superblock to an alternate
superblock. Avoids false positives should fsck_ffs be run on a filesystem
that was created after the UFS2 code has been merged.

This commit is mostly a forward compatibility patch that can be pulled
up in to the 1.6 branch.

From Kirk Mckusick in FreeBSD (setup.c rev. 1.30). Original commit message:


# 1.103 17-Apr-2020 jdolecek

align buffers used for I/O to DEV_BSIZE so it's executed more optimally
when run for xbd(4) raw (character) device


Revision tags: phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.102 05-Oct-2018 hannken

Add a test for duplicate inodes on the persistent snapshot list.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.101 08-Feb-2017 rin

branches: 1.101.4; 1.101.10; 1.101.12;
Add smaller versions of fsck_ffs(8) and newfs(8) for install media, where
support for Endian-Independent FFS and Apple UFS is disabled unless FFS_EI=1
and APPLE_UFS=1 are added to CRUNCHENV, respectively.

This reduces the size of ramdisk image for atari by over 15KB.

Thanks tsutsui and christos for their useful comments.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base tls-maxphys-base
# 1.100 23-Jun-2013 dholland

branches: 1.100.10; 1.100.14;
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.99 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.98 19-Jun-2013 dholland

Rename ambiguous macros:
MAXDIRSIZE -> UFS_MAXDIRSIZE or LFS_MAXDIRSIZE
NINDIR -> FFS_NINDIR, EXT2_NINDIR, LFS_NINDIR, or MFS_NINDIR
INOPB -> FFS_INOPB, LFS_INOPB
INOPF -> FFS_INOPF, LFS_INOPF
blksize -> ffs_blksize, ext2_blksize, or lfs_blksize
sblksize -> ffs_blksize

These are not the only ambiguously defined filesystem macros, of
course, there's a pile more. I may not have found all the ambiguous
definitions of blksize(), too, as there are a lot of other things
called 'blksize' in the system.


# 1.97 09-Jun-2013 dholland

Stick UFS_ in front of these symbols:
DIRBLKSIZ
DIRECTSIZ
DIRSIZ
OLDDIRFMT
NEWDIRFMT

Part of PR 47909.


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.96 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.95 29-Jan-2012 nonaka

branches: 1.95.6;
use FS_UFS[12]_MAGIC_SWAPPED instead of bswap32(FS_UFS[12]_MAGIC).


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.94 14-Aug-2011 christos

branches: 1.94.2;
WARNS=4


# 1.93 09-Jun-2011 christos

share more code.


Revision tags: cherry-xenmp-base
# 1.92 20-Mar-2011 bouyer

branches: 1.92.2;
initialise memory allocated for uquot_user_hash & uquot_group_hash.
Pointed out by Nicolas Joly.


# 1.91 06-Mar-2011 bouyer

merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.90 31-Jan-2010 mlelstv

branches: 1.90.2;
Skip handling of APPLEUFS_LABEL if it is smaller than a device block.
In particular:

- newfs will not try to erase the label
- fsck_ffs will not try to validate the label

This lets newfs and fsck work on 2048-byte-per-sector media.

Does Apple UFS support such media and how?


Revision tags: matt-premerge-20091211
# 1.89 27-Sep-2009 bouyer

Restore changes from 1.86 and 1.87 after commit of 1.88.


# 1.88 13-Sep-2009 bouyer

Do some basic checks of the WAPBL journal, to abort the boot before the
kernel refuse to mount a filesystem read-write (booting a system
multiuser with critical filesystems read-only is bad):
Add a check_wapbl() which will check some WAPBL values in the superblock,
and try to read the journal via wapbl_replay_start() if there is one.
pfatal() if one of these fail (abort boot if in preen mode,
as "CONTINUE" otherwise). In non-preen mode the bogus journal will
be cleared.
check_wapbl() is always called if the superblock supports WAPBL.
Even if FS_DOWAPBL is not there, there could be flags asking the
kernel to clear or create a log with bogus values which would cause the
kernel refuse to mount the filesystem.
Discussed in
http://mail-index.netbsd.org/tech-kern/2009/08/17/msg005896.html
and followups.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.87 07-Apr-2009 mrg

fix a logic error in the previous, as point out by frank kardel.


# 1.86 25-Mar-2009 mrg

don't ignore "fsck -f" when given with "-p" on a wapbl filesystem.
ie, "fsck -fp" actually forces the check in preen mode now.


# 1.85 25-Feb-2009 christos

don't copy the address of a pointer. Noticed by Anon Ymous


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 mjf-devfs2-base
# 1.84 30-Aug-2008 bouyer

branches: 1.84.2; 1.84.4; 1.84.8;
Add fss(4) snapshot support to fsck_ffs(8) (via -x or -X options, like
dump(8)). This allows fsck_ffs -n to work on a snapshot of a R/W mounted
filesystem, and avoid errors related to filesystem activity.


# 1.83 31-Jul-2008 simonb

Merge the simonb-wapbl branch. From the original branch commit:

Add Wasabi System's WAPBL (Write Ahead Physical Block Logging)
journaling code. Originally written by Darrin B. Jewell while
at Wasabi and updated to -current by Antti Kantee, Andy Doran,
Greg Oster and Simon Burge.

OK'd by core@, releng@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.82 23-Feb-2008 christos

branches: 1.82.4; 1.82.6;
Make sure that the exit values are always sane, and use symbolic instead
of magic constants. Reviewed by go@


Revision tags: matt-armv6-prevmlocking cube-autoconf-base mjf-devfs-base matt-armv6-base
# 1.81 22-Aug-2007 christos

branches: 1.81.2; 1.81.8; 1.81.10;
Avoid zero-divides from Anon Ymous


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base netbsd-4-base
# 1.80 26-Aug-2006 christos

- Deal with wedges and the new disk geometry structures, instead of using
struct disklabel.

Functionality lost:
1. struct disklabel used to be updated to contain bsize, fsize, cpg.
This information was used to locate the alternative superblock in
the filesystem if the primary superblock was corrupted. We need
to find a new place to store this information if we need this
functionality.
2. On vax SMD drives that contained bad sector lists, the newfs program
knew how to get the offset and skip to the correct location in order
to place the label.


Revision tags: abandoned-netbsd-4-base
# 1.79 17-Mar-2006 rumble

Check for allocation failures in malloc, calloc, realloc, asprintf, and
vasprintf and try to handle them.


# 1.78 27-Jun-2005 christos

sprinkle const.


# 1.77 02-Jun-2005 dbj

for ufs2, assume FS_44INODEFMT
this is necessary for freebsd compatbility, since they do not initialize
the old field.


# 1.76 02-Jun-2005 lukem

appease gcc -Wuninitialized


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.75 19-Jan-2005 xtraeme

Kill __P(), ANSIfy and WARNS=2


# 1.74 29-Oct-2004 dsl

Rewrite getdisklabelpart() to avoid problems with isdigit(*ch_ptr) and
an incorrect check for a (probably impossible) empty string.
Add comments to avoid confusion...


# 1.73 14-Apr-2004 dbj

add support for downgrading a filesystem fslevel from 4 to 3


# 1.72 14-Apr-2004 dbj

set fs_old_nrpos to 1 when doing -c4 upgrade.
This isn't used by kernel, but does affect cg layout slightly


# 1.71 12-Apr-2004 dbj

fix whitespace in debug printf


Revision tags: netbsd-2-0-base
# 1.70 21-Mar-2004 dsl

branches: 1.70.2;
Don't use an ffsv1 superblock from 64k (SBLOCK_UFS2) when looking
for the main filesystem superblock.
64k is the offset of the first alternate if the blocksize if 64k.
Fixes part of PR kern/24809


# 1.69 20-Jan-2004 dbj

don't calculate fake superblock used for finding alternate superblocks
if the disklabel is missing the cpg parameter. Also print a warning
if this is skipped because of a missing fsize, frag or cpg disklabel parameter
this fixes a divide by zero error reported by martin@


# 1.68 12-Jan-2004 dbj

change the message "COVERTING TO FFSv2 SUPERBLOCK" to
"CONVERT TO NEW SUPERBLOCK LAYOUT" to help avoid confusion


# 1.67 10-Jan-2004 mrg

- some KNF (80 cols)
- fix a printf format issue


# 1.66 09-Jan-2004 dbj

use %#llx instead of %llx when printing incorrect qfmask or qbmask


# 1.65 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.64 02-Jan-2004 dbj

add uuid field to apple ufs volume label


# 1.63 20-Oct-2003 dsl

Add a -q (quiet) option to print nothing for clean filesystems.
Support in fsck_ffs and stub in fsck_xxx.
Push a few more messages through pwarn() instead of printf() to ensure
disk name is shown.


# 1.62 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.61 11-Apr-2003 enami

Correctly detect a UFS1 file system of non-native endian.


# 1.60 06-Apr-2003 fvdl

Write update some old fields when writing the superblock, similar to
ffs_oldfscompat_write() in the kernel. Use the old totals when
time < old_time (i.e. an old kernel or fsck wrote the filesystem last).
When setting the date back on a new kernel, that works out ok, since
new kernels always update both fields.


# 1.59 05-Apr-2003 fvdl

Skip checks for old 4.2BSD filesystem; as it stands, we can't deal with
writing them. Could be fixed, but doesn't have a high priority.


# 1.58 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.57 21-Feb-2003 fvdl

Only check relevant fields when comparing the superblock to an alternate
superblock. Avoids false positives should fsck_ffs be run on a filesystem
that was created after the UFS2 code has been merged.

This commit is mostly a forward compatibility patch that can be pulled
up in to the 1.6 branch.

From Kirk Mckusick in FreeBSD (setup.c rev. 1.30). Original commit message:


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020
# 1.102 05-Oct-2018 hannken

Add a test for duplicate inodes on the persistent snapshot list.


Revision tags: pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.101 08-Feb-2017 rin

branches: 1.101.4; 1.101.10;
Add smaller versions of fsck_ffs(8) and newfs(8) for install media, where
support for Endian-Independent FFS and Apple UFS is disabled unless FFS_EI=1
and APPLE_UFS=1 are added to CRUNCHENV, respectively.

This reduces the size of ramdisk image for atari by over 15KB.

Thanks tsutsui and christos for their useful comments.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base tls-maxphys-base
# 1.100 23-Jun-2013 dholland

branches: 1.100.10; 1.100.14;
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.99 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.98 19-Jun-2013 dholland

Rename ambiguous macros:
MAXDIRSIZE -> UFS_MAXDIRSIZE or LFS_MAXDIRSIZE
NINDIR -> FFS_NINDIR, EXT2_NINDIR, LFS_NINDIR, or MFS_NINDIR
INOPB -> FFS_INOPB, LFS_INOPB
INOPF -> FFS_INOPF, LFS_INOPF
blksize -> ffs_blksize, ext2_blksize, or lfs_blksize
sblksize -> ffs_blksize

These are not the only ambiguously defined filesystem macros, of
course, there's a pile more. I may not have found all the ambiguous
definitions of blksize(), too, as there are a lot of other things
called 'blksize' in the system.


# 1.97 09-Jun-2013 dholland

Stick UFS_ in front of these symbols:
DIRBLKSIZ
DIRECTSIZ
DIRSIZ
OLDDIRFMT
NEWDIRFMT

Part of PR 47909.


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.96 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.95 29-Jan-2012 nonaka

branches: 1.95.6;
use FS_UFS[12]_MAGIC_SWAPPED instead of bswap32(FS_UFS[12]_MAGIC).


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.94 14-Aug-2011 christos

branches: 1.94.2;
WARNS=4


# 1.93 09-Jun-2011 christos

share more code.


Revision tags: cherry-xenmp-base
# 1.92 20-Mar-2011 bouyer

branches: 1.92.2;
initialise memory allocated for uquot_user_hash & uquot_group_hash.
Pointed out by Nicolas Joly.


# 1.91 06-Mar-2011 bouyer

merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.90 31-Jan-2010 mlelstv

branches: 1.90.2;
Skip handling of APPLEUFS_LABEL if it is smaller than a device block.
In particular:

- newfs will not try to erase the label
- fsck_ffs will not try to validate the label

This lets newfs and fsck work on 2048-byte-per-sector media.

Does Apple UFS support such media and how?


Revision tags: matt-premerge-20091211
# 1.89 27-Sep-2009 bouyer

Restore changes from 1.86 and 1.87 after commit of 1.88.


# 1.88 13-Sep-2009 bouyer

Do some basic checks of the WAPBL journal, to abort the boot before the
kernel refuse to mount a filesystem read-write (booting a system
multiuser with critical filesystems read-only is bad):
Add a check_wapbl() which will check some WAPBL values in the superblock,
and try to read the journal via wapbl_replay_start() if there is one.
pfatal() if one of these fail (abort boot if in preen mode,
as "CONTINUE" otherwise). In non-preen mode the bogus journal will
be cleared.
check_wapbl() is always called if the superblock supports WAPBL.
Even if FS_DOWAPBL is not there, there could be flags asking the
kernel to clear or create a log with bogus values which would cause the
kernel refuse to mount the filesystem.
Discussed in
http://mail-index.netbsd.org/tech-kern/2009/08/17/msg005896.html
and followups.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.87 07-Apr-2009 mrg

fix a logic error in the previous, as point out by frank kardel.


# 1.86 25-Mar-2009 mrg

don't ignore "fsck -f" when given with "-p" on a wapbl filesystem.
ie, "fsck -fp" actually forces the check in preen mode now.


# 1.85 25-Feb-2009 christos

don't copy the address of a pointer. Noticed by Anon Ymous


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 mjf-devfs2-base
# 1.84 30-Aug-2008 bouyer

branches: 1.84.2; 1.84.4; 1.84.8;
Add fss(4) snapshot support to fsck_ffs(8) (via -x or -X options, like
dump(8)). This allows fsck_ffs -n to work on a snapshot of a R/W mounted
filesystem, and avoid errors related to filesystem activity.


# 1.83 31-Jul-2008 simonb

Merge the simonb-wapbl branch. From the original branch commit:

Add Wasabi System's WAPBL (Write Ahead Physical Block Logging)
journaling code. Originally written by Darrin B. Jewell while
at Wasabi and updated to -current by Antti Kantee, Andy Doran,
Greg Oster and Simon Burge.

OK'd by core@, releng@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.82 23-Feb-2008 christos

branches: 1.82.4; 1.82.6;
Make sure that the exit values are always sane, and use symbolic instead
of magic constants. Reviewed by go@


Revision tags: matt-armv6-prevmlocking cube-autoconf-base mjf-devfs-base matt-armv6-base
# 1.81 22-Aug-2007 christos

branches: 1.81.2; 1.81.8; 1.81.10;
Avoid zero-divides from Anon Ymous


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base wrstuden-fixsa-base netbsd-4-base
# 1.80 26-Aug-2006 christos

- Deal with wedges and the new disk geometry structures, instead of using
struct disklabel.

Functionality lost:
1. struct disklabel used to be updated to contain bsize, fsize, cpg.
This information was used to locate the alternative superblock in
the filesystem if the primary superblock was corrupted. We need
to find a new place to store this information if we need this
functionality.
2. On vax SMD drives that contained bad sector lists, the newfs program
knew how to get the offset and skip to the correct location in order
to place the label.


Revision tags: abandoned-netbsd-4-base
# 1.79 17-Mar-2006 rumble

Check for allocation failures in malloc, calloc, realloc, asprintf, and
vasprintf and try to handle them.


# 1.78 27-Jun-2005 christos

sprinkle const.


# 1.77 02-Jun-2005 dbj

for ufs2, assume FS_44INODEFMT
this is necessary for freebsd compatbility, since they do not initialize
the old field.


# 1.76 02-Jun-2005 lukem

appease gcc -Wuninitialized


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.75 19-Jan-2005 xtraeme

Kill __P(), ANSIfy and WARNS=2


# 1.74 29-Oct-2004 dsl

Rewrite getdisklabelpart() to avoid problems with isdigit(*ch_ptr) and
an incorrect check for a (probably impossible) empty string.
Add comments to avoid confusion...


# 1.73 14-Apr-2004 dbj

add support for downgrading a filesystem fslevel from 4 to 3


# 1.72 14-Apr-2004 dbj

set fs_old_nrpos to 1 when doing -c4 upgrade.
This isn't used by kernel, but does affect cg layout slightly


# 1.71 12-Apr-2004 dbj

fix whitespace in debug printf


Revision tags: netbsd-2-0-base
# 1.70 21-Mar-2004 dsl

branches: 1.70.2;
Don't use an ffsv1 superblock from 64k (SBLOCK_UFS2) when looking
for the main filesystem superblock.
64k is the offset of the first alternate if the blocksize if 64k.
Fixes part of PR kern/24809


# 1.69 20-Jan-2004 dbj

don't calculate fake superblock used for finding alternate superblocks
if the disklabel is missing the cpg parameter. Also print a warning
if this is skipped because of a missing fsize, frag or cpg disklabel parameter
this fixes a divide by zero error reported by martin@


# 1.68 12-Jan-2004 dbj

change the message "COVERTING TO FFSv2 SUPERBLOCK" to
"CONVERT TO NEW SUPERBLOCK LAYOUT" to help avoid confusion


# 1.67 10-Jan-2004 mrg

- some KNF (80 cols)
- fix a printf format issue


# 1.66 09-Jan-2004 dbj

use %#llx instead of %llx when printing incorrect qfmask or qbmask


# 1.65 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.64 02-Jan-2004 dbj

add uuid field to apple ufs volume label


# 1.63 20-Oct-2003 dsl

Add a -q (quiet) option to print nothing for clean filesystems.
Support in fsck_ffs and stub in fsck_xxx.
Push a few more messages through pwarn() instead of printf() to ensure
disk name is shown.


# 1.62 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.61 11-Apr-2003 enami

Correctly detect a UFS1 file system of non-native endian.


# 1.60 06-Apr-2003 fvdl

Write update some old fields when writing the superblock, similar to
ffs_oldfscompat_write() in the kernel. Use the old totals when
time < old_time (i.e. an old kernel or fsck wrote the filesystem last).
When setting the date back on a new kernel, that works out ok, since
new kernels always update both fields.


# 1.59 05-Apr-2003 fvdl

Skip checks for old 4.2BSD filesystem; as it stands, we can't deal with
writing them. Could be fixed, but doesn't have a high priority.


# 1.58 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.57 21-Feb-2003 fvdl

Only check relevant fields when comparing the superblock to an alternate
superblock. Avoids false positives should fsck_ffs be run on a filesystem
that was created after the UFS2 code has been merged.

This commit is mostly a forward compatibility patch that can be pulled
up in to the 1.6 branch.

From Kirk Mckusick in FreeBSD (setup.c rev. 1.30). Original commit message: