dynamically allocate zero link count table
[unix-history] / usr / src / sbin / fsck / pass3.c
CommitLineData
1712811a 1#ifndef lint
f0ed004a 2static char version[] = "@(#)pass3.c 3.4 (Berkeley) %G%";
1712811a
KM
3#endif
4
5#include <sys/param.h>
6#include <sys/inode.h>
7#include <sys/fs.h>
8#include "fsck.h"
9
10int pass2check();
11
12pass3()
13{
14 register DINODE *dp;
15 struct inodesc idesc;
16 ino_t inumber, orphan;
17 int loopcnt;
18
19 bzero((char *)&idesc, sizeof(struct inodesc));
20 idesc.id_type = DATA;
21 for (inumber = ROOTINO; inumber <= lastino; inumber++) {
22 if (statemap[inumber] == DSTATE) {
23 pathp = pathname;
24 *pathp++ = '?';
25 *pathp = '\0';
26 idesc.id_func = findino;
7718c0e6 27 idesc.id_name = "..";
1712811a
KM
28 idesc.id_parent = inumber;
29 loopcnt = 0;
30 do {
31 orphan = idesc.id_parent;
39c18287 32 if (orphan < ROOTINO || orphan > imax)
1712811a 33 break;
39c18287 34 dp = ginode(orphan);
1712811a 35 idesc.id_parent = 0;
1712811a
KM
36 idesc.id_number = orphan;
37 (void)ckinode(dp, &idesc);
38 if (idesc.id_parent == 0)
39 break;
40 if (loopcnt >= sblock.fs_cstotal.cs_ndir)
41 break;
42 loopcnt++;
43 } while (statemap[idesc.id_parent] == DSTATE);
44 if (linkup(orphan, idesc.id_parent) == 1) {
45 idesc.id_func = pass2check;
46 idesc.id_number = lfdir;
47 descend(&idesc, orphan);
48 }
49 }
50 }
51}