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.6 (Berkeley) 02/01/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 int pass2check(); 28 29 pass3() 30 { 31 register struct dinode *dp; 32 struct inodesc idesc; 33 ino_t inumber, orphan; 34 int loopcnt; 35 36 bzero((char *)&idesc, sizeof(struct inodesc)); 37 idesc.id_type = DATA; 38 for (inumber = ROOTINO; inumber <= lastino; inumber++) { 39 if (statemap[inumber] == DSTATE) { 40 pathp = pathname; 41 *pathp++ = '?'; 42 *pathp = '\0'; 43 idesc.id_func = findino; 44 idesc.id_name = ".."; 45 idesc.id_parent = inumber; 46 loopcnt = 0; 47 do { 48 orphan = idesc.id_parent; 49 if (orphan < ROOTINO || orphan > maxino) 50 break; 51 dp = ginode(orphan); 52 idesc.id_parent = 0; 53 idesc.id_number = orphan; 54 if ((ckinode(dp, &idesc) & FOUND) == 0) 55 break; 56 if (loopcnt >= sblock.fs_cstotal.cs_ndir) 57 break; 58 loopcnt++; 59 } while (statemap[idesc.id_parent] == DSTATE); 60 if (linkup(orphan, idesc.id_parent) == 1) { 61 idesc.id_func = pass2check; 62 idesc.id_number = lfdir; 63 descend(&idesc, orphan); 64 } 65 } 66 } 67 } 68