History log of /netbsd-current/sbin/fsck_ffs/dir.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.62 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.


Revision tags: netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 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
# 1.61 05-May-2019 christos

Add a -z flag to zero out the up to 4 bytes of padding in directory entry
names (including the terminating NUL), as well as directory entries with
extra free space (d->d_reclen > UFS_DIRSIZ(d)).

Inspired from FreeBSD:
https://svnweb.freebsd.org/base?view=revision&revision=347066

While the kernel has been fixed to deal with the padding bytes (new
kernels will correctly zero out all the padding after the name), it
appears that there is still an issue with directory entries with extra
free space, since a newly created and populated filesystem gets modified
with "fsck_ffs -z".


# 1.60 05-May-2019 christos

simplify the endian byte-swapping code.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.59 08-Nov-2018 msaitoh

"s/ are are / are /" in comment. No functional change.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-1020 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.58 08-Feb-2017 rin

branches: 1.58.10; 1.58.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.57 23-Jun-2013 dholland

branches: 1.57.10; 1.57.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.56 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.55 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.54 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 yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.53 06-Mar-2011 bouyer

branches: 1.53.4; 1.53.10;
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 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.52 11-Apr-2009 lukem

branches: 1.52.2;
fix sign-compare issues


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 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 simonb-wapbl-nbase simonb-wapbl-base mjf-devfs2-base
# 1.51 08-Jul-2008 simonb

branches: 1.51.4;
Fix funny whitespace in a variable assignment.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 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.50 23-Feb-2008 christos

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


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base mjf-devfs-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base wrstuden-fixsa-base netbsd-4-base
# 1.49 16-Oct-2006 christos

branches: 1.49.8; 1.49.16; 1.49.18;
c99 initializers


Revision tags: abandoned-netbsd-4-base
# 1.48 21-Apr-2006 skrll

Don't use cast expressions as lvalues as newer versions of gcc warn.


# 1.47 23-Dec-2005 yamt

linkup: reparent() only when lost+found is created successfully.


# 1.46 19-Aug-2005 christos

64 bit inode changes


# 1.45 27-Jun-2005 christos

sprinkle const.


# 1.44 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.43 20-Jan-2005 xtraeme

whitespace (pointed out by wiz@)


# 1.42 19-Jan-2005 xtraeme

Kill __P(), ANSIfy and WARNS=2


# 1.41 08-Oct-2004 dbj

have allocdir fail cleanly when allocino fails


# 1.40 20-Jul-2004 mycroft

Reduce memory usage slightly.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.39 10-Jan-2004 mrg

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


# 1.38 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.37 13-Jul-2003 itojun

use bounded string op


# 1.36 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.35 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.


Revision tags: fvdl_fs64_base
# 1.34 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.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.33 09-May-2002 simonb

Don't bother testing if a uint8_t is > 256 -- that test is always false.


# 1.32 23-Jan-2001 mycroft

Fix a rather glaring byte-swapping bug: di_size is 64 bits, not 16.


# 1.31 10-Jan-2001 mycroft

Whoops; call propagate() with the right child inode number. (Doesn't break
anything, but it would have made reconnect less efficient.)


# 1.30 10-Jan-2001 mycroft

Abstract the code to attach a directory to its parent's child list into a
separate function, and call it from multiple places in linkup() to handle
reconnects and creation of /lost+found.


# 1.29 09-Jan-2001 mycroft

The reconnect algorithm was historically O(n^4).
Some years ago I made it O(n^2).
Someone helpfully made it O(n^4) again.
Today I'm making it O(n).
If that's not good enough, I don't know what else to do. B-)

Technical details:
* The graph traversal in propagate() is modified to be able to start from any
point in the tree. To handle certain exceptional cases, it is also modified
to work in two passes, marking the tree with a special tag and then changing
it to DFOUND.
* The reconnect case now modifies the child/sibling pointers and calls
propagate() to propagate the connection state starting with the reconnected
directory.

Pray that you never encounter a file system trashed enough for this to matter.


# 1.28 14-Dec-2000 simonb

Need an lfdir global variable now.


# 1.27 03-Aug-2000 castor

Fix an evil ugly bug which causes files placed into lost+found to
be inconsistent, and unremovable. From Ethan Solomita <ethan@geocast.com>.
Reviewed by fvdl.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.26 15-Nov-1999 fvdl

branches: 1.26.4;
Changes for softdep code.


Revision tags: netbsd-1-4-PATCH002 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.25 18-Mar-1998 bouyer

branches: 1.25.2; 1.25.4; 1.25.8;
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").


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.24 20-Sep-1997 lukem

- don't indiscriminately include <stdlib.h> and <unistd.h> in "fsck.h"
- explicitly pull in <stdio.h>, <stdlib.h> and <unistd.h> in *.c as necessary


# 1.23 16-Sep-1997 lukem

resolve conflicts from lite-2 merge.


# 1.22 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.21 21-Apr-1997 mrg

lost+found directories are mode -1700


# 1.20 27-Sep-1996 christos

- util.h -> fsutil.h


# 1.19 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.18 11-Jun-1996 mycroft

Use a different tree-walking algorithm in propagate().


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.17 18-Mar-1995 cgd

branches: 1.17.4;
convert to new RCS Id conventions; reduce my headache


# 1.16 28-Dec-1994 mycroft

Mostly sync with CSRG.


# 1.15 05-Dec-1994 cgd

more cleanups from Jim Jegers, passed over by me.


# 1.14 28-Oct-1994 mycroft

On a recursive call to fsck_readdir() through getpathname(), don't attempt to
fix a problem that's already being fixed.


# 1.13 06-Oct-1994 mycroft

dircheck() shouldn't be looking at d_type or d_namlen in blank entries
*at all*. Not only is it wrong, but it causes a serious problem on
little-endian machines, since after -c2 conversion, d_type will often
be > 15.


# 1.12 23-Sep-1994 mycroft

Remove some more uses of obsolete functions.


# 1.11 23-Sep-1994 mycroft

Eliminate uses of some obsolete functions.


# 1.10 20-Sep-1994 mycroft

A correct fix for the byte order problem when reconnecting.


# 1.9 29-Jul-1994 mycroft

Fix oversight in last patch.


# 1.8 28-Jul-1994 mycroft

Fix byte-order problem with directory entry creation.


# 1.7 08-Jun-1994 mycroft

branches: 1.7.2;
Update from 4.4-Lite, with local changes.


# 1.6 25-Apr-1994 cgd

need <sys/time.h>


# 1.5 05-Nov-1993 mycroft

Patch from Bruce Evans to deal with file names with NULs in them.


# 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