Annotation of XNU/bsd/ufs/ffs/ffs_tables.c, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.