2 * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
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.
17 * @(#)ufs_subr.c 7.11 (Berkeley) 12/30/89
20 #include <afs/param.h>
21 #include <afsconfig.h>
27 #include <sys/param.h>
31 #else /* AFS_OSF_ENV */
32 #ifdef AFS_VFSINCL_ENV
34 #include <sys/fs/ufs_fs.h>
38 #else /* AFS_VFSINCL_ENV */
40 #endif /* AFS_VFSINCL_ENV */
41 #endif /* AFS_OSF_ENV */
45 extern u_char *fragtbl[];
48 * Update the frsum fields to reflect addition or deletion
51 fragacct(fs, fragmap, fraglist, cnt)
58 register int field, subfield;
59 register int siz, pos;
61 inblk = (int)(fragtbl[fs->fs_frag][fragmap]) << 1;
63 for (siz = 1; siz < fs->fs_frag; siz++) {
64 if ((inblk & (1 << (siz + (fs->fs_frag % NBBY)))) == 0)
67 subfield = inside[siz];
68 for (pos = siz; pos <= fs->fs_frag; pos++) {
69 if ((fragmap & field) == subfield) {
84 * check if a block is available
93 switch ((int)fs->fs_frag) {
95 return (cp[h] == 0xff);
97 mask = 0x0f << ((h & 0x1) << 2);
98 return ((cp[h >> 1] & mask) == mask);
100 mask = 0x03 << ((h & 0x3) << 1);
101 return ((cp[h >> 2] & mask) == mask);
103 mask = 0x01 << (h & 0x7);
104 return ((cp[h >> 3] & mask) == mask);
112 * take a block out of the map
120 switch ((int)fs->fs_frag) {
125 cp[h >> 1] &= ~(0x0f << ((h & 0x1) << 2));
128 cp[h >> 2] &= ~(0x03 << ((h & 0x3) << 1));
131 cp[h >> 3] &= ~(0x01 << (h & 0x7));
139 * put a block into the map
147 switch ((int)fs->fs_frag) {
153 cp[h >> 1] |= (0x0f << ((h & 0x1) << 2));
156 cp[h >> 2] |= (0x03 << ((h & 0x3) << 1));
159 cp[h >> 3] |= (0x01 << (h & 0x7));
166 #if (!defined(vax) && !defined(tahoe)) || defined(VAX630) || defined(VAX650)
168 * C definitions of special instructions.
169 * Normally expanded with inline.
171 scanc(size, cp, table, mask)
173 register u_char *cp, table[];
174 register u_char mask;
176 register u_char *end = &cp[size];
178 while (cp < end && (table[*cp] & mask) == 0)
184 #if !defined(vax) && !defined(tahoe)
186 register u_char mask;
190 register u_char *end = &cp[size];
192 while (cp < end && *cp == mask)
198 register u_char mask;
202 register u_char *end = &cp[size];
204 while (cp < end && *cp != mask)