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.8 (Berkeley) 02/07/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 for (loopcnt = 0; ; loopcnt++) { 39 orphan = inp->i_number; 40 if (inp->i_parent == 0 || 41 statemap[inp->i_parent] != DSTATE || 42 loopcnt > numdirs) 43 break; 44 inp = getinoinfo(inp->i_parent); 45 } 46 (void)linkup(orphan, inp->i_dotdot); 47 inp->i_parent = inp->i_dotdot = lfdir; 48 lncntp[lfdir]--; 49 statemap[orphan] = DFOUND; 50 propagate(); 51 } 52 } 53