diff options
author | Thorsten Lockert <tholo@cvs.openbsd.org> | 1997-02-20 06:03:05 +0000 |
---|---|---|
committer | Thorsten Lockert <tholo@cvs.openbsd.org> | 1997-02-20 06:03:05 +0000 |
commit | 0ee12330ded542c62dd65fab4c9ebf99a9cf411e (patch) | |
tree | fc9da5181ce099b3b8992cff4eb6f329a1636da6 /sbin/fsck_ffs | |
parent | bd711bf14625ae42e78517cf019036b2112ca3cb (diff) |
From FreeBSD [Terry Lambert]:
The following small diff fixes the annoying fsck bug that causes it to
need to be run twice to end up with correct reference counts for inodes
for directories that had subdirectories relocated into the lost+found
directory.
I found the need to rerun *extremely* annoying. This fix causes the
count to be correctly adjusted later in pass 4 by correctly stating
the parent reference count.
Note that the parent reference count is incremented when the directory
entry is made (for ".."), but is not really there in the case of a
directory that does not make an entry in its parent dir.
This can be tested by waiting for the inode sync after cd'ing from a
shell into a test fs. Then you "mkdir xxx yyy zzz", wait a second,
and hit the machine reset button.
Diffstat (limited to 'sbin/fsck_ffs')
-rw-r--r-- | sbin/fsck_ffs/dir.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c index 6bd11ba8e24..9b79c368fe5 100644 --- a/sbin/fsck_ffs/dir.c +++ b/sbin/fsck_ffs/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.3 1996/10/20 08:36:30 tholo Exp $ */ +/* $OpenBSD: dir.c,v 1.4 1997/02/20 06:03:04 tholo Exp $ */ /* $NetBSD: dir.c,v 1.20 1996/09/27 22:45:11 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)dir.c 8.5 (Berkeley) 12/8/94"; #else -static char rcsid[] = "$OpenBSD: dir.c,v 1.3 1996/10/20 08:36:30 tholo Exp $"; +static char rcsid[] = "$OpenBSD: dir.c,v 1.4 1997/02/20 06:03:04 tholo Exp $"; #endif #endif /* not lint */ @@ -504,8 +504,17 @@ linkup(orphan, parentdir) inodirty(); lncntp[lfdir]++; pwarn("DIR I=%u CONNECTED. ", orphan); - if (parentdir != (ino_t)-1) + if (parentdir != (ino_t)-1) { printf("PARENT WAS I=%u\n", parentdir); + /* + * The parent directory, because of the ordering + * guarantees, has had the link count incremented + * for the child, but no entry was made. This + * fixes the parent link count so that fsck does + * not need to be rerun. + */ + lncntp[parentdir]++; + } if (preen == 0) printf("\n"); } |