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