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>
29 #else /* AFS_OSF_ENV */
30 #ifdef AFS_VFSINCL_ENV
32 #include <sys/fs/ufs_fs.h>
36 #else /* AFS_VFSINCL_ENV */
38 #endif /* AFS_VFSINCL_ENV */
39 #endif /* AFS_OSF_ENV */
43 extern u_char
*fragtbl
[];
46 * Update the frsum fields to reflect addition or deletion
49 fragacct(fs
, fragmap
, fraglist
, cnt
)
59 inblk
= (int)(fragtbl
[fs
->fs_frag
][fragmap
]) << 1;
61 for (siz
= 1; siz
< fs
->fs_frag
; siz
++) {
62 if ((inblk
& (1 << (siz
+ (fs
->fs_frag
% NBBY
)))) == 0)
65 subfield
= inside
[siz
];
66 for (pos
= siz
; pos
<= fs
->fs_frag
; pos
++) {
67 if ((fragmap
& field
) == subfield
) {
82 * check if a block is available
91 switch ((int)fs
->fs_frag
) {
93 return (cp
[h
] == 0xff);
95 mask
= 0x0f << ((h
& 0x1) << 2);
96 return ((cp
[h
>> 1] & mask
) == mask
);
98 mask
= 0x03 << ((h
& 0x3) << 1);
99 return ((cp
[h
>> 2] & mask
) == mask
);
101 mask
= 0x01 << (h
& 0x7);
102 return ((cp
[h
>> 3] & mask
) == mask
);
110 * take a block out of the map
118 switch ((int)fs
->fs_frag
) {
123 cp
[h
>> 1] &= ~(0x0f << ((h
& 0x1) << 2));
126 cp
[h
>> 2] &= ~(0x03 << ((h
& 0x3) << 1));
129 cp
[h
>> 3] &= ~(0x01 << (h
& 0x7));
137 * put a block into the map
145 switch ((int)fs
->fs_frag
) {
151 cp
[h
>> 1] |= (0x0f << ((h
& 0x1) << 2));
154 cp
[h
>> 2] |= (0x03 << ((h
& 0x3) << 1));
157 cp
[h
>> 3] |= (0x01 << (h
& 0x7));
164 #if (!defined(vax) && !defined(tahoe)) || defined(VAX630) || defined(VAX650)
166 * C definitions of special instructions.
167 * Normally expanded with inline.
169 scanc(size
, cp
, table
, mask
)
174 u_char
*end
= &cp
[size
];
176 while (cp
< end
&& (table
[*cp
] & mask
) == 0)
182 #if !defined(vax) && !defined(tahoe)
188 u_char
*end
= &cp
[size
];
190 while (cp
< end
&& *cp
== mask
)
200 u_char
*end
= &cp
[size
];
202 while (cp
< end
&& *cp
!= mask
)