new copyright notice
[unix-history] / usr / src / sbin / fsck / pass3.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[] = "@(#)pass3.c 5.10 (Berkeley) %G%";
10#endif /* not lint */
11
12#include <sys/param.h>
13#include <ufs/dinode.h>
14#include <ufs/fs.h>
15#include "fsck.h"
16
17pass3()
18{
19 register struct inoinfo **inpp, *inp;
20 ino_t orphan;
21 int loopcnt;
22
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;
28 if (statemap[inp->i_number] == DCLEAR)
29 continue;
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);
37 }
38 (void)linkup(orphan, inp->i_dotdot);
39 inp->i_parent = inp->i_dotdot = lfdir;
40 lncntp[lfdir]--;
41 statemap[orphan] = DFOUND;
42 propagate();
43 }
44}