1: /*
2: * Copyright (c) 1980 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: */
6:
7: #ifndef lint
8: static char sccsid[] = "@(#)pass4.c 5.3 (Berkeley) 3/5/86";
9: #endif not lint
10:
11: #include <sys/param.h>
12: #include <sys/inode.h>
13: #include <sys/fs.h>
14: #include "fsck.h"
15:
16: int pass4check();
17:
18: pass4()
19: {
20: register ino_t inumber;
21: register struct zlncnt *zlnp;
22: struct inodesc idesc;
23: int n;
24:
25: bzero((char *)&idesc, sizeof(struct inodesc));
26: idesc.id_type = ADDR;
27: idesc.id_func = pass4check;
28: for (inumber = ROOTINO; inumber <= lastino; inumber++) {
29: idesc.id_number = inumber;
30: switch (statemap[inumber]) {
31:
32: case FSTATE:
33: case DFOUND:
34: n = lncntp[inumber];
35: if (n)
36: adjust(&idesc, (short)n);
37: else {
38: for (zlnp = zlnhead; zlnp; zlnp = zlnp->next)
39: if (zlnp->zlncnt == inumber) {
40: zlnp->zlncnt = zlnhead->zlncnt;
41: zlnp = zlnhead;
42: zlnhead = zlnhead->next;
43: free(zlnp);
44: clri(&idesc, "UNREF", 1);
45: break;
46: }
47: }
48: break;
49:
50: case DSTATE:
51: clri(&idesc, "UNREF", 1);
52: break;
53:
54: case DCLEAR:
55: case FCLEAR:
56: clri(&idesc, "BAD/DUP", 1);
57: break;
58:
59: case USTATE:
60: break;
61:
62: default:
63: errexit("BAD STATE %d FOR INODE I=%d",
64: statemap[inumber], inumber);
65: }
66: }
67: }
68:
69: pass4check(idesc)
70: register struct inodesc *idesc;
71: {
72: register struct dups *dlp;
73: int nfrags, res = KEEPON;
74: daddr_t blkno = idesc->id_blkno;
75:
76: for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) {
77: if (outrange(blkno, 1)) {
78: res = SKIP;
79: } else if (getbmap(blkno)) {
80: for (dlp = duplist; dlp; dlp = dlp->next) {
81: if (dlp->dup != blkno)
82: continue;
83: dlp->dup = duplist->dup;
84: dlp = duplist;
85: duplist = duplist->next;
86: free(dlp);
87: break;
88: }
89: if (dlp == 0) {
90: clrbmap(blkno);
91: n_blks--;
92: }
93: }
94: }
95: return (res);
96: }
Defined functions
pass4
defined in line
18; used 1 times
Defined variables
sccsid
defined in line
8;
never used