avoid null pointers
[unix-history] / usr / src / sys / ufs / ffs / ffs_tables.c
CommitLineData
da7c5cc6 1/*
0880b18e 2 * Copyright (c) 1982, 1986 Regents of the University of California.
4aa5c983 3 * All rights reserved.
da7c5cc6 4 *
b702c21d 5 * %sccs.include.redist.c%
4aa5c983 6 *
b702c21d 7 * @(#)ffs_tables.c 7.4 (Berkeley) %G%
da7c5cc6 8 */
5576d804 9
10deb49e 10#ifdef KERNEL
94368568 11#include "param.h"
10deb49e
KB
12#else
13#include <sys/param.h>
14#endif
5576d804 15
5576d804 16/*
88a7a62a 17 * Bit patterns for identifying fragments in the block map
5576d804
KM
18 * used as ((map & around) == inside)
19 */
20int around[9] = {
21 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff
22};
23int inside[9] = {
24 0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe
25};
26
27/*
88a7a62a 28 * Given a block map bit pattern, the frag tables tell whether a
5576d804 29 * particular size fragment is available.
b6407c9d 30 *
5576d804 31 * used as:
b6407c9d 32 * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] {
5576d804
KM
33 * at least one fragment of the indicated size is available
34 * }
b6407c9d
KM
35 *
36 * These tables are used by the scanc instruction on the VAX to
5576d804
KM
37 * quickly find an appropriate fragment.
38 */
88a7a62a 39u_char fragtbl124[256] = {
156b8f82
KM
40 0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e,
41 0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a,
42 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
43 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
44 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
45 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
46 0x2a, 0x3e, 0x3e, 0x2a,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e, 0x5e, 0x5e, 0x6e, 0x5e, 0x5e, 0x6e, 0x4e,
69 0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce,
70 0x8a, 0x9e, 0x9e, 0xaa, 0x9e, 0x9e, 0xae, 0xce,
71 0x9e, 0x9e, 0x9e, 0xbe, 0xaa, 0xbe, 0xce, 0x8a,
5576d804 72};
5576d804 73
88a7a62a 74u_char fragtbl8[256] = {
5576d804
KM
75 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04,
76 0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08,
77 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
78 0x02, 0x03, 0x03, 0x02, 0x04, 0x05, 0x08, 0x10,
79 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
80 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
81 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
82 0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20,
83 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
84 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
85 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
86 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
87 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
88 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
89 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
90 0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40,
91 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
92 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
93 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
94 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
95 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
96 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
97 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
98 0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21,
99 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
100 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
101 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
102 0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12,
103 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
104 0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c,
105 0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c,
106 0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80,
107};
b6407c9d
KM
108
109/*
88a7a62a 110 * The actual fragtbl array.
b6407c9d 111 */
88a7a62a 112u_char *fragtbl[MAXFRAG + 1] = {
156b8f82 113 0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8,
b6407c9d 114};