X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/993a756cd96c42bf6ffd5a8a16c3011e511dc99f..ea4448dc95742ed59f71d541537601d7c7d21351:/usr/src/sbin/fsck/pass1.c diff --git a/usr/src/sbin/fsck/pass1.c b/usr/src/sbin/fsck/pass1.c index 0260336491..c7ef65523d 100644 --- a/usr/src/sbin/fsck/pass1.c +++ b/usr/src/sbin/fsck/pass1.c @@ -1,6 +1,12 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + #ifndef lint -static char version[] = "@(#)pass1.c 3.3 (Berkeley) %G%"; -#endif +static char sccsid[] = "@(#)pass1.c 5.1 (Berkeley) %G%"; +#endif not lint #include #include @@ -15,6 +21,7 @@ pass1() { register int c, i, j; register DINODE *dp; + struct zlncnt *zlnp; int ndb, partial, cgd; struct inodesc idesc; ino_t inumber; @@ -44,8 +51,7 @@ pass1() for (i = 0; i < sblock.fs_ipg; i++, inumber++) { if (inumber < ROOTINO) continue; - if ((dp = ginode(inumber)) == NULL) - continue; + dp = ginode(inumber); if (!ALLOC(dp)) { if (bcmp((char *)dp->di_db, (char *)zino.di_db, NDADDR * sizeof(daddr_t)) || @@ -97,28 +103,30 @@ pass1() n_files++; lncntp[inumber] = dp->di_nlink; if (dp->di_nlink <= 0) { - if (badlnp < &badlncnt[MAXLNCNT]) - *badlnp++ = inumber; - else { + zlnp = (struct zlncnt *)malloc(sizeof *zlnp); + if (zlnp == NULL) { pfatal("LINK COUNT TABLE OVERFLOW"); if (reply("CONTINUE") == 0) errexit(""); + } else { + zlnp->zlncnt = inumber; + zlnp->next = zlnhead; + zlnhead = zlnp; } } statemap[inumber] = DIRCT(dp) ? DSTATE : FSTATE; badblk = dupblk = 0; maxblk = 0; idesc.id_number = inumber; - idesc.id_filesize = 0; (void)ckinode(dp, &idesc); - idesc.id_filesize *= btodb(sblock.fs_fsize); - if (dp->di_blocks != idesc.id_filesize) { + idesc.id_entryno *= btodb(sblock.fs_fsize); + if (dp->di_blocks != idesc.id_entryno) { pwarn("INCORRECT BLOCK COUNT I=%u (%ld should be %ld)", - inumber, dp->di_blocks, idesc.id_filesize); + inumber, dp->di_blocks, idesc.id_entryno); if (preen) printf(" (CORRECTED)\n"); else if (reply("CORRECT") == 0) continue; - dp->di_blocks = idesc.id_filesize; + dp->di_blocks = idesc.id_entryno; inodirty(); } continue; @@ -135,10 +143,11 @@ pass1() pass1check(idesc) register struct inodesc *idesc; { - register daddr_t *dlp; int res = KEEPON; int anyout, nfrags; daddr_t blkno = idesc->id_blkno; + register struct dups *dlp; + struct dups *new; if ((anyout = outrange(blkno, idesc->id_numfrags)) != 0) { blkerr(idesc->id_number, "BAD", blkno); @@ -169,23 +178,31 @@ pass1check(idesc) errexit(""); return (STOP); } - if (enddup >= &duplist[DUPTBLSIZE]) { + new = (struct dups *)malloc(sizeof(struct dups)); + if (new == NULL) { pfatal("DUP TABLE OVERFLOW."); if (reply("CONTINUE") == 0) errexit(""); return (STOP); } - for (dlp = duplist; dlp < muldup; dlp++) - if (*dlp == blkno) { - *enddup++ = blkno; - break; - } - if (dlp >= muldup) { - *enddup++ = *muldup; - *muldup++ = blkno; + new->dup = blkno; + if (muldup == 0) { + duplist = muldup = new; + new->next = 0; + } else { + new->next = muldup->next; + muldup->next = new; } + for (dlp = duplist; dlp != muldup; dlp = dlp->next) + if (dlp->dup == blkno) + break; + if (dlp == muldup && dlp->dup != blkno) + muldup = new; } - idesc->id_filesize++; + /* + * count the number of blocks found in id_entryno + */ + idesc->id_entryno++; } return (res); }