1 /* 2 * Copyright (c) 1982, 1986 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)ffs_tables.c 7.5 (Berkeley) 11/01/91 8 */ 9 10 #include <sys/param.h> 11 12 /* 13 * Bit patterns for identifying fragments in the block map 14 * used as ((map & around) == inside) 15 */ 16 int around[9] = { 17 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff 18 }; 19 int inside[9] = { 20 0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe 21 }; 22 23 /* 24 * Given a block map bit pattern, the frag tables tell whether a 25 * particular size fragment is available. 26 * 27 * used as: 28 * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] { 29 * at least one fragment of the indicated size is available 30 * } 31 * 32 * These tables are used by the scanc instruction on the VAX to 33 * quickly find an appropriate fragment. 34 */ 35 u_char fragtbl124[256] = { 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, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa, 44 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, 45 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, 46 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, 47 0x16, 0x16, 0x16, 0x3e, 0x3e,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x01, 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 }; 104 105 /* 106 * The actual fragtbl array. 107 */ 108 u_char *fragtbl[MAXFRAG + 1] = { 109 0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8, 110 }; 111