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 |
76797561 DF |
8 | static char sccsid[] = "@(#)pass1b.c 5.1 (Berkeley) %G%"; |
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 | } | |
44 | out1b: | |
45 | flush(&dfile, &inoblk); | |
46 | } | |
47 | ||
48 | pass1bcheck(idesc) | |
49 | register struct inodesc *idesc; | |
50 | { | |
62e6c152 | 51 | register struct dups *dlp; |
7fa08060 KM |
52 | int nfrags, res = KEEPON; |
53 | daddr_t blkno = idesc->id_blkno; | |
54 | ||
55 | for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) { | |
56 | if (outrange(blkno, 1)) | |
57 | res = SKIP; | |
62e6c152 KM |
58 | for (dlp = duphead; dlp; dlp = dlp->next) { |
59 | if (dlp->dup == blkno) { | |
7fa08060 | 60 | blkerr(idesc->id_number, "DUP", blkno); |
62e6c152 KM |
61 | dlp->dup = duphead->dup; |
62 | duphead->dup = blkno; | |
63 | duphead = duphead->next; | |
7fa08060 | 64 | } |
62e6c152 KM |
65 | if (dlp == muldup) |
66 | break; | |
67 | } | |
68 | if (muldup == 0 || duphead == muldup->next) | |
69 | return (STOP); | |
7fa08060 KM |
70 | } |
71 | return (res); | |
72 | } |