1 /*
2 * Copyright (c) 1980, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8 #ifndef lint
9 static char sccsid[] = "@(#)pass1b.c 8.4 (Berkeley) 04/28/95";
10 #endif /* not lint */
11
12 #include <sys/param.h>
13 #include <sys/time.h>
14
15 #include <ufs/ufs/dinode.h>
16 #include <ufs/ffs/fs.h>
17
18 #include <string.h>
19
20 #include "fsck.h"
21
22 static struct dups *duphead;
23 static int pass1bcheck __P((struct inodesc *));
24
25 void
pass1b()26 pass1b()
27 {
28 register int c, i;
29 register struct dinode *dp;
30 struct inodesc idesc;
31 ino_t inumber;
32
33 memset(&idesc, 0, sizeof(struct inodesc));
34 idesc.id_type = ADDR;
35 idesc.id_func = pass1bcheck;
36 duphead = duplist;
37 inumber = 0;
38 for (c = 0; c < sblock.fs_ncg; c++) {
39 for (i = 0; i < sblock.fs_ipg; i++, inumber++) {
40 if (inumber < ROOTINO)
41 continue;
42 dp = ginode(inumber);
43 if (dp == NULL)
44 continue;
45 idesc.id_number = inumber;
46 if (statemap[inumber] != USTATE &&
47 (ckinode(dp, &idesc) & STOP))
48 return;
49 }
50 }
51 }
52
53 static int
pass1bcheck(idesc)54 pass1bcheck(idesc)
55 register struct inodesc *idesc;
56 {
57 register struct dups *dlp;
58 int nfrags, res = KEEPON;
59 ufs_daddr_t blkno = idesc->id_blkno;
60
61 for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) {
62 if (chkrange(blkno, 1))
63 res = SKIP;
64 for (dlp = duphead; dlp; dlp = dlp->next) {
65 if (dlp->dup == blkno) {
66 blkerror(idesc->id_number, "DUP", blkno);
67 dlp->dup = duphead->dup;
68 duphead->dup = blkno;
69 duphead = duphead->next;
70 }
71 if (dlp == muldup)
72 break;
73 }
74 if (muldup == 0 || duphead == muldup->next)
75 return (STOP);
76 }
77 return (res);
78 }
79