From 1a15cb8ff36fe1f23d927e43b5653ab68a1bfa7f Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 18 Jul 1996 19:11:03 +0000 Subject: *** empty log message *** --- ufs-fsck/pass2.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'ufs-fsck/pass2.c') diff --git a/ufs-fsck/pass2.c b/ufs-fsck/pass2.c index 69331946..db63abd7 100644 --- a/ufs-fsck/pass2.c +++ b/ufs-fsck/pass2.c @@ -60,6 +60,30 @@ pass2 () if (dp->d_reclen == 0 || dp->d_reclen + (void *)dp - buf > DIRBLKSIZ) { + /* Perhaps the entire dir block is zero. UFS does that + when extending directories. So allow preening + to safely patch up all-null dir blocks. */ + if (dp == buf) + { + char *bp; + for (bp = (char *)buf; bp < (char *)buf + DIRBLKSIZ; bp++) + if (*bp) + goto reclen_problem; + + problem (0, "NULL BLOCK IN DIRECTORY"); + if (preen || reply ("PATCH")) + { + /* Mark this entry free, and return. */ + dp->d_ino = 0; + dp->d_reclen = DIRBLKSIZ; + pfix ("PATCHED"); + return 1; + } + else + return mod; + } + + reclen_problem: problem (1, "BAD RECLEN IN DIRECTORY"); if (reply ("SALVAGE")) { -- cgit v1.2.3