2 * Copyright (c) 1982, 1986 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_tables.c 7.3 (Berkeley) 4/24/89
20 #include <afsconfig.h>
21 #include <afs/param.h>
27 #include <sys/param.h>
34 * Bit patterns for identifying fragments in the block map
35 * used as ((map & around) == inside)
38 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff
41 0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe
45 * Given a block map bit pattern, the frag tables tell whether a
46 * particular size fragment is available.
49 * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] {
50 * at least one fragment of the indicated size is available
53 * These tables are used by the scanc instruction on the VAX to
54 * quickly find an appropriate fragment.
56 u_char fragtbl124[256] = {
57 0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e,
58 0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a,
59 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
60 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
61 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
62 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
63 0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e,
64 0x3e, 0x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6e, 0x4e,
86 0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce,
87 0x8a, 0x9e, 0x9e, 0xaa, 0x9e, 0x9e, 0xae, 0xce,
88 0x9e, 0x9e, 0x9e, 0xbe, 0xaa, 0xbe, 0xce, 0x8a,
91 u_char fragtbl8[256] = {
92 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04,
93 0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08,
94 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
95 0x02, 0x03, 0x03, 0x02, 0x04, 0x05, 0x08, 0x10,
96 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
97 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
98 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
99 0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20,
100 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
101 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
102 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
103 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
104 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
105 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
106 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
107 0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40,
108 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
109 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
110 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
111 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
112 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
113 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
114 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
115 0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21,
116 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
117 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
118 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
119 0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12,
120 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
121 0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c,
122 0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c,
123 0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80,
127 * The actual fragtbl array.
129 u_char *fragtbl[MAXFRAG + 1] = {
130 0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8,