1 /* 2 * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5 6 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 7 /* All Rights Reserved */ 8 9 /* 10 * Copyright (c) 1980, 1986, 1990 The Regents of the University of California. 11 * All rights reserved. 12 * 13 * Redistribution and use in source and binary forms are permitted 14 * provided that: (1) source distributions retain this entire copyright 15 * notice and comment, and (2) distributions including binaries display 16 * the following acknowledgement: ``This product includes software 17 * developed by the University of California, Berkeley and its contributors'' 18 * in the documentation or other materials provided with the distribution 19 * and in all advertising materials mentioning features or use of this 20 * software. Neither the name of the University nor the names of its 21 * contributors may be used to endorse or promote products derived 22 * from this software without specific prior written permission. 23 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 24 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26 */ 27 28 #pragma ident "%Z%%M% %I% %E% SMI" 29 30 #include <sys/param.h> 31 #include <sys/types.h> 32 #include <sys/mntent.h> 33 34 #define bcopy(f, t, n) memcpy(t, f, n) 35 #define bzero(s, n) memset(s, 0, n) 36 #define bcmp(s, d, n) memcmp(s, d, n) 37 38 #define index(s, r) strchr(s, r) 39 #define rindex(s, r) strrchr(s, r) 40 41 #include <sys/fs/ufs_fs.h> 42 #include <sys/vnode.h> 43 #include <sys/fs/ufs_inode.h> 44 #include "fsck.h" 45 46 int pass1bcheck(); 47 static struct dups *duphead; 48 49 pass1b() 50 { 51 int c, i; 52 struct dinode *dp; 53 struct inodesc idesc; 54 ino_t inumber; 55 56 bzero((char *)&idesc, sizeof (struct inodesc)); 57 idesc.id_type = ADDR; 58 idesc.id_func = pass1bcheck; 59 duphead = duplist; 60 inumber = 0; 61 for (c = 0; c < sblock.fs_ncg; c++) { 62 for (i = 0; i < sblock.fs_ipg; i++, inumber++) { 63 if (inumber < UFSROOTINO) 64 continue; 65 dp = ginode(inumber); 66 if (dp == NULL) 67 continue; 68 idesc.id_number = inumber; 69 idesc.id_fix = DONTKNOW; 70 if (statemap[inumber] != USTATE && 71 (ckinode(dp, &idesc) & STOP)) 72 return; 73 } 74 } 75 } 76 77 pass1bcheck(idesc) 78 struct inodesc *idesc; 79 { 80 struct dups *dlp; 81 int res = KEEPON; 82 int nfrags; 83 daddr32_t blkno = idesc->id_blkno; 84 85 for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) { 86 if (chkrange(blkno, 1)) 87 res = SKIP; 88 for (dlp = duphead; dlp; dlp = dlp->next) { 89 if (dlp->dup == blkno) { 90 blkerror(idesc->id_number, "DUP", blkno); 91 dlp->dup = duphead->dup; 92 duphead->dup = blkno; 93 duphead = duphead->next; 94 } 95 if (dlp == muldup) 96 break; 97 } 98 if (muldup == 0 || duphead == muldup->next) 99 return (STOP); 100 } 101 return (res); 102 } 103