1 |
17 |
hellwig |
/* $NetBSD: ffs_tables.c,v 1.9 2005/12/11 12:25:25 christos Exp $ */
|
2 |
|
|
|
3 |
|
|
/*
|
4 |
|
|
* Copyright (c) 1982, 1986, 1993
|
5 |
|
|
* The Regents of the University of California. All rights reserved.
|
6 |
|
|
*
|
7 |
|
|
* Redistribution and use in source and binary forms, with or without
|
8 |
|
|
* modification, are permitted provided that the following conditions
|
9 |
|
|
* are met:
|
10 |
|
|
* 1. Redistributions of source code must retain the above copyright
|
11 |
|
|
* notice, this list of conditions and the following disclaimer.
|
12 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
13 |
|
|
* notice, this list of conditions and the following disclaimer in the
|
14 |
|
|
* documentation and/or other materials provided with the distribution.
|
15 |
|
|
* 3. Neither the name of the University nor the names of its contributors
|
16 |
|
|
* may be used to endorse or promote products derived from this software
|
17 |
|
|
* without specific prior written permission.
|
18 |
|
|
*
|
19 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
20 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
23 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
24 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
25 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
26 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
27 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
28 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
29 |
|
|
* SUCH DAMAGE.
|
30 |
|
|
*
|
31 |
|
|
* @(#)ffs_tables.c 8.1 (Berkeley) 6/11/93
|
32 |
|
|
*/
|
33 |
|
|
|
34 |
|
|
#if HAVE_NBTOOL_CONFIG_H
|
35 |
|
|
#include "nbtool_config.h"
|
36 |
|
|
#endif
|
37 |
|
|
|
38 |
|
|
#include <sys/cdefs.h>
|
39 |
|
|
#if defined(__KERNEL_RCSID) && !defined(__lint)
|
40 |
|
|
__KERNEL_RCSID(0, "$NetBSD: ffs_tables.c,v 1.9 2005/12/11 12:25:25 christos Exp $");
|
41 |
|
|
#endif
|
42 |
|
|
|
43 |
|
|
#include <sys/param.h>
|
44 |
|
|
|
45 |
|
|
#include "common.h"
|
46 |
|
|
#include "fs.h"
|
47 |
|
|
|
48 |
|
|
/*
|
49 |
|
|
* Bit patterns for identifying fragments in the block map
|
50 |
|
|
* used as ((map & around) == inside)
|
51 |
|
|
*/
|
52 |
|
|
const int around[9] = {
|
53 |
|
|
0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff
|
54 |
|
|
};
|
55 |
|
|
const int inside[9] = {
|
56 |
|
|
0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe
|
57 |
|
|
};
|
58 |
|
|
|
59 |
|
|
/*
|
60 |
|
|
* Given a block map bit pattern, the frag tables tell whether a
|
61 |
|
|
* particular size fragment is available.
|
62 |
|
|
*
|
63 |
|
|
* used as:
|
64 |
|
|
* if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] {
|
65 |
|
|
* at least one fragment of the indicated size is available
|
66 |
|
|
* }
|
67 |
|
|
*
|
68 |
|
|
* These tables are used by the scanc instruction on the VAX to
|
69 |
|
|
* quickly find an appropriate fragment.
|
70 |
|
|
*/
|
71 |
|
|
const u_char fragt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01, 0x03, 0x01, 0x01, 0x03, 0x05,
|
112 |
|
|
0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
|
113 |
|
|
0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
|
114 |
|
|
0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20,
|
115 |
|
|
0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
|
116 |
|
|
0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
|
117 |
|
|
0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
|
118 |
|
|
0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
|
119 |
|
|
0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
|
120 |
|
|
0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
|
121 |
|
|
0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
|
122 |
|
|
0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40,
|
123 |
|
|
0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
|
124 |
|
|
0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
|
125 |
|
|
0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
|
126 |
|
|
0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
|
127 |
|
|
0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
|
128 |
|
|
0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
|
129 |
|
|
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
|
130 |
|
|
0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21,
|
131 |
|
|
0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
|
132 |
|
|
0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
|
133 |
|
|
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
|
134 |
|
|
0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12,
|
135 |
|
|
0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
|
136 |
|
|
0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c,
|
137 |
|
|
0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c,
|
138 |
|
|
0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80,
|
139 |
|
|
};
|
140 |
|
|
|
141 |
|
|
/*
|
142 |
|
|
* The actual fragtbl array.
|
143 |
|
|
*/
|
144 |
|
|
const u_char * const fragtbl[MAXFRAG + 1] = {
|
145 |
|
|
0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8,
|
146 |
|
|
};
|