summaryrefslogtreecommitdiff
path: root/ufs-fsck
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1996-07-01 19:22:04 +0000
committerMichael I. Bushnell <mib@gnu.org>1996-07-01 19:22:04 +0000
commitbea8b10a8f2d4e5e9cabb67685b34375c62bc8bb (patch)
tree0e1d65c866b005af83b2ab2f48251a5a482d0d36 /ufs-fsck
parent15ea5bc172ffd076ab8fa2e561a1fd688553e07e (diff)
(pass2): Don't skip empty directories in `.' and `..' correctness
check; we don't clear them the way BSD does, so we want `.' and `..' to get created for us. Also handle `.' before `..' so that they get created in the usual order for empty directories.
Diffstat (limited to 'ufs-fsck')
-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