1 /*- 2 * Copyright (c) 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley 6 * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension 7 * Support code is derived from software contributed to Berkeley 8 * by Atsushi Murai (amurai@spec.co.jp). 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the University of 21 * California, Berkeley and its contributors. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)iso.h 8.2 (Berkeley) 1/23/94 39 * $Id$ 40 */ 41 42 #define ISODCL(from, to) (to - from + 1) 43 44 struct iso_volume_descriptor { 45 char type[ISODCL(1,1)]; /* 711 */ 46 char id[ISODCL(2,6)]; 47 char version[ISODCL(7,7)]; 48 char data[ISODCL(8,2048)]; 49 }; 50 51 /* volume descriptor types */ 52 #define ISO_VD_PRIMARY 1 53 #define ISO_VD_END 255 54 55 #define ISO_STANDARD_ID "CD001" 56 #define ISO_ECMA_ID "CDW01" 57 58 struct iso_primary_descriptor { 59 char type [ISODCL ( 1, 1)]; /* 711 */ 60 char id [ISODCL ( 2, 6)]; 61 char version [ISODCL ( 7, 7)]; /* 711 */ 62 char unused1 [ISODCL ( 8, 8)]; 63 char system_id [ISODCL ( 9, 40)]; /* achars */ 64 char volume_id [ISODCL ( 41, 72)]; /* dchars */ 65 char unused2 [ISODCL ( 73, 80)]; 66 char volume_space_size [ISODCL ( 81, 88)]; /* 733 */ 67 char unused3 [ISODCL ( 89, 120)]; 68 char volume_set_size [ISODCL (121, 124)]; /* 723 */ 69 char volume_sequence_number [ISODCL (125, 128)]; /* 723 */ 70 char logical_block_size [ISODCL (129, 132)]; /* 723 */ 71 char path_table_size [ISODCL (133, 140)]; /* 733 */ 72 char type_l_path_table [ISODCL (141, 144)]; /* 731 */ 73 char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */ 74 char type_m_path_table [ISODCL (149, 152)]; /* 732 */ 75 char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */ 76 char root_directory_record [ISODCL (157, 190)]; /* 9.1 */ 77 char volume_set_id [ISODCL (191, 318)]; /* dchars */ 78 char publisher_id [ISODCL (319, 446)]; /* achars */ 79 char preparer_id [ISODCL (447, 574)]; /* achars */ 80 char application_id [ISODCL (575, 702)]; /* achars */ 81 char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */ 82 char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */ 83 char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */ 84 char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */ 85 char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */ 86 char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */ 87 char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */ 88 char file_structure_version [ISODCL (882, 882)]; /* 711 */ 89 char unused4 [ISODCL (883, 883)]; 90 char application_data [ISODCL (884, 1395)]; 91 char unused5 [ISODCL (1396, 2048)]; 92 }; 93 #define ISO_DEFAULT_BLOCK_SIZE 2048 94 95 struct iso_directory_record { 96 char length [ISODCL (1, 1)]; /* 711 */ 97 char ext_attr_length [ISODCL (2, 2)]; /* 711 */ 98 unsigned char extent [ISODCL (3, 10)]; /* 733 */ 99 unsigned char size [ISODCL (11, 18)]; /* 733 */ 100 char date [ISODCL (19, 25)]; /* 7 by 711 */ 101 char flags [ISODCL (26, 26)]; 102 char file_unit_size [ISODCL (27, 27)]; /* 711 */ 103 char interleave [ISODCL (28, 28)]; /* 711 */ 104 char volume_sequence_number [ISODCL (29, 32)]; /* 723 */ 105 char name_len [ISODCL (33, 33)]; /* 711 */ 106 char name [0]; 107 }; 108 /* can't take sizeof(iso_directory_record), because of possible alignment 109 of the last entry (34 instead of 33) */ 110 #define ISO_DIRECTORY_RECORD_SIZE 33 111 112 struct iso_extended_attributes { 113 unsigned char owner [ISODCL (1, 4)]; /* 723 */ 114 unsigned char group [ISODCL (5, 8)]; /* 723 */ 115 unsigned char perm [ISODCL (9, 10)]; /* 9.5.3 */ 116 char ctime [ISODCL (11, 27)]; /* 8.4.26.1 */ 117 char mtime [ISODCL (28, 44)]; /* 8.4.26.1 */ 118 char xtime [ISODCL (45, 61)]; /* 8.4.26.1 */ 119 char ftime [ISODCL (62, 78)]; /* 8.4.26.1 */ 120 char recfmt [ISODCL (79, 79)]; /* 711 */ 121 char recattr [ISODCL (80, 80)]; /* 711 */ 122 unsigned char reclen [ISODCL (81, 84)]; /* 723 */ 123 char system_id [ISODCL (85, 116)]; /* achars */ 124 char system_use [ISODCL (117, 180)]; 125 char version [ISODCL (181, 181)]; /* 711 */ 126 char len_esc [ISODCL (182, 182)]; /* 711 */ 127 char reserved [ISODCL (183, 246)]; 128 unsigned char len_au [ISODCL (247, 250)]; /* 723 */ 129 }; 130 131 /* CD-ROM Format type */ 132 enum ISO_FTYPE { ISO_FTYPE_DEFAULT, ISO_FTYPE_9660, ISO_FTYPE_RRIP, ISO_FTYPE_ECMA }; 133 134 #ifndef ISOFSMNT_ROOT 135 #define ISOFSMNT_ROOT 0 136 #endif 137 138 struct iso_mnt { 139 int im_flags; 140 141 struct mount *im_mountp; 142 dev_t im_dev; 143 struct vnode *im_devvp; 144 145 int logical_block_size; 146 int im_bshift; 147 int im_bmask; 148 149 int volume_space_size; 150 char im_fsmnt[50]; 151 struct netexport im_export; 152 153 char root[ISODCL (157, 190)]; 154 int root_extent; 155 int root_size; 156 enum ISO_FTYPE iso_ftype; 157 158 int rr_skip; 159 int rr_skip0; 160 }; 161 162 #define VFSTOISOFS(mp) ((struct iso_mnt *)((mp)->mnt_data)) 163 164 #define iso_blkoff(imp, loc) ((loc) & (imp)->im_bmask) 165 #define iso_lblkno(imp, loc) ((loc) >> (imp)->im_bshift) 166 #define iso_blksize(imp, ip, lbn) ((imp)->logical_block_size) 167 #define iso_lblktosize(imp, blk) ((blk) << (imp)->im_bshift) 168 169 int cd9660_mount __P((struct mount *, 170 char *, caddr_t, struct nameidata *, struct proc *)); 171 int cd9660_start __P((struct mount *, int, struct proc *)); 172 int cd9660_unmount __P((struct mount *, int, struct proc *)); 173 int cd9660_root __P((struct mount *, struct vnode **)); 174 int cd9660_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *)); 175 int cd9660_statfs __P((struct mount *, struct statfs *, struct proc *)); 176 int cd9660_sync __P((struct mount *, int, struct ucred *, struct proc *)); 177 int cd9660_vget __P((struct mount *, ino_t, struct vnode **)); 178 int cd9660_fhtovp __P((struct mount *, struct fid *, struct mbuf *, 179 struct vnode **, int *, struct ucred **)); 180 int cd9660_vptofh __P((struct vnode *, struct fid *)); 181 int cd9660_init __P(()); 182 183 struct iso_node; 184 int iso_blkatoff __P((struct iso_node *ip, long offset, struct buf **bpp)); 185 int iso_iget __P((struct iso_node *xp, ino_t ino, int relocated, 186 struct iso_node **ipp, struct iso_directory_record *isodir)); 187 int iso_iput __P((struct iso_node *ip)); 188 int iso_ilock __P((struct iso_node *ip)); 189 int iso_iunlock __P((struct iso_node *ip)); 190 int cd9660_mountroot __P((void)); 191 192 extern int (**cd9660_vnodeop_p)(); 193 194 extern inline int 195 isonum_711(p) 196 unsigned char *p; 197 { 198 return *p; 199 } 200 201 extern inline int 202 isonum_712(p) 203 char *p; 204 { 205 return *p; 206 } 207 208 extern inline int 209 isonum_721(p) 210 unsigned char *p; 211 { 212 return *p|((char)p[1] << 8); 213 } 214 215 extern inline int 216 isonum_722(p) 217 unsigned char *p; 218 { 219 return ((char)*p << 8)|p[1]; 220 } 221 222 extern inline int 223 isonum_723(p) 224 unsigned char *p; 225 { 226 return isonum_721(p); 227 } 228 229 extern inline int 230 isonum_731(p) 231 unsigned char *p; 232 { 233 return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24); 234 } 235 236 extern inline int 237 isonum_732(p) 238 unsigned char *p; 239 { 240 return (*p << 24)|(p[1] << 16)|(p[2] << 8)|p[3]; 241 } 242 243 extern inline int 244 isonum_733(p) 245 unsigned char *p; 246 { 247 return isonum_731(p); 248 } 249 250 int isofncmp __P((unsigned char *, int, unsigned char *, int)); 251 void isofntrans __P((unsigned char *, int, unsigned char *, unsigned short *, 252 int, int)); 253 254 /* 255 * Associated files have a leading '='. 256 */ 257 #define ASSOCCHAR '=' 258