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 <afsconfig.h>
21 #include <afs/param.h>
26 #include <sys/param.h>
30 #else /* AFS_OSF_ENV */
31 #ifdef AFS_VFSINCL_ENV
33 #include <sys/fs/ufs_fs.h>
37 #else /* AFS_VFSINCL_ENV */
39 #endif /* AFS_VFSINCL_ENV */
40 #endif /* AFS_OSF_ENV */
44 extern u_char *fragtbl[];
47 * Update the frsum fields to reflect addition or deletion
50 fragacct(fs, fragmap, fraglist, cnt)
60 inblk = (int)(fragtbl[fs->fs_frag][fragmap]) << 1;
62 for (siz = 1; siz < fs->fs_frag; siz++) {
63 if ((inblk & (1 << (siz + (fs->fs_frag % NBBY)))) == 0)
66 subfield = inside[siz];
67 for (pos = siz; pos <= fs->fs_frag; pos++) {
68 if ((fragmap & field) == subfield) {
83 * check if a block is available
92 switch ((int)fs->fs_frag) {
94 return (cp[h] == 0xff);
96 mask = 0x0f << ((h & 0x1) << 2);
97 return ((cp[h >> 1] & mask) == mask);
99 mask = 0x03 << ((h & 0x3) << 1);
100 return ((cp[h >> 2] & mask) == mask);
102 mask = 0x01 << (h & 0x7);
103 return ((cp[h >> 3] & mask) == mask);
111 * take a block out of the map
119 switch ((int)fs->fs_frag) {
124 cp[h >> 1] &= ~(0x0f << ((h & 0x1) << 2));
127 cp[h >> 2] &= ~(0x03 << ((h & 0x3) << 1));
130 cp[h >> 3] &= ~(0x01 << (h & 0x7));
138 * put a block into the map
146 switch ((int)fs->fs_frag) {
152 cp[h >> 1] |= (0x0f << ((h & 0x1) << 2));
155 cp[h >> 2] |= (0x03 << ((h & 0x3) << 1));
158 cp[h >> 3] |= (0x01 << (h & 0x7));
165 #if (!defined(vax) && !defined(tahoe)) || defined(VAX630) || defined(VAX650)
167 * C definitions of special instructions.
168 * Normally expanded with inline.
170 scanc(size, cp, table, mask)
175 u_char *end = &cp[size];
177 while (cp < end && (table[*cp] & mask) == 0)
183 #if !defined(vax) && !defined(tahoe)
189 u_char *end = &cp[size];
191 while (cp < end && *cp == mask)
201 u_char *end = &cp[size];
203 while (cp < end && *cp != mask)