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