1 /* 2 * Copyright (c) 1980, 1986 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #ifndef lint 19 static char sccsid[] = "@(#)pass3.c 5.9 (Berkeley) 04/29/90"; 20 #endif /* not lint */ 21 22 #include <sys/param.h> 23 #include <ufs/dinode.h> 24 #include <ufs/fs.h> 25 #include "fsck.h" 26 27 pass3() 28 { 29 register struct inoinfo **inpp, *inp; 30 ino_t orphan; 31 int loopcnt; 32 33 for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--) { 34 inp = *inpp; 35 if (inp->i_number == ROOTINO || 36 !(inp->i_parent == 0 || statemap[inp->i_number] == DSTATE)) 37 continue; 38 if (statemap[inp->i_number] == DCLEAR) 39 continue; 40 for (loopcnt = 0; ; loopcnt++) { 41 orphan = inp->i_number; 42 if (inp->i_parent == 0 || 43 statemap[inp->i_parent] != DSTATE || 44 loopcnt > numdirs) 45 break; 46 inp = getinoinfo(inp->i_parent); 47 } 48 (void)linkup(orphan, inp->i_dotdot); 49 inp->i_parent = inp->i_dotdot = lfdir; 50 lncntp[lfdir]--; 51 statemap[orphan] = DFOUND; 52 propagate(); 53 } 54 } 55