summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-10-18 17:21:52 +0000
committerMiles Bader <miles@gnu.org>1995-10-18 17:21:52 +0000
commitb6e72fc6447d33da1623ba2f7123238c27d0a114 (patch)
tree353d4020f6badd94b20c05acc546d8d1be100c56
parent2b18b710ac288b9554d6d6e336f4d736daf07d61 (diff)
(pass4): If an unlinked file can't be reconnected, offer to clear it. Once a
reconnect attempt fails, don't try again. (pass4): Use changed pinode. (pass4): Call pfix instead of printf.
-rw-r--r--ufs-fsck/pass4.c49
1 files changed, 15 insertions, 34 deletions
diff --git a/ufs-fsck/pass4.c b/ufs-fsck/pass4.c
index 7ba50baf..bd1c7541 100644
--- a/ufs-fsck/pass4.c
+++ b/ufs-fsck/pass4.c
@@ -24,6 +24,8 @@ void
pass4()
{
ino_t number;
+ /* True if any reconnect attempt failed, in which case we don't try again. */
+ int reconn_failed = 0;
for (number = ROOTINO; number < maxino; number++)
{
@@ -31,19 +33,15 @@ pass4()
{
if (linkcount[number] != linkfound[number])
{
- struct dinode dino;
- getinode (number, &dino);
- pwarn ("LINK COUNT %s",
- (DI_MODE (&dino) & IFMT) == IFDIR ? "DIR" : "FILE");
- pinode (number);
- printf (" COUNT %d SHOULD BE %d", linkcount[number],
- linkfound[number]);
- if (preen)
- printf (" (ADJUSTED)");
+ pinode (number, "LINK COUNT %d SHOULD BE %d IN",
+ linkcount[number], linkfound[number]);
if (preen || reply ("ADJUST"))
{
+ struct dinode dino;
+ getinode (number, &dino);
dino.di_nlink = linkfound[number];
write_inode (number, &dino);
+ pfix ("ADJUSTED");
}
}
}
@@ -59,48 +57,31 @@ pass4()
we want to clear it; if the size is positive, then we
want to reattach in. */
struct dinode dino;
+
+ pinode (number, "UNREF");
getinode (number, &dino);
-
- if (dino.di_size)
+ if (dino.di_size && !reconn_failed)
{
/* This can't happen for dirctories because pass 3 should
already have reset them up. */
if ((DI_MODE (&dino) & IFMT) == IFDIR)
errexit ("NO LINKS TO NONZERO DIRECTORY");
- pwarn ("UNREF FILE");
- pinode (number);
- if (preen)
- printf (" (RECONNECTED)");
if (preen || reply ("RECONNECT"))
- linkup (number, -1);
+ reconn_failed = !linkup (number, -1);
+ if (!reconn_failed)
+ pfix ("RECONNECTED");
}
- else
+ if (dino.di_size == 0 || reconn_failed)
{
- pwarn ("UNREF %s",
- (DI_MODE (&dino) & IFMT) == IFDIR ? "DIR" : "FILE");
- pinode (number);
- if (preen)
- printf (" (CLEARED)");
if (preen || reply ("CLEAR"))
{
inodestate[number] = UNALLOC;
clear_inode (number, &dino);
}
+ pfix ("CLEARED");
}
}
}
}
-
-
-
-
-
-
-
-
-
-
-
-