projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dynamically allocate zero link count table
[unix-history]
/
usr
/
src
/
sbin
/
fsck
/
pass1.c
diff --git
a/usr/src/sbin/fsck/pass1.c
b/usr/src/sbin/fsck/pass1.c
index
b34763f
..
c7f53c0
100644
(file)
--- a/
usr/src/sbin/fsck/pass1.c
+++ b/
usr/src/sbin/fsck/pass1.c
@@
-1,5
+1,5
@@
#ifndef lint
#ifndef lint
-static char version[] = "@(#)pass1.c 3.
4
(Berkeley) %G%";
+static char version[] = "@(#)pass1.c 3.
7
(Berkeley) %G%";
#endif
#include <sys/param.h>
#endif
#include <sys/param.h>
@@
-15,6
+15,7
@@
pass1()
{
register int c, i, j;
register DINODE *dp;
{
register int c, i, j;
register DINODE *dp;
+ struct zlncnt *zlnp;
int ndb, partial, cgd;
struct inodesc idesc;
ino_t inumber;
int ndb, partial, cgd;
struct inodesc idesc;
ino_t inumber;
@@
-96,28
+97,30
@@
pass1()
n_files++;
lncntp[inumber] = dp->di_nlink;
if (dp->di_nlink <= 0) {
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("");
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;
}
}
statemap[inumber] = DIRCT(dp) ? DSTATE : FSTATE;
badblk = dupblk = 0; maxblk = 0;
idesc.id_number = inumber;
- idesc.id_filesize = 0;
(void)ckinode(dp, &idesc);
(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)",
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;
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;
inodirty();
}
continue;
@@
-134,10
+137,11
@@
pass1()
pass1check(idesc)
register struct inodesc *idesc;
{
pass1check(idesc)
register struct inodesc *idesc;
{
- register daddr_t *dlp;
int res = KEEPON;
int anyout, nfrags;
daddr_t blkno = idesc->id_blkno;
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);
if ((anyout = outrange(blkno, idesc->id_numfrags)) != 0) {
blkerr(idesc->id_number, "BAD", blkno);
@@
-168,23
+172,31
@@
pass1check(idesc)
errexit("");
return (STOP);
}
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);
}
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);
}
}
return (res);
}