Home | History | Annotate | Download | only in fsck_lfs
History log of /src/sbin/fsck_lfs/dir.c
RevisionDateAuthorComments
 1.47  03-Apr-2020  joerg Avoid common symbols for fsck_lfs.
 1.46  21-Sep-2015  dholland branches: 1.46.16;
Add 64-bit directory entry structures, and adjust accessors accordingly.

The LFS64 directory entry has a 64-bit inode number. This is stored as
two 32-bit values to avoid inducing 64-bit alignment requirements.

The exposed type for manipulating directory entries is now
LFS_DIRHEADER, following the same convention as e.g. IFILE and SEGUSE.
(But with LFS_ on it, because.)
 1.45  21-Sep-2015  dholland Oops; LFS_DIRECTSIZ() is going to need the fs as an argument.

Also, it turns out that dirhash needs a compile-time-constant version
of LFS_DIRECTSIZ(LFS_MAXNAMLEN+1), independent of 64-vs-32, so create
LFS_MAXDIRENTRYSIZE for this. Sigh.
 1.44  20-Sep-2015  dholland Clean up struct lfs_dirtemplate.
 1.43  15-Sep-2015  dholland Pass around struct lfs_dirheader instead of struct lfs_direct.
 1.42  15-Sep-2015  dholland Add an accessor function for directory names.
 1.41  15-Sep-2015  dholland Add a function lfs_copydirname() to copy directory names in place; use
it in place of (variously) memcpy and strlcpy. (The latter isn't even
correct; was probably changed blindly from strncpy at some point.)

The new function zeroes the padding in the directory entry instead of
leaving trash behind.
 1.40  15-Sep-2015  dholland Tidyups/fixes preparatory to making d_name[] in struct lfs_direct size
0 instead of size LFS_MAXNAMLEN+1, and preparatory to having accessor
functions for d_name. In particular, don't create prototype entries
and copy them, and access the name field only for directory structures
that are in buffers with space for the name to exist.
 1.39  15-Sep-2015  dholland Add and use accessor functions for more of the directory entry fields.
 1.38  01-Sep-2015  dholland Add new accessors for the d_type and d_namlen fields of struct lfs_direct.
Napalm the old byteswap access logic for these.
 1.37  01-Sep-2015  dholland Use the lfs dinode accessors in place of the ufs-derived ones.
(Mostly.)

The ufs-derived ones are fake structure member macros, which are gross
and not very safe. Also, it seems that a lot of places in the lfs code
were using the ffsv1 branch of them unconditionally, and this way it's
guaranteed all those places have been updated.

Found while doing this: for non-devices, have getattr produce NODEV
in the rdev field instead of leaking the address of the first direct
block.
 1.36  12-Aug-2015  dholland Hack up dinode usage to be 64 vs. 32 as needed. Part 1.

(This part changes the native lfs code; the ufs-derived code already
has 64 vs. 32 logic, but as aspects of it are unsafe, and don't
entirely interoperate cleanly with the lfs 64/32 stuff, pass 2 will be
rehashing that.)
 1.35  28-Jul-2015  dholland Add a new lfs header file: lfs_accessors.h.

This contains all the accessor functions and macros out of lfs.h.
Add an include of lfs_accessors.h after all uses of lfs.h... except
for code that wants to define its own struct lfs-alike that the
accessors are supposed to play along with. For these, set STRUCT_LFS
and include lfs_accessors.h after the necessary structure has been
defined, so that lfs_accessors.h can emit functions in terms of it.
 1.34  24-Jul-2015  dholland Switch to accessor functions for elements of the LFS on-disk
superblock. This will allow switching between 32/64 bit forms on the
fly; it will also allow handling LFS_EI reasonably tidily. (That
currently doesn't work on the superblock.)

It also gets rid of cpp abuse in the form of fake structure member
macros.

Also, instead of doing sleep/wakeup on &lfs_avail and &lfs_nextseg
inside the on-disk superblock, add extra elements to the in-memory
struct lfs for this. (XXX: these should be changed to condvars, but
not right now)

XXX: this migrates a structure needed by the lfs code in libsa (struct
salfs) into lfs.h, where it doesn't belong, but for the time being
this is necessary in order to allow the accessors (and the various
lfs macros and other goop that relies on them) to compile.
 1.33  29-Mar-2015  chopps - Fix fallout for recent bread() change (removing cred arg).
 1.32  18-Jun-2013  christos Prefix most of the cpp macros with lfs_ and LFS_ to avoid conflicts with ffs.
This was done so that boot blocks that want to compile both FFS and LFS in
the same file work.
 1.31  08-Jun-2013  dholland Tidy up the LFS userland build hacks.
Don't use -I${NETBSDSRCDIR}/sys; don't include files other than the
exported LFS headers, which are lfs.h, lfs_inode.h, and (for now)
lfs_extern.h.
 1.30  08-Jun-2013  dholland DIRBLKSIZ -> LFS_DIRBLKSIZ
DIRECTSIZ -> LFS_DIRECTSIZ
DIRSIZ -> LFS_DIRSIZ
OLDDIRFMT -> LFS_OLDDIRFMT
NEWDIRFMT -> LFS_NEWDIRFMT
IFTODT -> LFS_IFTODT
DTTOIF -> LFS_DTTOIF
 1.29  08-Jun-2013  dholland struct direct -> struct lfs_direct
struct dirtemplate -> struct lfs_dirtemplate
struct odirtemplate -> struct lfs_odirtemplate
DT_* -> LFS_DT_*
 1.28  08-Jun-2013  dholland Stick LFS_ in front of IFMT, IFIFO, IFREG, etc. so as not to conflict
with the UFS copies of these symbols. (Which themselves ought to have
UFS_ stuck on.)
 1.27  06-Jun-2013  dholland ufs -> ulfs for fsck_lfs.
 1.26  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.25  16-Feb-2010  mlelstv branches: 1.25.6; 1.25.12;
Three changes in a single commit.

- drop the notion of frags (LFS fragments) vs fsb (FFS fragments)
The code uses a complicated unity function that just makes the
code difficult to understand.

- support larger sector sizes. Fix disk address computations
to use DEV_BSIZE in the kernel as required by device drivers
and to use sector sizes in userland.

- Fix several locking bugs in lfs_bio.c and lfs_subr.c.
 1.24  16-May-2008  hannken Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write. Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn(). If set the caller
intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
may clear the buffer and runs copy-on-write. Process possible errors
from getblk() or fscow_run(). Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
 1.23  16-Mar-2008  lukem branches: 1.23.2; 1.23.4;
errexit() now provides the trailing \n (since fsck_ffs assumed that
from a conversion from err(3)), so "make it so".
 1.22  08-Oct-2007  ad branches: 1.22.6; 1.22.8;
Give brelse() a second argument so that it matches the kernel.
fsck_lfs now compiles again.
 1.21  16-Oct-2006  christos branches: 1.21.8;
c99 initializers
 1.20  01-Sep-2006  perseant Several fixes to improve the reliability of the roll-forward agent.
Also, note "properly orphaned" files as distinct from corrupted files.
 1.19  13-Sep-2005  christos rename lfs.h to lfs_user.h so that it does not conflict.
 1.18  19-Aug-2005  christos 64 bit inode changes
 1.17  27-Jun-2005  christos more const.
 1.16  27-Jun-2005  christos constify
 1.15  08-Jun-2005  perseant Use the correct method to create a new inode, when we allocate lost+found.

Correct uninitialized variable issues in pass6.c and dir.c (PR#30411 and
PR#30394, respectively).
 1.14  19-Jan-2005  xtraeme ANSIfy, WARNS=2
 1.13  05-Oct-2003  jdolecek fix NULL pointer pointer dereference in fileerror() when ino is NULL

problem reported and fix provided in PR kern/23065 by Gary Duzan, only
slightly adjusted to only do the VTOI() when needed
 1.12  03-Oct-2003  yamt write out modified directory entries to the correct place.
 1.11  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.10  13-Jul-2003  itojun use bounded string op
 1.9  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.8  28-Mar-2003  perseant Add working writing ability to fsck_lfs, including roll-forward, based on
a partial-segment writer ported from the kernel.
 1.7  23-May-2002  perseant Re-checksum the superblock whenever it is marked dirty.

Tested on alpha.
 1.6  09-May-2002  simonb branches: 1.6.2;
Don't bother testing if a uint8_t is > 256 -- that test is always false.
 1.5  13-Jul-2001  perseant Merge the short-lived perseant-lfsv2 branch into the trunk.

Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default. Changes for the v2 layout include:

- Segments of non-PO2 size and arbitrary block offset, so these can be
matched to convenient physical characteristics of the partition (e.g.,
stripe or track size and offset).

- Address by fragment instead of by disk sector, paving the way for
non-512-byte-sector devices. In theory fragments can be as large
as you like, though in reality they must be smaller than MAXBSIZE in size.

- Use serial number and filesystem identifier to ensure that roll-forward
doesn't get old data and think it's new. Roll-forward is enabled for
v2 filesystems, though not for v1 filesystems by default.

- The inode free list is now a tailq, paving the way for undelete (undelete
is not yet implemented, but can be without further non-backwards-compatible
changes to disk structures).

- Inode atime information is kept in the Ifile, instead of on the inode;
that is, the inode is never written *just* because atime was changed.
Because of this the inodes remain near the file data on the disk, rather
than wandering all over as the disk is read repeatedly. This speeds up
repeated reads by a small but noticeable amount.

Other changes of note include:

- The ifile written by newfs_lfs can now be of arbitrary length, it is no
longer restricted to a single indirect block.

- Fixed an old bug where ctime was changed every time a vnode was created.
I need to look more closely to make sure that the times are only updated
during write(2) and friends, not after-the-fact during a segment write,
and certainly not by the cleaner.
 1.4  14-Jun-2000  perseant branches: 1.4.4;
Add "-i" flag to specify the location of the index file inode, to
examine alternate checkpoints. Regularize usage of maxino. Remove olf
debugging cruft.
 1.3  23-May-2000  perseant branches: 1.3.2;
Convert to NetBSD source code style
 1.2  03-Jul-1999  kleink RCS Id police.
 1.1  18-Mar-1999  perseant Initial checkin of fsck_lfs. This version cannot do any repair (-p flag
does nothing, and one of -p or -n is required) but can be useful as a
diagnostic tool.
 1.3.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.4.4.1  02-Jul-2001  perseant Change disk addressing unit to be the fragment, instead of the disk sector.
All quantities in the superblock, inodes, indirect blocks, etc. refer now
to this abstract unit (called "fsb" as it is in FFS) instead of disk sectors;
as a consequence segment summary blocks have to be multiples of a fragment in
size. In v1 filesystems, compatibility code ensures that 1 fsb == 1 sector,
regardless of fragment size.

Fragments can now range in size between 512 and 32k; in the event that
LFS_LABELPAD (8k) is smaller than the disk address unit size, an extra
proto-superblock is kept at 8k from the beginning of the disk, to be used
*only* to locate the real superblocks. (Not all of the userland knows about
this yet.)

Almost all of this was done not by me, but by joff.
 1.6.2.1  02-Jun-2002  tv Pull up revision 1.7 (requested by perseant in ticket #131):
Re-checksum the superblock whenever it is marked dirty.
Tested on alpha.
 1.21.8.2  23-Mar-2008  matt sync with HEAD
 1.21.8.1  06-Nov-2007  matt sync with HEAD
 1.22.8.2  02-Jun-2008  mjf Sync with HEAD.
 1.22.8.1  03-Apr-2008  mjf Sync with HEAD.
 1.22.6.1  24-Mar-2008  keiichi sync with head.
 1.23.4.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.23.2.1  18-May-2008  yamt sync with head.
 1.25.12.2  23-Jun-2013  tls resync from head
 1.25.12.1  25-Feb-2013  tls resync with head
 1.25.6.2  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.25.6.1  23-Jan-2013  yamt sync with head
 1.46.16.1  08-Apr-2020  martin Merge changes from current as of 20200406

RSS XML Feed