venus: Remove dedebug
[openafs.git] / src / vfsck / ufs_tables.c
1 /*
2  * Copyright (c) 1982, 1986 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  *      @(#)ufs_tables.c        7.3 (Berkeley) 4/24/89
18  */
19
20 #include <afsconfig.h>
21 #include <afs/param.h>
22
23 #ifndef KERNEL
24 #include <roken.h>
25 #ifdef  AFS_HPUX_ENV
26 #include <sys/fs.h>
27 #endif
28 #endif
29
30 /*
31  * Bit patterns for identifying fragments in the block map
32  * used as ((map & around) == inside)
33  */
34 int around[9] = {
35     0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff
36 };
37 int inside[9] = {
38     0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe
39 };
40
41 /*
42  * Given a block map bit pattern, the frag tables tell whether a
43  * particular size fragment is available.
44  *
45  * used as:
46  * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] {
47  *      at least one fragment of the indicated size is available
48  * }
49  *
50  * These tables are used by the scanc instruction on the VAX to
51  * quickly find an appropriate fragment.
52  */
53 u_char fragtbl124[256] = {
54     0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e,
55     0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a,
56     0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
57     0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
58     0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
59     0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
60     0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e,
61     0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa,
62     0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
63     0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
64     0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
65     0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
66     0x26, 0x36, 0x36, 0x2e, 0x36, 0x36, 0x26, 0x6e,
67     0x36, 0x36, 0x36, 0x3e, 0x2e, 0x3e, 0x6e, 0xae,
68     0x4e, 0x5e, 0x5e, 0x6e, 0x5e, 0x5e, 0x6e, 0x4e,
69     0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce,
70     0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
71     0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
72     0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
73     0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
74     0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
75     0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
76     0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e,
77     0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, 0xbe,
78     0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e,
79     0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa,
80     0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e,
81     0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, 0xbe,
82     0x4e, 0x5e, 0x5e, 0x6e, 0x5e, 0x5e, 0x6e, 0x4e,
83     0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce,
84     0x8a, 0x9e, 0x9e, 0xaa, 0x9e, 0x9e, 0xae, 0xce,
85     0x9e, 0x9e, 0x9e, 0xbe, 0xaa, 0xbe, 0xce, 0x8a,
86 };
87
88 u_char fragtbl8[256] = {
89     0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04,
90     0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08,
91     0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
92     0x02, 0x03, 0x03, 0x02, 0x04, 0x05, 0x08, 0x10,
93     0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
94     0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
95     0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
96     0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20,
97     0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
98     0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
99     0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
100     0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
101     0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
102     0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
103     0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
104     0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40,
105     0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
106     0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
107     0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
108     0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
109     0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
110     0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
111     0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
112     0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21,
113     0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
114     0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
115     0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
116     0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12,
117     0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
118     0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c,
119     0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c,
120     0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80,
121 };
122
123 /*
124  * The actual fragtbl array.
125  */
126 u_char *fragtbl[MAXFRAG + 1] = {
127     0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8,
128 };