10Sstevel@tonic-gate /*
2*392Sswilcox * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
30Sstevel@tonic-gate * Use is subject to license terms.
40Sstevel@tonic-gate */
50Sstevel@tonic-gate
60Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
70Sstevel@tonic-gate /* All Rights Reserved */
80Sstevel@tonic-gate
90Sstevel@tonic-gate /*
100Sstevel@tonic-gate * Copyright (c) 1980, 1986, 1990 The Regents of the University of California.
110Sstevel@tonic-gate * All rights reserved.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * Redistribution and use in source and binary forms are permitted
140Sstevel@tonic-gate * provided that: (1) source distributions retain this entire copyright
150Sstevel@tonic-gate * notice and comment, and (2) distributions including binaries display
160Sstevel@tonic-gate * the following acknowledgement: ``This product includes software
170Sstevel@tonic-gate * developed by the University of California, Berkeley and its contributors''
180Sstevel@tonic-gate * in the documentation or other materials provided with the distribution
190Sstevel@tonic-gate * and in all advertising materials mentioning features or use of this
200Sstevel@tonic-gate * software. Neither the name of the University nor the names of its
210Sstevel@tonic-gate * contributors may be used to endorse or promote products derived
220Sstevel@tonic-gate * from this software without specific prior written permission.
230Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
240Sstevel@tonic-gate * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
250Sstevel@tonic-gate * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
260Sstevel@tonic-gate */
270Sstevel@tonic-gate
280Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
290Sstevel@tonic-gate
30*392Sswilcox #include <stdio.h>
31*392Sswilcox #include <stdlib.h>
32*392Sswilcox #include <unistd.h>
330Sstevel@tonic-gate #include <sys/param.h>
340Sstevel@tonic-gate #include <sys/types.h>
350Sstevel@tonic-gate #include <sys/mntent.h>
360Sstevel@tonic-gate #include <sys/fs/ufs_fs.h>
370Sstevel@tonic-gate #include <sys/vnode.h>
380Sstevel@tonic-gate #include <sys/fs/ufs_inode.h>
390Sstevel@tonic-gate #include "fsck.h"
400Sstevel@tonic-gate
41*392Sswilcox static int pass1bcheck(struct inodesc *);
420Sstevel@tonic-gate
43*392Sswilcox void
pass1b(void)44*392Sswilcox pass1b(void)
450Sstevel@tonic-gate {
460Sstevel@tonic-gate struct dinode *dp;
470Sstevel@tonic-gate struct inodesc idesc;
48*392Sswilcox fsck_ino_t inumber;
490Sstevel@tonic-gate
50*392Sswilcox /*
51*392Sswilcox * We can get STOP failures from ckinode() that
52*392Sswilcox * are completely independent of our dup checks.
53*392Sswilcox * If that were not the case, then we could track
54*392Sswilcox * when we've seen all of the dups and short-
55*392Sswilcox * circuit our search. As it is, we need to
56*392Sswilcox * keep going, so there's no point in looking
57*392Sswilcox * at what ckinode() returns to us.
58*392Sswilcox */
59*392Sswilcox
60*392Sswilcox for (inumber = UFSROOTINO; inumber < maxino; inumber++) {
61*392Sswilcox init_inodesc(&idesc);
62*392Sswilcox idesc.id_type = ADDR;
63*392Sswilcox idesc.id_func = pass1bcheck;
64*392Sswilcox idesc.id_number = inumber;
65*392Sswilcox idesc.id_fix = DONTKNOW;
66*392Sswilcox dp = ginode(inumber);
67*392Sswilcox if (statemap[inumber] != USTATE)
68*392Sswilcox (void) ckinode(dp, &idesc, CKI_TRAVERSE);
690Sstevel@tonic-gate }
700Sstevel@tonic-gate }
710Sstevel@tonic-gate
72*392Sswilcox static int
pass1bcheck(struct inodesc * idesc)73*392Sswilcox pass1bcheck(struct inodesc *idesc)
740Sstevel@tonic-gate {
750Sstevel@tonic-gate int res = KEEPON;
76*392Sswilcox int nfrags;
77*392Sswilcox daddr32_t lbn;
780Sstevel@tonic-gate daddr32_t blkno = idesc->id_blkno;
790Sstevel@tonic-gate
80*392Sswilcox for (nfrags = 0; nfrags < idesc->id_numfrags; blkno++, nfrags++) {
81*392Sswilcox if (chkrange(blkno, 1)) {
820Sstevel@tonic-gate res = SKIP;
83*392Sswilcox } else {
84*392Sswilcox /*
85*392Sswilcox * Note that we only report additional dup claimants
86*392Sswilcox * in this pass, as the first claimant found was
87*392Sswilcox * listed during pass 1.
88*392Sswilcox */
89*392Sswilcox lbn = idesc->id_lbn * sblock.fs_frag + nfrags;
90*392Sswilcox if (find_dup_ref(blkno, idesc->id_number, lbn, DB_INCR))
91*392Sswilcox blkerror(idesc->id_number, "DUP", blkno, lbn);
920Sstevel@tonic-gate }
930Sstevel@tonic-gate }
940Sstevel@tonic-gate return (res);
950Sstevel@tonic-gate }
96