122049Sdist /* 2*39976Smckusick * Copyright (c) 1980, 1986 The Regents of the University of California. 3*39976Smckusick * All rights reserved. 4*39976Smckusick * 5*39976Smckusick * Redistribution and use in source and binary forms are permitted 6*39976Smckusick * provided that the above copyright notice and this paragraph are 7*39976Smckusick * duplicated in all such forms and that any documentation, 8*39976Smckusick * advertising materials, and other materials related to such 9*39976Smckusick * distribution and use acknowledge that the software was developed 10*39976Smckusick * by the University of California, Berkeley. The name of the 11*39976Smckusick * University may not be used to endorse or promote products derived 12*39976Smckusick * from this software without specific prior written permission. 13*39976Smckusick * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14*39976Smckusick * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15*39976Smckusick * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1622049Sdist */ 1722049Sdist 1816263Smckusick #ifndef lint 19*39976Smckusick static char sccsid[] = "@(#)pass1b.c 5.6 (Berkeley) 02/01/90"; 20*39976Smckusick #endif /* not lint */ 2116263Smckusick 2216263Smckusick #include <sys/param.h> 2339383Smckusick #include <ufs/dinode.h> 2438337Smckusick #include <ufs/fs.h> 2516263Smckusick #include "fsck.h" 2616263Smckusick 2716263Smckusick int pass1bcheck(); 2821744Smckusick static struct dups *duphead; 2916263Smckusick 3016263Smckusick pass1b() 3116263Smckusick { 3216263Smckusick register int c, i; 3339973Smckusick register struct dinode *dp; 3416263Smckusick struct inodesc idesc; 3516263Smckusick ino_t inumber; 3616263Smckusick 3716263Smckusick bzero((char *)&idesc, sizeof(struct inodesc)); 3816263Smckusick idesc.id_type = ADDR; 3916263Smckusick idesc.id_func = pass1bcheck; 4021744Smckusick duphead = duplist; 4116263Smckusick inumber = 0; 4216263Smckusick for (c = 0; c < sblock.fs_ncg; c++) { 4316263Smckusick for (i = 0; i < sblock.fs_ipg; i++, inumber++) { 4420847Smckusick if (inumber < ROOTINO) 4520847Smckusick continue; 4616263Smckusick dp = ginode(inumber); 4716263Smckusick if (dp == NULL) 4816263Smckusick continue; 4916263Smckusick idesc.id_number = inumber; 5016263Smckusick if (statemap[inumber] != USTATE && 5116263Smckusick (ckinode(dp, &idesc) & STOP)) 5239973Smckusick return; 5316263Smckusick } 5416263Smckusick } 5516263Smckusick } 5616263Smckusick 5716263Smckusick pass1bcheck(idesc) 5816263Smckusick register struct inodesc *idesc; 5916263Smckusick { 6021744Smckusick register struct dups *dlp; 6116263Smckusick int nfrags, res = KEEPON; 6216263Smckusick daddr_t blkno = idesc->id_blkno; 6316263Smckusick 6416263Smckusick for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) { 6539973Smckusick if (chkrange(blkno, 1)) 6616263Smckusick res = SKIP; 6721744Smckusick for (dlp = duphead; dlp; dlp = dlp->next) { 6821744Smckusick if (dlp->dup == blkno) { 6939973Smckusick blkerror(idesc->id_number, "DUP", blkno); 7021744Smckusick dlp->dup = duphead->dup; 7121744Smckusick duphead->dup = blkno; 7221744Smckusick duphead = duphead->next; 7316263Smckusick } 7421744Smckusick if (dlp == muldup) 7521744Smckusick break; 7621744Smckusick } 7721744Smckusick if (muldup == 0 || duphead == muldup->next) 7821744Smckusick return (STOP); 7916263Smckusick } 8016263Smckusick return (res); 8116263Smckusick } 82