iso.h revision 25531
11541Srgrimes/*- 21541Srgrimes * Copyright (c) 1994 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * This code is derived from software contributed to Berkeley 61541Srgrimes * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension 71541Srgrimes * Support code is derived from software contributed to Berkeley 81541Srgrimes * by Atsushi Murai (amurai@spec.co.jp). 91541Srgrimes * 101541Srgrimes * Redistribution and use in source and binary forms, with or without 111541Srgrimes * modification, are permitted provided that the following conditions 121541Srgrimes * are met: 131541Srgrimes * 1. Redistributions of source code must retain the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer. 151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 161541Srgrimes * notice, this list of conditions and the following disclaimer in the 171541Srgrimes * documentation and/or other materials provided with the distribution. 181541Srgrimes * 3. All advertising materials mentioning features or use of this software 191541Srgrimes * must display the following acknowledgement: 201541Srgrimes * This product includes software developed by the University of 211541Srgrimes * California, Berkeley and its contributors. 221541Srgrimes * 4. Neither the name of the University nor the names of its contributors 231541Srgrimes * may be used to endorse or promote products derived from this software 241541Srgrimes * without specific prior written permission. 251541Srgrimes * 261541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 271541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 281541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 291541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 301541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 311541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 321541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 331541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 341541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 351541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 361541Srgrimes * SUCH DAMAGE. 371541Srgrimes * 3822521Sdyson * @(#)iso.h 8.6 (Berkeley) 5/10/95 3925531Sjoerg * $Id: iso.h,v 1.15 1997/05/04 16:17:49 joerg Exp $ 401541Srgrimes */ 411541Srgrimes 421541Srgrimes#define ISODCL(from, to) (to - from + 1) 431541Srgrimes 441541Srgrimesstruct iso_volume_descriptor { 451541Srgrimes char type[ISODCL(1,1)]; /* 711 */ 461541Srgrimes char id[ISODCL(2,6)]; 471541Srgrimes char version[ISODCL(7,7)]; 485651Sjoerg char unused[ISODCL(8,8)]; 495651Sjoerg char type_sierra[ISODCL(9,9)]; /* 711 */ 505651Sjoerg char id_sierra[ISODCL(10,14)]; 515651Sjoerg char version_sierra[ISODCL(15,15)]; 525651Sjoerg char data[ISODCL(16,2048)]; 531541Srgrimes}; 541541Srgrimes 551541Srgrimes/* volume descriptor types */ 561541Srgrimes#define ISO_VD_PRIMARY 1 571541Srgrimes#define ISO_VD_END 255 581541Srgrimes 591541Srgrimes#define ISO_STANDARD_ID "CD001" 605651Sjoerg#define ISO_ECMA_ID "CDW01" 611541Srgrimes 625651Sjoerg#define ISO_SIERRA_ID "CDROM" 635651Sjoerg 641541Srgrimesstruct iso_primary_descriptor { 655651Sjoerg char type [ISODCL ( 1, 1)]; /* 711 */ 665651Sjoerg char id [ISODCL ( 2, 6)]; 675651Sjoerg char version [ISODCL ( 7, 7)]; /* 711 */ 685651Sjoerg char unused1 [ISODCL ( 8, 8)]; 691541Srgrimes char system_id [ISODCL ( 9, 40)]; /* achars */ 701541Srgrimes char volume_id [ISODCL ( 41, 72)]; /* dchars */ 711541Srgrimes char unused2 [ISODCL ( 73, 80)]; 721541Srgrimes char volume_space_size [ISODCL ( 81, 88)]; /* 733 */ 731541Srgrimes char unused3 [ISODCL ( 89, 120)]; 741541Srgrimes char volume_set_size [ISODCL (121, 124)]; /* 723 */ 751541Srgrimes char volume_sequence_number [ISODCL (125, 128)]; /* 723 */ 761541Srgrimes char logical_block_size [ISODCL (129, 132)]; /* 723 */ 771541Srgrimes char path_table_size [ISODCL (133, 140)]; /* 733 */ 781541Srgrimes char type_l_path_table [ISODCL (141, 144)]; /* 731 */ 791541Srgrimes char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */ 801541Srgrimes char type_m_path_table [ISODCL (149, 152)]; /* 732 */ 811541Srgrimes char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */ 821541Srgrimes char root_directory_record [ISODCL (157, 190)]; /* 9.1 */ 831541Srgrimes char volume_set_id [ISODCL (191, 318)]; /* dchars */ 841541Srgrimes char publisher_id [ISODCL (319, 446)]; /* achars */ 851541Srgrimes char preparer_id [ISODCL (447, 574)]; /* achars */ 861541Srgrimes char application_id [ISODCL (575, 702)]; /* achars */ 871541Srgrimes char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */ 881541Srgrimes char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */ 891541Srgrimes char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */ 901541Srgrimes char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */ 911541Srgrimes char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */ 921541Srgrimes char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */ 931541Srgrimes char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */ 941541Srgrimes char file_structure_version [ISODCL (882, 882)]; /* 711 */ 951541Srgrimes char unused4 [ISODCL (883, 883)]; 961541Srgrimes char application_data [ISODCL (884, 1395)]; 971541Srgrimes char unused5 [ISODCL (1396, 2048)]; 981541Srgrimes}; 991541Srgrimes#define ISO_DEFAULT_BLOCK_SIZE 2048 1001541Srgrimes 1015651Sjoergstruct iso_sierra_primary_descriptor { 1025651Sjoerg char unknown1 [ISODCL ( 1, 8)]; /* 733 */ 1035651Sjoerg char type [ISODCL ( 9, 9)]; /* 711 */ 1045651Sjoerg char id [ISODCL ( 10, 14)]; 1055651Sjoerg char version [ISODCL ( 15, 15)]; /* 711 */ 1065651Sjoerg char unused1 [ISODCL ( 16, 16)]; 1075651Sjoerg char system_id [ISODCL ( 17, 48)]; /* achars */ 1085651Sjoerg char volume_id [ISODCL ( 49, 80)]; /* dchars */ 1095651Sjoerg char unused2 [ISODCL ( 81, 88)]; 1105651Sjoerg char volume_space_size [ISODCL ( 89, 96)]; /* 733 */ 1115651Sjoerg char unused3 [ISODCL ( 97, 128)]; 1125651Sjoerg char volume_set_size [ISODCL (129, 132)]; /* 723 */ 1135651Sjoerg char volume_sequence_number [ISODCL (133, 136)]; /* 723 */ 1145651Sjoerg char logical_block_size [ISODCL (137, 140)]; /* 723 */ 1155651Sjoerg char path_table_size [ISODCL (141, 148)]; /* 733 */ 1165651Sjoerg char type_l_path_table [ISODCL (149, 152)]; /* 731 */ 1175651Sjoerg char opt_type_l_path_table [ISODCL (153, 156)]; /* 731 */ 1185651Sjoerg char unknown2 [ISODCL (157, 160)]; /* 731 */ 1195651Sjoerg char unknown3 [ISODCL (161, 164)]; /* 731 */ 1205651Sjoerg char type_m_path_table [ISODCL (165, 168)]; /* 732 */ 1215651Sjoerg char opt_type_m_path_table [ISODCL (169, 172)]; /* 732 */ 1225651Sjoerg char unknown4 [ISODCL (173, 176)]; /* 732 */ 1235651Sjoerg char unknown5 [ISODCL (177, 180)]; /* 732 */ 1245651Sjoerg char root_directory_record [ISODCL (181, 214)]; /* 9.1 */ 1255651Sjoerg char volume_set_id [ISODCL (215, 342)]; /* dchars */ 1265651Sjoerg char publisher_id [ISODCL (343, 470)]; /* achars */ 1275651Sjoerg char preparer_id [ISODCL (471, 598)]; /* achars */ 1285651Sjoerg char application_id [ISODCL (599, 726)]; /* achars */ 1295651Sjoerg char copyright_id [ISODCL (727, 790)]; /* achars */ 1305651Sjoerg char creation_date [ISODCL (791, 806)]; /* ? */ 1315651Sjoerg char modification_date [ISODCL (807, 822)]; /* ? */ 1325651Sjoerg char expiration_date [ISODCL (823, 838)]; /* ? */ 1335651Sjoerg char effective_date [ISODCL (839, 854)]; /* ? */ 1345651Sjoerg char file_structure_version [ISODCL (855, 855)]; /* 711 */ 1355651Sjoerg char unused4 [ISODCL (856, 2048)]; 1365651Sjoerg}; 1375651Sjoerg 1381541Srgrimesstruct iso_directory_record { 1391541Srgrimes char length [ISODCL (1, 1)]; /* 711 */ 1401541Srgrimes char ext_attr_length [ISODCL (2, 2)]; /* 711 */ 14122521Sdyson u_char extent [ISODCL (3, 10)]; /* 733 */ 14222521Sdyson u_char size [ISODCL (11, 18)]; /* 733 */ 1431541Srgrimes char date [ISODCL (19, 25)]; /* 7 by 711 */ 1441541Srgrimes char flags [ISODCL (26, 26)]; 1451541Srgrimes char file_unit_size [ISODCL (27, 27)]; /* 711 */ 1461541Srgrimes char interleave [ISODCL (28, 28)]; /* 711 */ 1471541Srgrimes char volume_sequence_number [ISODCL (29, 32)]; /* 723 */ 1481541Srgrimes char name_len [ISODCL (33, 33)]; /* 711 */ 14922521Sdyson char name [1]; /* XXX */ 1501541Srgrimes}; 1511541Srgrimes/* can't take sizeof(iso_directory_record), because of possible alignment 1521541Srgrimes of the last entry (34 instead of 33) */ 1531541Srgrimes#define ISO_DIRECTORY_RECORD_SIZE 33 1541541Srgrimes 1551541Srgrimesstruct iso_extended_attributes { 15622521Sdyson u_char owner [ISODCL (1, 4)]; /* 723 */ 15722521Sdyson u_char group [ISODCL (5, 8)]; /* 723 */ 15822521Sdyson u_char perm [ISODCL (9, 10)]; /* 9.5.3 */ 1591541Srgrimes char ctime [ISODCL (11, 27)]; /* 8.4.26.1 */ 1601541Srgrimes char mtime [ISODCL (28, 44)]; /* 8.4.26.1 */ 1611541Srgrimes char xtime [ISODCL (45, 61)]; /* 8.4.26.1 */ 1621541Srgrimes char ftime [ISODCL (62, 78)]; /* 8.4.26.1 */ 1631541Srgrimes char recfmt [ISODCL (79, 79)]; /* 711 */ 1641541Srgrimes char recattr [ISODCL (80, 80)]; /* 711 */ 16522521Sdyson u_char reclen [ISODCL (81, 84)]; /* 723 */ 1661541Srgrimes char system_id [ISODCL (85, 116)]; /* achars */ 1671541Srgrimes char system_use [ISODCL (117, 180)]; 1681541Srgrimes char version [ISODCL (181, 181)]; /* 711 */ 1691541Srgrimes char len_esc [ISODCL (182, 182)]; /* 711 */ 1701541Srgrimes char reserved [ISODCL (183, 246)]; 17122521Sdyson u_char len_au [ISODCL (247, 250)]; /* 723 */ 1721541Srgrimes}; 1731541Srgrimes 17425531Sjoerg#ifdef KERNEL 17525531Sjoerg 1761541Srgrimes/* CD-ROM Format type */ 1775651Sjoergenum ISO_FTYPE { ISO_FTYPE_DEFAULT, ISO_FTYPE_9660, ISO_FTYPE_RRIP, 1785651Sjoerg ISO_FTYPE_ECMA, ISO_FTYPE_HIGH_SIERRA }; 1791541Srgrimes 1801541Srgrimes#ifndef ISOFSMNT_ROOT 1811541Srgrimes#define ISOFSMNT_ROOT 0 1821541Srgrimes#endif 1831541Srgrimes 1841541Srgrimesstruct iso_mnt { 1851541Srgrimes int im_flags; 1861541Srgrimes 1871541Srgrimes struct mount *im_mountp; 1881541Srgrimes dev_t im_dev; 1891541Srgrimes struct vnode *im_devvp; 1901541Srgrimes 1911541Srgrimes int logical_block_size; 1921541Srgrimes int im_bshift; 1931541Srgrimes int im_bmask; 1948876Srgrimes 1951541Srgrimes int volume_space_size; 1961541Srgrimes struct netexport im_export; 1978876Srgrimes 1981541Srgrimes char root[ISODCL (157, 190)]; 1991541Srgrimes int root_extent; 2001541Srgrimes int root_size; 2015651Sjoerg enum ISO_FTYPE iso_ftype; 2028876Srgrimes 2031541Srgrimes int rr_skip; 2041541Srgrimes int rr_skip0; 2051541Srgrimes}; 2061541Srgrimes 2071541Srgrimes#define VFSTOISOFS(mp) ((struct iso_mnt *)((mp)->mnt_data)) 2081541Srgrimes 20922521Sdyson#define blkoff(imp, loc) ((loc) & (imp)->im_bmask) 21022521Sdyson#define lblktosize(imp, blk) ((blk) << (imp)->im_bshift) 21122521Sdyson#define lblkno(imp, loc) ((loc) >> (imp)->im_bshift) 21222521Sdyson#define blksize(imp, ip, lbn) ((imp)->logical_block_size) 2131541Srgrimes 21422521Sdysonint cd9660_vget_internal __P((struct mount *, ino_t, struct vnode **, int, 21522521Sdyson struct iso_directory_record *)); 21622521Sdysonint cd9660_init __P((struct vfsconf *)); 21722521Sdyson#define cd9660_sysctl ((int (*) __P((int *, u_int, void *, size_t *, void *, \ 21822521Sdyson size_t, struct proc *)))eopnotsupp) 2191541Srgrimes 22012158Sbdeextern vop_t **cd9660_vnodeop_p; 22122521Sdysonextern vop_t **cd9660_specop_p; 22222521Sdysonextern vop_t **cd9660_fifoop_p; 2231541Srgrimes 22425531Sjoergint isofncmp __P((u_char *, int, u_char *, int)); 22525531Sjoergvoid isofntrans __P((u_char *, int, u_char *, u_short *, int, int)); 22625531Sjoergino_t isodirino __P((struct iso_directory_record *, struct iso_mnt *)); 22725531Sjoerg 22825531Sjoerg#endif /* KERNEL */ 22925531Sjoerg 23025531Sjoerg/* 23125531Sjoerg * The isonum_xxx functions are inlined anyway, and could come handy even 23225531Sjoerg * outside the kernel. Thus we don't hide them here. 23325531Sjoerg */ 23425531Sjoerg 23522521Sdysonstatic __inline int isonum_711 __P((u_char *)); 23622521Sdysonstatic __inline int 2371541Srgrimesisonum_711(p) 23822521Sdyson u_char *p; 2391541Srgrimes{ 2401541Srgrimes return *p; 2411541Srgrimes} 2421541Srgrimes 24322521Sdysonstatic __inline int isonum_712 __P((char *)); 24422521Sdysonstatic __inline int 2451541Srgrimesisonum_712(p) 2461541Srgrimes char *p; 2471541Srgrimes{ 2481541Srgrimes return *p; 2491541Srgrimes} 2501541Srgrimes 25122521Sdyson#ifndef UNALIGNED_ACCESS 25222521Sdyson 25322521Sdysonstatic __inline int isonum_723 __P((u_char *)); 25422521Sdysonstatic __inline int 25522521Sdysonisonum_723(p) 25622521Sdyson u_char *p; 2571541Srgrimes{ 25822521Sdyson return *p|(p[1] << 8); 2591541Srgrimes} 2601541Srgrimes 26122521Sdysonstatic __inline int isonum_733 __P((u_char *)); 26222521Sdysonstatic __inline int 26322521Sdysonisonum_733(p) 26422521Sdyson u_char *p; 2651541Srgrimes{ 26622521Sdyson return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24); 2671541Srgrimes} 2681541Srgrimes 26922521Sdyson#else /* UNALIGNED_ACCESS */ 27022521Sdyson 27122521Sdyson#if BYTE_ORDER == LITTLE_ENDIAN 27222521Sdyson 27322521Sdysonstatic __inline int 2741541Srgrimesisonum_723(p) 27522521Sdyson u_char *p 2761541Srgrimes{ 27722521Sdyson return *(u_int16t *)p; 2781541Srgrimes} 2791541Srgrimes 28022521Sdysonstatic __inline int 28122521Sdysonisonum_733(p) 28222521Sdyson u_char *p; 2831541Srgrimes{ 28422521Sdyson return *(u_int32t *)p; 2851541Srgrimes} 2861541Srgrimes 28722521Sdyson#endif 28822521Sdyson 28922521Sdyson#if BYTE_ORDER == BIG_ENDIAN 29022521Sdyson 29122521Sdysonstatic __inline int 29222521Sdysonisonum_723(p) 29322521Sdyson u_char *p 2941541Srgrimes{ 29522521Sdyson return *(u_int16t *)(p + 2); 2961541Srgrimes} 2971541Srgrimes 29822521Sdysonstatic __inline int 2991541Srgrimesisonum_733(p) 30022521Sdyson u_char *p; 3011541Srgrimes{ 30222521Sdyson return *(u_int32t *)(p + 4); 3031541Srgrimes} 3041541Srgrimes 30522521Sdyson#endif 3061541Srgrimes 30722521Sdyson#endif /* UNALIGNED_ACCESS */ 30822521Sdyson 3091541Srgrimes/* 3101541Srgrimes * Associated files have a leading '='. 3111541Srgrimes */ 3121541Srgrimes#define ASSOCCHAR '=' 313