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