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