summaryrefslogtreecommitdiff
path: root/ufs-fsck/pass2.c
diff options
context:
space:
mode:
Diffstat (limited to 'ufs-fsck/pass2.c')
-rw-r--r--ufs-fsck/pass2.c64
1 files changed, 31 insertions, 33 deletions
diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c
index ee12d33b..69331946 100644
--- a/ufs-fsck/pass2.c
+++ b/ufs-fsck/pass2.c
@@ -297,75 +297,73 @@ pass2 ()
for (nd = 0; nd < dirarrayused; nd++)
{
dnp = dirsorted[nd];
- if (dnp->i_isize == 0)
- continue;
/* Root is considered to be its own parent even though it isn't
listed. */
if (dnp->i_number == ROOTINO && !dnp->i_parent)
dnp->i_parent = ROOTINO;
- /* Check `..' to make sure it exists and is correct */
- if (dnp->i_parent && dnp->i_dotdot == 0)
+ /* Check `.' to make sure it exists and is correct */
+ if (dnp->i_dot == 0)
{
- dnp->i_dotdot = dnp->i_parent;
- pinode (0, dnp->i_number, "MISSING `..' IN");
+ dnp->i_dot = dnp->i_number;
+ pinode (0, dnp->i_number, "MISSING `.' IN");
if ((preen || reply ("FIX"))
- && makeentry (dnp->i_number, dnp->i_parent, ".."))
+ && makeentry (dnp->i_number, dnp->i_number, "."))
{
- linkfound[dnp->i_parent]++;
+ linkfound[dnp->i_number]++;
pfix ("FIXED");
}
else
pfail (0);
}
- else if (dnp->i_parent && dnp->i_dotdot != dnp->i_parent)
+ else if (dnp->i_dot != dnp->i_number)
{
- pinode (0, dnp->i_number, "BAD INODE NUMBER FOR `..' IN");
+ pinode (0, dnp->i_number, "BAD INODE NUMBER FOR `.' IN");
if (preen || reply ("FIX"))
{
- ino_t parent = dnp->i_parent, old_dotdot = dnp->i_dotdot;
- dnp->i_dotdot = parent;
- if (changeino (dnp->i_number, "..", parent))
- /* Adjust what the parent's link count should be; the actual
- count will be corrected in an later pass. */
+ ino_t old_dot = dnp->i_dot;
+ dnp->i_dot = dnp->i_number;
+ if (changeino (dnp->i_number, ".", dnp->i_number))
{
- linkfound[parent]++;
- if (inodestate[old_dotdot] != UNALLOC)
- linkfound[old_dotdot]--;
+ linkfound[dnp->i_number]++;
+ if (inodestate[old_dot] != UNALLOC)
+ linkfound[old_dot]--;
pfix ("FIXED");
}
else
pfail (0);
}
}
-
- /* Check `.' to make sure it exists and is correct */
- if (dnp->i_dot == 0)
+
+ /* Check `..' to make sure it exists and is correct */
+ if (dnp->i_parent && dnp->i_dotdot == 0)
{
- dnp->i_dot = dnp->i_number;
- pinode (0, dnp->i_number, "MISSING `.' IN");
+ dnp->i_dotdot = dnp->i_parent;
+ pinode (0, dnp->i_number, "MISSING `..' IN");
if ((preen || reply ("FIX"))
- && makeentry (dnp->i_number, dnp->i_number, "."))
+ && makeentry (dnp->i_number, dnp->i_parent, ".."))
{
- linkfound[dnp->i_number]++;
+ linkfound[dnp->i_parent]++;
pfix ("FIXED");
}
else
pfail (0);
}
- else if (dnp->i_dot != dnp->i_number)
+ else if (dnp->i_parent && dnp->i_dotdot != dnp->i_parent)
{
- pinode (0, dnp->i_number, "BAD INODE NUMBER FOR `.' IN");
+ pinode (0, dnp->i_number, "BAD INODE NUMBER FOR `..' IN");
if (preen || reply ("FIX"))
{
- ino_t old_dot = dnp->i_dot;
- dnp->i_dot = dnp->i_number;
- if (changeino (dnp->i_number, ".", dnp->i_number))
+ ino_t parent = dnp->i_parent, old_dotdot = dnp->i_dotdot;
+ dnp->i_dotdot = parent;
+ if (changeino (dnp->i_number, "..", parent))
+ /* Adjust what the parent's link count should be; the actual
+ count will be corrected in an later pass. */
{
- linkfound[dnp->i_number]++;
- if (inodestate[old_dot] != UNALLOC)
- linkfound[old_dot]--;
+ linkfound[parent]++;
+ if (inodestate[old_dotdot] != UNALLOC)
+ linkfound[old_dotdot]--;
pfix ("FIXED");
}
else