summaryrefslogtreecommitdiff
path: root/ufs-fsck/pass2.c
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1994-10-25 15:50:51 +0000
committerMichael I. Bushnell <mib@gnu.org>1994-10-25 15:50:51 +0000
commit3b8cfbbf7a39317399b6afd14c5b502d287e27a5 (patch)
tree66738dcfdf95b9eb600766542508ab95865e8dd8 /ufs-fsck/pass2.c
parent7e8473ac2ca0959b70383ca00860988edde0274d (diff)
Formerly pass2.c.~10~
Diffstat (limited to 'ufs-fsck/pass2.c')
-rw-r--r--ufs-fsck/pass2.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c
index a04b475e..e300501a 100644
--- a/ufs-fsck/pass2.c
+++ b/ufs-fsck/pass2.c
@@ -163,14 +163,36 @@ pass2 ()
/* Account for the inode in the linkfound map */
if (inodestate[dp->d_ino] != UNALLOC)
linkfound[dp->d_ino]++;
-
- /* If this is `.' or `..' then note the value for
- later examination. */
- if (dp->d_namlen == 1 && dp->d_name[0] == '.')
- dnp->i_dot = dp->d_ino;
- if (dp->d_namlen == 2
- && dp->d_name[0] == '.' && dp->d_name[1] == '.')
- dnp->i_dotdot = dp->d_ino;
+
+ if (inodestate[dp->d_ino] == DIRECTORY
+ || inodestate[dp->d_ino] == BADDIR)
+ {
+ if (dp->d_namlen == 1 && dp->d_name[0] == '.')
+ dnp->i_dot = dp->d_ino;
+ else if (dp->d_namlen == 2
+ && dp->d_name[0] == '.' && dp->d_name[1] == '.')
+ dnp->i_dotdot = dp->d_ino;
+ else
+ {
+ struct dirinfo *targetdir;
+ targetdir = lookup_directory (dp->d_ino);
+ if (targetdir->i_parent)
+ {
+ printf ("EXTRANEOUS LINK %s TO DIR I=%ld", dp->d_name,
+ dp->d_ino);
+ pwarn ("FOUND IN DIR I=%d", dnp->i_number);
+ if (preen || reply ("REMOVE"))
+ {
+ if (preen)
+ printf (" (REMOVED)");
+ dp->d_ino = 0;
+ mod = 1;
+ }
+ }
+ else
+ targetdir->i_parent = dnp->i_number;
+ }
+ }
}
return mod;
}