ffs_tables.c revision 1.1 1 1.1 mycroft /*
2 1.1 mycroft * Copyright (c) 1982, 1986, 1993
3 1.1 mycroft * The Regents of the University of California. All rights reserved.
4 1.1 mycroft *
5 1.1 mycroft * Redistribution and use in source and binary forms, with or without
6 1.1 mycroft * modification, are permitted provided that the following conditions
7 1.1 mycroft * are met:
8 1.1 mycroft * 1. Redistributions of source code must retain the above copyright
9 1.1 mycroft * notice, this list of conditions and the following disclaimer.
10 1.1 mycroft * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 mycroft * notice, this list of conditions and the following disclaimer in the
12 1.1 mycroft * documentation and/or other materials provided with the distribution.
13 1.1 mycroft * 3. All advertising materials mentioning features or use of this software
14 1.1 mycroft * must display the following acknowledgement:
15 1.1 mycroft * This product includes software developed by the University of
16 1.1 mycroft * California, Berkeley and its contributors.
17 1.1 mycroft * 4. Neither the name of the University nor the names of its contributors
18 1.1 mycroft * may be used to endorse or promote products derived from this software
19 1.1 mycroft * without specific prior written permission.
20 1.1 mycroft *
21 1.1 mycroft * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 1.1 mycroft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1 mycroft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1 mycroft * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 1.1 mycroft * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.1 mycroft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.1 mycroft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.1 mycroft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.1 mycroft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.1 mycroft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.1 mycroft * SUCH DAMAGE.
32 1.1 mycroft *
33 1.1 mycroft * from: @(#)ffs_tables.c 8.1 (Berkeley) 6/11/93
34 1.1 mycroft * $Id: ffs_tables.c,v 1.1 1994/06/08 11:42:08 mycroft Exp $
35 1.1 mycroft */
36 1.1 mycroft
37 1.1 mycroft #include <sys/param.h>
38 1.1 mycroft
39 1.1 mycroft /*
40 1.1 mycroft * Bit patterns for identifying fragments in the block map
41 1.1 mycroft * used as ((map & around) == inside)
42 1.1 mycroft */
43 1.1 mycroft int around[9] = {
44 1.1 mycroft 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff
45 1.1 mycroft };
46 1.1 mycroft int inside[9] = {
47 1.1 mycroft 0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe
48 1.1 mycroft };
49 1.1 mycroft
50 1.1 mycroft /*
51 1.1 mycroft * Given a block map bit pattern, the frag tables tell whether a
52 1.1 mycroft * particular size fragment is available.
53 1.1 mycroft *
54 1.1 mycroft * used as:
55 1.1 mycroft * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] {
56 1.1 mycroft * at least one fragment of the indicated size is available
57 1.1 mycroft * }
58 1.1 mycroft *
59 1.1 mycroft * These tables are used by the scanc instruction on the VAX to
60 1.1 mycroft * quickly find an appropriate fragment.
61 1.1 mycroft */
62 1.1 mycroft u_char fragtbl124[256] = {
63 1.1 mycroft 0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e,
64 1.1 mycroft 0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a,
65 1.1 mycroft 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
66 1.1 mycroft 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
67 1.1 mycroft 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
68 1.1 mycroft 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
69 1.1 mycroft 0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e,
70 1.1 mycroft 0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa,
71 1.1 mycroft 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
72 1.1 mycroft 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
73 1.1 mycroft 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
74 1.1 mycroft 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
75 1.1 mycroft 0x26, 0x36, 0x36, 0x2e, 0x36, 0x36, 0x26, 0x6e,
76 1.1 mycroft 0x36, 0x36, 0x36, 0x3e, 0x2e, 0x3e, 0x6e, 0xae,
77 1.1 mycroft 0x4e, 0x5e, 0x5e, 0x6e, 0x5e, 0x5e, 0x6e, 0x4e,
78 1.1 mycroft 0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce,
79 1.1 mycroft 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
80 1.1 mycroft 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
81 1.1 mycroft 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
82 1.1 mycroft 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
83 1.1 mycroft 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
84 1.1 mycroft 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
85 1.1 mycroft 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e,
86 1.1 mycroft 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, 0xbe,
87 1.1 mycroft 0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e,
88 1.1 mycroft 0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa,
89 1.1 mycroft 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e,
90 1.1 mycroft 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, 0xbe,
91 1.1 mycroft 0x4e, 0x5e, 0x5e, 0x6e, 0x5e, 0x5e, 0x6e, 0x4e,
92 1.1 mycroft 0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce,
93 1.1 mycroft 0x8a, 0x9e, 0x9e, 0xaa, 0x9e, 0x9e, 0xae, 0xce,
94 1.1 mycroft 0x9e, 0x9e, 0x9e, 0xbe, 0xaa, 0xbe, 0xce, 0x8a,
95 1.1 mycroft };
96 1.1 mycroft
97 1.1 mycroft u_char fragtbl8[256] = {
98 1.1 mycroft 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04,
99 1.1 mycroft 0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08,
100 1.1 mycroft 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
101 1.1 mycroft 0x02, 0x03, 0x03, 0x02, 0x04, 0x05, 0x08, 0x10,
102 1.1 mycroft 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
103 1.1 mycroft 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
104 1.1 mycroft 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
105 1.1 mycroft 0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20,
106 1.1 mycroft 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
107 1.1 mycroft 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
108 1.1 mycroft 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
109 1.1 mycroft 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
110 1.1 mycroft 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
111 1.1 mycroft 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
112 1.1 mycroft 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
113 1.1 mycroft 0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40,
114 1.1 mycroft 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
115 1.1 mycroft 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
116 1.1 mycroft 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
117 1.1 mycroft 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
118 1.1 mycroft 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
119 1.1 mycroft 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
120 1.1 mycroft 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
121 1.1 mycroft 0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21,
122 1.1 mycroft 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
123 1.1 mycroft 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
124 1.1 mycroft 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
125 1.1 mycroft 0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12,
126 1.1 mycroft 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
127 1.1 mycroft 0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c,
128 1.1 mycroft 0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c,
129 1.1 mycroft 0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80,
130 1.1 mycroft };
131 1.1 mycroft
132 1.1 mycroft /*
133 1.1 mycroft * The actual fragtbl array.
134 1.1 mycroft */
135 1.1 mycroft u_char *fragtbl[MAXFRAG + 1] = {
136 1.1 mycroft 0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8,
137 1.1 mycroft };
138