pass3.c revision 1558
11558Srgrimes/* 21558Srgrimes * Copyright (c) 1980, 1986, 1993 31558Srgrimes * The Regents of the University of California. All rights reserved. 41558Srgrimes * 51558Srgrimes * Redistribution and use in source and binary forms, with or without 61558Srgrimes * modification, are permitted provided that the following conditions 71558Srgrimes * are met: 81558Srgrimes * 1. Redistributions of source code must retain the above copyright 91558Srgrimes * notice, this list of conditions and the following disclaimer. 101558Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111558Srgrimes * notice, this list of conditions and the following disclaimer in the 121558Srgrimes * documentation and/or other materials provided with the distribution. 131558Srgrimes * 3. All advertising materials mentioning features or use of this software 141558Srgrimes * must display the following acknowledgement: 151558Srgrimes * This product includes software developed by the University of 161558Srgrimes * California, Berkeley and its contributors. 171558Srgrimes * 4. Neither the name of the University nor the names of its contributors 181558Srgrimes * may be used to endorse or promote products derived from this software 191558Srgrimes * without specific prior written permission. 201558Srgrimes * 211558Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221558Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231558Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241558Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251558Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261558Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271558Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281558Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291558Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301558Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311558Srgrimes * SUCH DAMAGE. 321558Srgrimes */ 331558Srgrimes 341558Srgrimes#ifndef lint 351558Srgrimesstatic char sccsid[] = "@(#)pass3.c 8.1 (Berkeley) 6/5/93"; 361558Srgrimes#endif /* not lint */ 371558Srgrimes 381558Srgrimes#include <sys/param.h> 391558Srgrimes#include <sys/time.h> 401558Srgrimes#include <ufs/ufs/dinode.h> 411558Srgrimes#include <ufs/ffs/fs.h> 421558Srgrimes#include "fsck.h" 431558Srgrimes 441558Srgrimespass3() 451558Srgrimes{ 461558Srgrimes register struct inoinfo **inpp, *inp; 471558Srgrimes ino_t orphan; 481558Srgrimes int loopcnt; 491558Srgrimes 501558Srgrimes for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--) { 511558Srgrimes inp = *inpp; 521558Srgrimes if (inp->i_number == ROOTINO || 531558Srgrimes !(inp->i_parent == 0 || statemap[inp->i_number] == DSTATE)) 541558Srgrimes continue; 551558Srgrimes if (statemap[inp->i_number] == DCLEAR) 561558Srgrimes continue; 571558Srgrimes for (loopcnt = 0; ; loopcnt++) { 581558Srgrimes orphan = inp->i_number; 591558Srgrimes if (inp->i_parent == 0 || 601558Srgrimes statemap[inp->i_parent] != DSTATE || 611558Srgrimes loopcnt > numdirs) 621558Srgrimes break; 631558Srgrimes inp = getinoinfo(inp->i_parent); 641558Srgrimes } 651558Srgrimes (void)linkup(orphan, inp->i_dotdot); 661558Srgrimes inp->i_parent = inp->i_dotdot = lfdir; 671558Srgrimes lncntp[lfdir]--; 681558Srgrimes statemap[orphan] = DFOUND; 691558Srgrimes propagate(); 701558Srgrimes } 711558Srgrimes} 72