Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/fsck_ffs Abstract the code to attach a directory to its...
details: https://anonhg.NetBSD.org/src/rev/14ae3c6b6c8b
branches: trunk
changeset: 501999:14ae3c6b6c8b
user: mycroft <mycroft%NetBSD.org@localhost>
date: Wed Jan 10 08:22:20 2001 +0000
description:
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.
diffstat:
sbin/fsck_ffs/dir.c | 32 ++++++++++++++++++++++++--------
sbin/fsck_ffs/pass3.c | 12 +++---------
2 files changed, 27 insertions(+), 17 deletions(-)
diffs (145 lines):
diff -r 6f7ebb02518d -r 14ae3c6b6c8b sbin/fsck_ffs/dir.c
--- a/sbin/fsck_ffs/dir.c Wed Jan 10 08:10:45 2001 +0000
+++ b/sbin/fsck_ffs/dir.c Wed Jan 10 08:22:20 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.29 2001/01/09 05:51:14 mycroft Exp $ */
+/* $NetBSD: dir.c,v 1.30 2001/01/10 08:22:20 mycroft Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)dir.c 8.8 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: dir.c,v 1.29 2001/01/09 05:51:14 mycroft Exp $");
+__RCSID("$NetBSD: dir.c,v 1.30 2001/01/10 08:22:20 mycroft Exp $");
#endif
#endif /* not lint */
@@ -79,6 +79,7 @@
static struct bufarea *getdirblk __P((daddr_t, long));
static int lftempname __P((char *, ino_t));
static int mkentry __P((struct inodesc *));
+void reparent __P((ino_t, ino_t));
/*
* Propagate connected state through the tree.
@@ -118,6 +119,21 @@
}
}
+void
+reparent(inumber, parent)
+ ino_t inumber, parent;
+{
+ struct inoinfo *inp, *pinp;
+
+ inp = getinoinfo(inumber);
+ inp->i_parent = inp->i_dotdot = parent;
+ pinp = getinoinfo(parent);
+ inp->i_parentp = pinp;
+ inp->i_sibling = pinp->i_child;
+ pinp->i_child = inp;
+ propagate(lfdir);
+}
+
/*
* Scan each entry in a directory block.
*/
@@ -501,11 +517,11 @@
printf("\n");
}
}
+ reparent(lfdir, ROOTINO);
}
}
if (lfdir == 0) {
- pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY");
- printf("\n\n");
+ pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY\n\n");
markclean = 0;
return (0);
}
@@ -518,7 +534,8 @@
return (0);
}
oldlfdir = lfdir;
- if ((lfdir = allocdir(ROOTINO, (ino_t)0, lfmode)) == 0) {
+ lfdir = allocdir(ROOTINO, (ino_t)0, lfmode);
+ if (lfdir == 0) {
pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY\n\n");
markclean = 0;
return (0);
@@ -529,6 +546,7 @@
return (0);
}
inodirty();
+ reparent(lfdir, ROOTINO);
idesc.id_type = ADDR;
idesc.id_func = pass4check;
idesc.id_number = oldlfdir;
@@ -557,6 +575,7 @@
dp->di_nlink = iswap16(iswap16(dp->di_nlink) + 1);
inodirty();
lncntp[lfdir]++;
+ reparent(orphan, lfdir);
pwarn("DIR I=%u CONNECTED. ", orphan);
if (parentdir != (ino_t)-1)
printf("PARENT WAS I=%u\n", parentdir);
@@ -690,7 +709,6 @@
ino_t parent, request;
int mode;
{
- struct inoinfo *inp;
ino_t ino;
char *cp;
struct dinode *dp;
@@ -735,8 +753,6 @@
return (0);
}
cacheino(dp, ino);
- inp = getinoinfo(ino);
- inp->i_parent = inp->i_dotdot = parent;
statemap[ino] = statemap[parent];
if (statemap[ino] == DSTATE) {
lncntp[ino] = iswap16(dp->di_nlink);
diff -r 6f7ebb02518d -r 14ae3c6b6c8b sbin/fsck_ffs/pass3.c
--- a/sbin/fsck_ffs/pass3.c Wed Jan 10 08:10:45 2001 +0000
+++ b/sbin/fsck_ffs/pass3.c Wed Jan 10 08:22:20 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass3.c,v 1.11 2001/01/09 05:51:14 mycroft Exp $ */
+/* $NetBSD: pass3.c,v 1.12 2001/01/10 08:22:20 mycroft Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)pass3.c 8.2 (Berkeley) 4/27/95";
#else
-__RCSID("$NetBSD: pass3.c,v 1.11 2001/01/09 05:51:14 mycroft Exp $");
+__RCSID("$NetBSD: pass3.c,v 1.12 2001/01/10 08:22:20 mycroft Exp $");
#endif
#endif /* not lint */
@@ -54,7 +54,7 @@
void
pass3()
{
- struct inoinfo **inpp, *inp, *pinp;
+ struct inoinfo **inpp, *inp;
ino_t orphan;
int loopcnt;
@@ -74,12 +74,6 @@
inp = getinoinfo(inp->i_parent);
}
(void)linkup(orphan, inp->i_dotdot);
- inp->i_parent = inp->i_dotdot = lfdir;
lncntp[lfdir]--;
- pinp = getinoinfo(lfdir);
- inp->i_parentp = pinp;
- inp->i_sibling = pinp->i_child;
- pinp->i_child = inp;
- propagate(orphan);
}
}
Home |
Main Index |
Thread Index |
Old Index