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

This commit is contained in:
mycroft 1996-06-11 07:07:52 +00:00
parent cc47447cfc
commit 96dea9e6ca
4 changed files with 34 additions and 30 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.17 1995/03/18 14:55:40 cgd Exp $ */
/* $NetBSD: dir.c,v 1.18 1996/06/11 07:07:52 mycroft Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)dir.c 8.5 (Berkeley) 12/8/94";
#else
static char rcsid[] = "$NetBSD: dir.c,v 1.17 1995/03/18 14:55:40 cgd Exp $";
static char rcsid[] = "$NetBSD: dir.c,v 1.18 1996/06/11 07:07:52 mycroft Exp $";
#endif
#endif /* not lint */
@ -78,24 +78,34 @@ int lftempname __P((char *, ino_t));
void
propagate()
{
register struct inoinfo **inpp, *inp;
register struct inoinfo **inpp, *inp, *pinp;
struct inoinfo **inpend;
long change;
/*
* Create a list of children for each directory.
*/
inpend = &inpsort[inplast];
do {
change = 0;
for (inpp = inpsort; inpp < inpend; inpp++) {
inp = *inpp;
if (inp->i_parent == 0)
continue;
if (statemap[inp->i_parent] == DFOUND &&
statemap[inp->i_number] == DSTATE) {
statemap[inp->i_number] = DFOUND;
change++;
}
}
} while (change > 0);
for (inpp = inpsort; inpp < inpend; inpp++) {
inp = *inpp;
if (inp->i_parent == 0 ||
inp->i_number == ROOTINO)
continue;
pinp = getinoinfo(inp->i_parent);
inp->i_parentp = pinp;
inp->i_sibling = pinp->i_child;
pinp->i_child = inp;
}
inp = getinoinfo(ROOTINO);
while (inp) {
statemap[inp->i_number] = DFOUND;
if (inp->i_child &&
statemap[inp->i_child->i_number] == DSTATE)
inp = inp->i_child;
else if (inp->i_sibling)
inp = inp->i_sibling;
else
inp = inp->i_parentp;
}
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: fsck.h,v 1.10 1995/04/12 21:24:09 mycroft Exp $ */
/* $NetBSD: fsck.h,v 1.11 1996/06/11 07:07:53 mycroft Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -154,6 +154,7 @@ struct zlncnt *zlnhead; /* head of zero link count list */
*/
struct inoinfo {
struct inoinfo *i_nexthash; /* next entry in hash chain */
struct inoinfo *i_child, *i_sibling, *i_parentp;
ino_t i_number; /* inode number of this entry */
ino_t i_parent; /* inode number of parent */
ino_t i_dotdot; /* inode number of `..' */

View File

@ -1,4 +1,4 @@
/* $NetBSD: inode.c,v 1.19 1996/05/25 09:57:36 mycroft Exp $ */
/* $NetBSD: inode.c,v 1.20 1996/06/11 07:07:54 mycroft Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)inode.c 8.5 (Berkeley) 2/8/95";
#else
static char rcsid[] = "$NetBSD: inode.c,v 1.19 1996/05/25 09:57:36 mycroft Exp $";
static char rcsid[] = "$NetBSD: inode.c,v 1.20 1996/06/11 07:07:54 mycroft Exp $";
#endif
#endif /* not lint */
@ -332,6 +332,7 @@ cacheino(dp, inumber)
inpp = &inphead[inumber % numdirs];
inp->i_nexthash = *inpp;
*inpp = inp;
inp->i_child = inp->i_sibling = inp->i_parentp = 0;
if (inumber == ROOTINO)
inp->i_parent = ROOTINO;
else

View File

@ -1,4 +1,4 @@
/* $NetBSD: pass2.c,v 1.14 1996/05/21 15:32:16 mycroft Exp $ */
/* $NetBSD: pass2.c,v 1.15 1996/06/11 07:07:56 mycroft Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)pass2.c 8.6 (Berkeley) 10/27/94";
#else
static char rcsid[] = "$NetBSD: pass2.c,v 1.14 1996/05/21 15:32:16 mycroft Exp $";
static char rcsid[] = "$NetBSD: pass2.c,v 1.15 1996/06/11 07:07:56 mycroft Exp $";
#endif
#endif /* not lint */
@ -112,7 +112,6 @@ pass2()
default:
errexit("BAD STATE %d FOR ROOT INODE", statemap[ROOTINO]);
}
statemap[ROOTINO] = DFOUND;
if (newinofmt) {
statemap[WINO] = FSTATE;
typemap[WINO] = DT_WHT;
@ -169,9 +168,6 @@ pass2()
inp = *inpp;
if (inp->i_parent == 0 || inp->i_isize == 0)
continue;
if (statemap[inp->i_parent] == DFOUND &&
statemap[inp->i_number] == DSTATE)
statemap[inp->i_number] = DFOUND;
if (inp->i_dotdot == inp->i_parent ||
inp->i_dotdot == (ino_t)-1)
continue;
@ -412,10 +408,6 @@ again:
goto again;
case DSTATE:
if (statemap[idesc->id_number] == DFOUND)
statemap[dirp->d_ino] = DFOUND;
/* fall through */
case DFOUND:
inp = getinoinfo(dirp->d_ino);
if (inp->i_parent != 0 && idesc->id_entryno > 2) {