Commit | Line | Data |
---|---|---|
76797561 | 1 | /* |
fe32782c KM |
2 | * Copyright (c) 1980, 1986 The Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
70ab3c27 | 5 | * %sccs.include.redist.c% |
76797561 DF |
6 | */ |
7 | ||
1712811a | 8 | #ifndef lint |
558b3a30 | 9 | static char sccsid[] = "@(#)pass3.c 5.11 (Berkeley) %G%"; |
fe32782c | 10 | #endif /* not lint */ |
1712811a KM |
11 | |
12 | #include <sys/param.h> | |
558b3a30 KB |
13 | #include <ufs/ufs/dinode.h> |
14 | #include <ufs/ffs/fs.h> | |
1712811a KM |
15 | #include "fsck.h" |
16 | ||
1712811a KM |
17 | pass3() |
18 | { | |
c32e1b91 KM |
19 | register struct inoinfo **inpp, *inp; |
20 | ino_t orphan; | |
1712811a KM |
21 | int loopcnt; |
22 | ||
c32e1b91 KM |
23 | for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--) { |
24 | inp = *inpp; | |
25 | if (inp->i_number == ROOTINO || | |
26 | !(inp->i_parent == 0 || statemap[inp->i_number] == DSTATE)) | |
27 | continue; | |
3012ee67 KM |
28 | if (statemap[inp->i_number] == DCLEAR) |
29 | continue; | |
c32e1b91 KM |
30 | for (loopcnt = 0; ; loopcnt++) { |
31 | orphan = inp->i_number; | |
32 | if (inp->i_parent == 0 || | |
33 | statemap[inp->i_parent] != DSTATE || | |
34 | loopcnt > numdirs) | |
35 | break; | |
36 | inp = getinoinfo(inp->i_parent); | |
1712811a | 37 | } |
c32e1b91 KM |
38 | (void)linkup(orphan, inp->i_dotdot); |
39 | inp->i_parent = inp->i_dotdot = lfdir; | |
40 | lncntp[lfdir]--; | |
41 | statemap[orphan] = DFOUND; | |
42 | propagate(); | |
1712811a KM |
43 | } |
44 | } |