BSD 4_3_Tahoe release
[unix-history] / usr / src / etc / fsck / pass3.c
CommitLineData
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
1712811a 7#ifndef lint
ca67e7b4 8static char sccsid[] = "@(#)pass3.c 5.2 (Berkeley) 1/7/87";
76797561 9#endif not lint
1712811a
KM
10
11#include <sys/param.h>
12#include <sys/inode.h>
13#include <sys/fs.h>
14#include "fsck.h"
15
16int pass2check();
17
18pass3()
19{
20 register DINODE *dp;
21 struct inodesc idesc;
22 ino_t inumber, orphan;
23 int loopcnt;
24
25 bzero((char *)&idesc, sizeof(struct inodesc));
26 idesc.id_type = DATA;
27 for (inumber = ROOTINO; inumber <= lastino; inumber++) {
28 if (statemap[inumber] == DSTATE) {
29 pathp = pathname;
30 *pathp++ = '?';
31 *pathp = '\0';
32 idesc.id_func = findino;
7718c0e6 33 idesc.id_name = "..";
1712811a
KM
34 idesc.id_parent = inumber;
35 loopcnt = 0;
36 do {
37 orphan = idesc.id_parent;
39c18287 38 if (orphan < ROOTINO || orphan > imax)
1712811a 39 break;
39c18287 40 dp = ginode(orphan);
1712811a 41 idesc.id_parent = 0;
1712811a 42 idesc.id_number = orphan;
315f1422 43 if ((ckinode(dp, &idesc) & FOUND) == 0)
1712811a
KM
44 break;
45 if (loopcnt >= sblock.fs_cstotal.cs_ndir)
46 break;
47 loopcnt++;
48 } while (statemap[idesc.id_parent] == DSTATE);
49 if (linkup(orphan, idesc.id_parent) == 1) {
50 idesc.id_func = pass2check;
51 idesc.id_number = lfdir;
52 descend(&idesc, orphan);
53 }
54 }
55 }
56}