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.1 (Berkeley) 06/05/85"; 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 clri(&idesc, "UNREF", 1); 41 break; 42 } 43 } 44 break; 45 46 case DSTATE: 47 clri(&idesc, "UNREF", 1); 48 break; 49 50 case DCLEAR: 51 case FCLEAR: 52 clri(&idesc, "BAD/DUP", 1); 53 break; 54 } 55 } 56 } 57 58 pass4check(idesc) 59 register struct inodesc *idesc; 60 { 61 register struct dups *dlp; 62 int nfrags, res = KEEPON; 63 daddr_t blkno = idesc->id_blkno; 64 65 for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) { 66 if (outrange(blkno, 1)) { 67 res = SKIP; 68 } else if (getbmap(blkno)) { 69 for (dlp = duplist; dlp; dlp = dlp->next) { 70 if (dlp->dup != blkno) 71 continue; 72 dlp->dup = duplist->dup; 73 dlp = duplist; 74 duplist = duplist->next; 75 /* free(dlp); */ 76 break; 77 } 78 if (dlp == 0) { 79 clrbmap(blkno); 80 n_blks--; 81 } 82 } 83 } 84 return (res); 85 } 86