[BACK]Return to iso.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / fs / cd9660

Annotation of src/sys/fs/cd9660/iso.h, Revision 1.3

1.3     ! martin      1: /*     $NetBSD: iso.h,v 1.2 2003/08/07 16:31:36 agc Exp $      */
1.1       jdolecek    2:
                      3: /*-
                      4:  * Copyright (c) 1994
                      5:  *     The Regents of the University of California.  All rights reserved.
                      6:  *
                      7:  * This code is derived from software contributed to Berkeley
                      8:  * by Pace Willisson (pace@blitz.com).  The Rock Ridge Extension
                      9:  * Support code is derived from software contributed to Berkeley
                     10:  * by Atsushi Murai (amurai@spec.co.jp).
                     11:  *
                     12:  * Redistribution and use in source and binary forms, with or without
                     13:  * modification, are permitted provided that the following conditions
                     14:  * are met:
                     15:  * 1. Redistributions of source code must retain the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer.
                     17:  * 2. Redistributions in binary form must reproduce the above copyright
                     18:  *    notice, this list of conditions and the following disclaimer in the
                     19:  *    documentation and/or other materials provided with the distribution.
1.2       agc        20:  * 3. Neither the name of the University nor the names of its contributors
1.1       jdolecek   21:  *    may be used to endorse or promote products derived from this software
                     22:  *    without specific prior written permission.
                     23:  *
                     24:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     25:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     26:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     27:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     28:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     29:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     30:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     31:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     32:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     33:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     34:  * SUCH DAMAGE.
                     35:  *
                     36:  *     @(#)iso.h       8.6 (Berkeley) 5/10/95
                     37:  */
                     38:
                     39: /*
                     40:  * Definitions describing ISO9660 file system structure, as well as
                     41:  * the functions necessary to access fields of ISO9660 file system
                     42:  * structures.
                     43:  */
                     44:
                     45: #define ISODCL(from, to) (to - from + 1)
                     46:
                     47: struct iso_volume_descriptor {
                     48:        char type[ISODCL(1,1)]; /* 711 */
                     49:        char id[ISODCL(2,6)];
                     50:        char version[ISODCL(7,7)];
                     51:        char data[ISODCL(8,2048)];
                     52: };
                     53:
                     54: /* volume descriptor types */
                     55: #define ISO_VD_PRIMARY 1
                     56: #define ISO_VD_SUPPLEMENTARY 2
                     57: #define ISO_VD_END 255
                     58:
                     59: #define ISO_STANDARD_ID "CD001"
                     60: #define ISO_ECMA_ID     "CDW01"
                     61:
                     62: struct iso_primary_descriptor {
                     63:        char type                       [ISODCL (  1,   1)]; /* 711 */
                     64:        char id                         [ISODCL (  2,   6)];
                     65:        char version                    [ISODCL (  7,   7)]; /* 711 */
                     66:        char unused1                    [ISODCL (  8,   8)];
                     67:        char system_id                  [ISODCL (  9,  40)]; /* achars */
                     68:        char volume_id                  [ISODCL ( 41,  72)]; /* dchars */
                     69:        char unused2                    [ISODCL ( 73,  80)];
                     70:        char volume_space_size          [ISODCL ( 81,  88)]; /* 733 */
                     71:        char unused3                    [ISODCL ( 89, 120)];
                     72:        char volume_set_size            [ISODCL (121, 124)]; /* 723 */
                     73:        char volume_sequence_number     [ISODCL (125, 128)]; /* 723 */
                     74:        char logical_block_size         [ISODCL (129, 132)]; /* 723 */
                     75:        char path_table_size            [ISODCL (133, 140)]; /* 733 */
                     76:        char type_l_path_table          [ISODCL (141, 144)]; /* 731 */
                     77:        char opt_type_l_path_table      [ISODCL (145, 148)]; /* 731 */
                     78:        char type_m_path_table          [ISODCL (149, 152)]; /* 732 */
                     79:        char opt_type_m_path_table      [ISODCL (153, 156)]; /* 732 */
                     80:        char root_directory_record      [ISODCL (157, 190)]; /* 9.1 */
                     81:        char volume_set_id              [ISODCL (191, 318)]; /* dchars */
                     82:        char publisher_id               [ISODCL (319, 446)]; /* achars */
                     83:        char preparer_id                [ISODCL (447, 574)]; /* achars */
                     84:        char application_id             [ISODCL (575, 702)]; /* achars */
                     85:        char copyright_file_id          [ISODCL (703, 739)]; /* 7.5 dchars */
                     86:        char abstract_file_id           [ISODCL (740, 776)]; /* 7.5 dchars */
                     87:        char bibliographic_file_id      [ISODCL (777, 813)]; /* 7.5 dchars */
                     88:        char creation_date              [ISODCL (814, 830)]; /* 8.4.26.1 */
                     89:        char modification_date          [ISODCL (831, 847)]; /* 8.4.26.1 */
                     90:        char expiration_date            [ISODCL (848, 864)]; /* 8.4.26.1 */
                     91:        char effective_date             [ISODCL (865, 881)]; /* 8.4.26.1 */
                     92:        char file_structure_version     [ISODCL (882, 882)]; /* 711 */
                     93:        char unused4                    [ISODCL (883, 883)];
                     94:        char application_data           [ISODCL (884, 1395)];
                     95:        char unused5                    [ISODCL (1396, 2048)];
                     96: };
                     97: #define ISO_DEFAULT_BLOCK_SIZE         2048
                     98:
                     99: struct iso_supplementary_descriptor {
                    100:        char type                       [ISODCL (  1,   1)]; /* 711 */
                    101:        char id                         [ISODCL (  2,   6)];
                    102:        char version                    [ISODCL (  7,   7)]; /* 711 */
                    103:        char flags                      [ISODCL (  8,   8)]; /* 711? */
                    104:        char system_id                  [ISODCL (  9,  40)]; /* achars */
                    105:        char volume_id                  [ISODCL ( 41,  72)]; /* dchars */
                    106:        char unused2                    [ISODCL ( 73,  80)];
                    107:        char volume_space_size          [ISODCL ( 81,  88)]; /* 733 */
                    108:        char escape                     [ISODCL ( 89, 120)];
                    109:        char volume_set_size            [ISODCL (121, 124)]; /* 723 */
                    110:        char volume_sequence_number     [ISODCL (125, 128)]; /* 723 */
                    111:        char logical_block_size         [ISODCL (129, 132)]; /* 723 */
                    112:        char path_table_size            [ISODCL (133, 140)]; /* 733 */
                    113:        char type_l_path_table          [ISODCL (141, 144)]; /* 731 */
                    114:        char opt_type_l_path_table      [ISODCL (145, 148)]; /* 731 */
                    115:        char type_m_path_table          [ISODCL (149, 152)]; /* 732 */
                    116:        char opt_type_m_path_table      [ISODCL (153, 156)]; /* 732 */
                    117:        char root_directory_record      [ISODCL (157, 190)]; /* 9.1 */
                    118:        char volume_set_id              [ISODCL (191, 318)]; /* dchars */
                    119:        char publisher_id               [ISODCL (319, 446)]; /* achars */
                    120:        char preparer_id                [ISODCL (447, 574)]; /* achars */
                    121:        char application_id             [ISODCL (575, 702)]; /* achars */
                    122:        char copyright_file_id          [ISODCL (703, 739)]; /* 7.5 dchars */
                    123:        char abstract_file_id           [ISODCL (740, 776)]; /* 7.5 dchars */
                    124:        char bibliographic_file_id      [ISODCL (777, 813)]; /* 7.5 dchars */
                    125:        char creation_date              [ISODCL (814, 830)]; /* 8.4.26.1 */
                    126:        char modification_date          [ISODCL (831, 847)]; /* 8.4.26.1 */
                    127:        char expiration_date            [ISODCL (848, 864)]; /* 8.4.26.1 */
                    128:        char effective_date             [ISODCL (865, 881)]; /* 8.4.26.1 */
                    129:        char file_structure_version     [ISODCL (882, 882)]; /* 711 */
                    130:        char unused4                    [ISODCL (883, 883)];
                    131:        char application_data           [ISODCL (884, 1395)];
                    132:        char unused5                    [ISODCL (1396, 2048)];
                    133: };
                    134:
                    135: struct iso_directory_record {
                    136:        char length                     [ISODCL (1, 1)]; /* 711 */
                    137:        char ext_attr_length            [ISODCL (2, 2)]; /* 711 */
                    138:        u_char extent                   [ISODCL (3, 10)]; /* 733 */
                    139:        u_char size                     [ISODCL (11, 18)]; /* 733 */
                    140:        char date                       [ISODCL (19, 25)]; /* 7 by 711 */
                    141:        char flags                      [ISODCL (26, 26)];
                    142:        char file_unit_size             [ISODCL (27, 27)]; /* 711 */
                    143:        char interleave                 [ISODCL (28, 28)]; /* 711 */
                    144:        char volume_sequence_number     [ISODCL (29, 32)]; /* 723 */
                    145:        char name_len                   [ISODCL (33, 33)]; /* 711 */
                    146:        char name                       [1];                    /* XXX */
                    147: };
                    148: /* can't take sizeof(iso_directory_record), because of possible alignment
                    149:    of the last entry (34 instead of 33) */
                    150: #define ISO_DIRECTORY_RECORD_SIZE      33
                    151:
                    152: struct iso_extended_attributes {
                    153:        u_char owner                    [ISODCL (1, 4)]; /* 723 */
                    154:        u_char group                    [ISODCL (5, 8)]; /* 723 */
                    155:        u_char perm                     [ISODCL (9, 10)]; /* 9.5.3 */
                    156:        char ctime                      [ISODCL (11, 27)]; /* 8.4.26.1 */
                    157:        char mtime                      [ISODCL (28, 44)]; /* 8.4.26.1 */
                    158:        char xtime                      [ISODCL (45, 61)]; /* 8.4.26.1 */
                    159:        char ftime                      [ISODCL (62, 78)]; /* 8.4.26.1 */
                    160:        char recfmt                     [ISODCL (79, 79)]; /* 711 */
                    161:        char recattr                    [ISODCL (80, 80)]; /* 711 */
                    162:        u_char reclen                   [ISODCL (81, 84)]; /* 723 */
                    163:        char system_id                  [ISODCL (85, 116)]; /* achars */
                    164:        char system_use                 [ISODCL (117, 180)];
                    165:        char version                    [ISODCL (181, 181)]; /* 711 */
                    166:        char len_esc                    [ISODCL (182, 182)]; /* 711 */
                    167:        char reserved                   [ISODCL (183, 246)];
                    168:        u_char len_au                   [ISODCL (247, 250)]; /* 723 */
                    169: };
                    170:
                    171: static __inline int isonum_711 __P((u_char *)) __attribute__ ((unused));
1.3     ! martin    172: static __inline int isonum_712 __P((signed char *)) __attribute__ ((unused));
        !           173: static __inline uint16_t isonum_721 __P((u_char *)) __attribute__ ((unused));
        !           174: static __inline uint16_t isonum_722 __P((u_char *)) __attribute__ ((unused));
        !           175: static __inline uint16_t isonum_723 __P((u_char *)) __attribute__ ((unused));
        !           176: static __inline uint32_t isonum_731 __P((u_char *)) __attribute__ ((unused));
        !           177: static __inline uint32_t isonum_732 __P((u_char *)) __attribute__ ((unused));
        !           178: static __inline uint32_t isonum_733 __P((u_char *)) __attribute__ ((unused));
1.1       jdolecek  179:
                    180: /* 7.1.1: unsigned char */
                    181: static __inline int
                    182: #if __STDC__
                    183: isonum_711(u_char *p)
                    184: #else
                    185: isonum_711(p)
                    186:        u_char *p;
                    187: #endif
                    188: {
                    189:        return *p;
                    190: }
                    191:
                    192: /* 7.1.2: signed(?) char */
                    193: static __inline int
                    194: #if __STDC__
1.3     ! martin    195: isonum_712(signed char *p)
1.1       jdolecek  196: #else
                    197: isonum_712(p)
1.3     ! martin    198:        signed char *p;
1.1       jdolecek  199: #endif
                    200: {
                    201:        return *p;
                    202: }
                    203:
                    204: /* 7.2.1: unsigned little-endian 16-bit value.  NOT USED IN KERNEL. */
1.3     ! martin    205: static __inline uint16_t
1.1       jdolecek  206: isonum_721(p)
                    207:        u_char *p;
                    208: {
                    209: #if defined(UNALIGNED_ACCESS) && (BYTE_ORDER == LITTLE_ENDIAN)
1.3     ! martin    210:        return *(uint16_t *)p;
1.1       jdolecek  211: #else
                    212:        return *p|((char)p[1] << 8);
                    213: #endif
                    214: }
                    215:
                    216: /* 7.2.2: unsigned big-endian 16-bit value.  NOT USED IN KERNEL. */
1.3     ! martin    217: static __inline uint16_t
1.1       jdolecek  218: isonum_722(p)
                    219:        unsigned char *p;
                    220: {
                    221: #if defined(UNALIGNED_ACCESS) && (BYTE_ORDER == BIG_ENDIAN)
1.3     ! martin    222:        return *(uint16_t *)p;
1.1       jdolecek  223: #else
                    224:        return ((char)*p << 8)|p[1];
                    225: #endif
                    226: }
                    227:
                    228: /* 7.2.3: unsigned both-endian (little, then big) 16-bit value */
1.3     ! martin    229: static __inline uint16_t
1.1       jdolecek  230: #if __STDC__
                    231: isonum_723(u_char *p)
                    232: #else
                    233: isonum_723(p)
                    234:        u_char *p;
                    235: #endif
                    236: {
                    237: #if defined(UNALIGNED_ACCESS) && \
                    238:     ((BYTE_ORDER == LITTLE_ENDIAN) || (BYTE_ORDER == BIG_ENDIAN))
                    239: #if BYTE_ORDER == LITTLE_ENDIAN
1.3     ! martin    240:        return *(uint16_t *)p;
1.1       jdolecek  241: #else
1.3     ! martin    242:        return *(uint16_t *)(p + 2);
1.1       jdolecek  243: #endif
                    244: #else /* !UNALIGNED_ACCESS or weird byte order */
                    245:        return *p|(p[1] << 8);
                    246: #endif
                    247: }
                    248:
                    249: /* 7.3.1: unsigned little-endian 32-bit value.  NOT USED IN KERNEL. */
1.3     ! martin    250: static __inline uint32_t
1.1       jdolecek  251: isonum_731(p)
                    252:        u_char *p;
                    253: {
                    254: #if defined(UNALIGNED_ACCESS) && (BYTE_ORDER == LITTLE_ENDIAN)
1.3     ! martin    255:        return *(uint32_t *)p;
1.1       jdolecek  256: #else
                    257:        return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24);
                    258: #endif
                    259: }
                    260:
                    261: /* 7.3.2: unsigned big-endian 32-bit value.  NOT USED IN KERNEL. */
1.3     ! martin    262: static __inline uint32_t
1.1       jdolecek  263: isonum_732(p)
                    264:        unsigned char *p;
                    265: {
                    266: #if defined(UNALIGNED_ACCESS) && (BYTE_ORDER == BIG_ENDIAN)
1.3     ! martin    267:        return *(uint32_t *)p;
1.1       jdolecek  268: #else
                    269:        return (*p << 24)|(p[1] << 16)|(p[2] << 8)|p[3];
                    270: #endif
                    271: }
                    272:
                    273: /* 7.3.3: unsigned both-endian (little, then big) 32-bit value */
1.3     ! martin    274: static __inline uint32_t
1.1       jdolecek  275: #if __STDC__
                    276: isonum_733(u_char *p)
                    277: #else
                    278: isonum_733(p)
                    279:        u_char *p;
                    280: #endif
                    281: {
                    282: #if defined(UNALIGNED_ACCESS) && \
                    283:     ((BYTE_ORDER == LITTLE_ENDIAN) || (BYTE_ORDER == BIG_ENDIAN))
                    284: #if BYTE_ORDER == LITTLE_ENDIAN
1.3     ! martin    285:        return *(uint32_t *)p;
1.1       jdolecek  286: #else
1.3     ! martin    287:        return *(uint32_t *)(p + 4);
1.1       jdolecek  288: #endif
                    289: #else /* !UNALIGNED_ACCESS or weird byte order */
                    290:        return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24);
                    291: #endif
                    292: }
                    293:
                    294: /*
                    295:  * Associated files have a leading '='.
                    296:  */
                    297: #define        ASSOCCHAR       '='

CVSweb <webmaster@jp.NetBSD.org>