Commit | Line | Data |
---|---|---|
76797561 DF |
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 | ||
7fa08060 | 7 | #ifndef lint |
870c9581 | 8 | static char sccsid[] = "@(#)pass1b.c 5.2 (Berkeley) %G%"; |
76797561 | 9 | #endif not lint |
7fa08060 KM |
10 | |
11 | #include <sys/param.h> | |
12 | #include <sys/inode.h> | |
13 | #include <sys/fs.h> | |
14 | #include "fsck.h" | |
15 | ||
16 | int pass1bcheck(); | |
62e6c152 | 17 | static struct dups *duphead; |
7fa08060 KM |
18 | |
19 | pass1b() | |
20 | { | |
21 | register int c, i; | |
22 | register DINODE *dp; | |
23 | struct inodesc idesc; | |
24 | ino_t inumber; | |
25 | ||
26 | bzero((char *)&idesc, sizeof(struct inodesc)); | |
27 | idesc.id_type = ADDR; | |
28 | idesc.id_func = pass1bcheck; | |
62e6c152 | 29 | duphead = duplist; |
7fa08060 KM |
30 | inumber = 0; |
31 | for (c = 0; c < sblock.fs_ncg; c++) { | |
32 | for (i = 0; i < sblock.fs_ipg; i++, inumber++) { | |
a50c3bff KM |
33 | if (inumber < ROOTINO) |
34 | continue; | |
7fa08060 KM |
35 | dp = ginode(inumber); |
36 | if (dp == NULL) | |
37 | continue; | |
38 | idesc.id_number = inumber; | |
39 | if (statemap[inumber] != USTATE && | |
40 | (ckinode(dp, &idesc) & STOP)) | |
41 | goto out1b; | |
42 | } | |
43 | } | |
870c9581 | 44 | out1b:; |
7fa08060 KM |
45 | } |
46 | ||
47 | pass1bcheck(idesc) | |
48 | register struct inodesc *idesc; | |
49 | { | |
62e6c152 | 50 | register struct dups *dlp; |
7fa08060 KM |
51 | int nfrags, res = KEEPON; |
52 | daddr_t blkno = idesc->id_blkno; | |
53 | ||
54 | for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) { | |
55 | if (outrange(blkno, 1)) | |
56 | res = SKIP; | |
62e6c152 KM |
57 | for (dlp = duphead; dlp; dlp = dlp->next) { |
58 | if (dlp->dup == blkno) { | |
7fa08060 | 59 | blkerr(idesc->id_number, "DUP", blkno); |
62e6c152 KM |
60 | dlp->dup = duphead->dup; |
61 | duphead->dup = blkno; | |
62 | duphead = duphead->next; | |
7fa08060 | 63 | } |
62e6c152 KM |
64 | if (dlp == muldup) |
65 | break; | |
66 | } | |
67 | if (muldup == 0 || duphead == muldup->next) | |
68 | return (STOP); | |
7fa08060 KM |
69 | } |
70 | return (res); | |
71 | } |