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