expand parameters to functions; READDIR drops eofflag;
[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 *
7273f499 7 * @(#)ffs_tables.c 7.5 (Berkeley) %G%
da7c5cc6 8 */
5576d804 9
10deb49e 10#include <sys/param.h>
5576d804 11
5576d804 12/*
88a7a62a 13 * Bit patterns for identifying fragments in the block map
5576d804
KM
14 * used as ((map & around) == inside)
15 */
16int around[9] = {
17 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff
18};
19int inside[9] = {
20 0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe
21};
22
23/*
88a7a62a 24 * Given a block map bit pattern, the frag tables tell whether a
5576d804 25 * particular size fragment is available.
b6407c9d 26 *
5576d804 27 * used as:
b6407c9d 28 * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] {
5576d804
KM
29 * at least one fragment of the indicated size is available
30 * }
b6407c9d
KM
31 *
32 * These tables are used by the scanc instruction on the VAX to
5576d804
KM
33 * quickly find an appropriate fragment.
34 */
88a7a62a 35u_char fragtbl124[256] = {
156b8f82
KM
36 0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e,
37 0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a,
38 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
39 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
40 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
41 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
42 0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e,
43 0x3e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, 0x6e, 0x4e,
65 0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce,
66 0x8a, 0x9e, 0x9e, 0xaa, 0x9e, 0x9e, 0xae, 0xce,
67 0x9e, 0x9e, 0x9e, 0xbe, 0xaa, 0xbe, 0xce, 0x8a,
5576d804 68};
5576d804 69
88a7a62a 70u_char fragtbl8[256] = {
5576d804
KM
71 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04,
72 0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08,
73 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
74 0x02, 0x03, 0x03, 0x02, 0x04, 0x05, 0x08, 0x10,
75 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
76 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
77 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
78 0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20,
79 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
80 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
81 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
82 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
83 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
84 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
85 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
86 0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40,
87 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
88 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
89 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
90 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
91 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
92 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
93 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
94 0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21,
95 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
96 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
97 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
98 0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12,
99 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
100 0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c,
101 0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c,
102 0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80,
103};
b6407c9d
KM
104
105/*
88a7a62a 106 * The actual fragtbl array.
b6407c9d 107 */
88a7a62a 108u_char *fragtbl[MAXFRAG + 1] = {
156b8f82 109 0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8,
b6407c9d 110};