Remove DUX/OSF code
[openafs.git] / src / vfsck / pass1b.c
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 #include <afsconfig.h>
19 #include <afs/param.h>
20
21 #include <roken.h>
22
23 #include <ctype.h>
24
25 #define VICE
26 #ifdef AFS_VFSINCL_ENV
27 #include <sys/vnode.h>
28 #ifdef    AFS_SUN5_ENV
29 #include <sys/fs/ufs_inode.h>
30 #include <sys/fs/ufs_fs.h>
31 #define _KERNEL
32 #include <sys/fs/ufs_fsdir.h>
33 #undef _KERNEL
34 #include <sys/fs/ufs_mount.h>
35 #else
36 #include <ufs/inode.h>
37 #include <ufs/fs.h>
38 #endif
39 #else /* AFS_VFSINCL_ENV */
40 #include <sys/inode.h>
41 #ifdef  AFS_HPUX_ENV
42 #define LONGFILENAMES   1
43 #include <sys/sysmacros.h>
44 #include <sys/ino.h>
45 #endif
46 #include <sys/fs.h>
47 #endif /* AFS_VFSINCL_ENV */
48
49 #include "fsck.h"
50
51 int pass1bcheck();
52 static struct dups *duphead;
53
54 pass1b()
55 {
56     int c, i;
57     struct dinode *dp;
58     struct inodesc idesc;
59     ino_t inumber;
60
61     memset(&idesc, 0, sizeof(struct inodesc));
62     idesc.id_type = ADDR;
63     idesc.id_func = pass1bcheck;
64     duphead = duplist;
65     inumber = 0;
66     for (c = 0; c < sblock.fs_ncg; c++) {
67         for (i = 0; i < sblock.fs_ipg; i++, inumber++) {
68             if (inumber < ROOTINO)
69                 continue;
70             dp = ginode(inumber);
71             if (dp == NULL)
72                 continue;
73             idesc.id_number = inumber;
74 #ifdef  AFS_SUN5_ENV
75             idesc.id_fix = DONTKNOW;
76 #endif
77 #if defined(ACLS) && defined(AFS_HPUX_ENV)
78             if (((statemap[inumber] & STATE) != USTATE) &&
79 #else /* not ACLS */
80             if (statemap[inumber] != USTATE &&
81 #endif /* ACLS */
82                 (ckinode(dp, &idesc) & STOP))
83                 return;
84         }
85     }
86 }
87
88 pass1bcheck(idesc)
89      struct inodesc *idesc;
90 {
91     struct dups *dlp;
92     int nfrags, res = KEEPON;
93     daddr_t blkno = idesc->id_blkno;
94
95     for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) {
96         if (chkrange(blkno, 1))
97             res = SKIP;
98         for (dlp = duphead; dlp; dlp = dlp->next) {
99             if (dlp->dup == blkno) {
100                 blkerror(idesc->id_number, "DUP", blkno);
101                 dlp->dup = duphead->dup;
102                 duphead->dup = blkno;
103                 duphead = duphead->next;
104             }
105             if (dlp == muldup)
106                 break;
107         }
108         if (muldup == 0 || duphead == muldup->next)
109             return (STOP);
110     }
111     return (res);
112 }