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: iso.h,v 1.2 1994/08/02 07:41:38 davidg Exp $ 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 #define iso_lblktodaddr(imp, lbn) btodb(iso_lblktosize(imp, lbn)) 169 #define iso_dblkinc(imp, lbn) ((lbn) + iso_lblktodaddr(imp, 1)) 170 #define iso_dblkno(imp, loc) iso_lblktodaddr(imp, iso_lblkno(imp, loc)) 171 172 int cd9660_mount __P((struct mount *, 173 char *, caddr_t, struct nameidata *, struct proc *)); 174 int cd9660_start __P((struct mount *, int, struct proc *)); 175 int cd9660_unmount __P((struct mount *, int, struct proc *)); 176 int cd9660_root __P((struct mount *, struct vnode **)); 177 int cd9660_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *)); 178 int cd9660_statfs __P((struct mount *, struct statfs *, struct proc *)); 179 int cd9660_sync __P((struct mount *, int, struct ucred *, struct proc *)); 180 int cd9660_vget __P((struct mount *, ino_t, struct vnode **)); 181 int cd9660_fhtovp __P((struct mount *, struct fid *, struct mbuf *, 182 struct vnode **, int *, struct ucred **)); 183 int cd9660_vptofh __P((struct vnode *, struct fid *)); 184 int cd9660_init __P(()); 185 186 struct iso_node; 187 int iso_blkatoff __P((struct iso_node *ip, long offset, struct buf **bpp)); 188 int iso_iget __P((struct iso_node *xp, ino_t ino, int relocated, 189 struct iso_node **ipp, struct iso_directory_record *isodir)); 190 int iso_iput __P((struct iso_node *ip)); 191 int iso_ilock __P((struct iso_node *ip)); 192 int iso_iunlock __P((struct iso_node *ip)); 193 int cd9660_mountroot __P((void)); 194 195 extern int (**cd9660_vnodeop_p)(); 196 197 extern inline int 198 isonum_711(p) 199 unsigned char *p; 200 { 201 return *p; 202 } 203 204 extern inline int 205 isonum_712(p) 206 char *p; 207 { 208 return *p; 209 } 210 211 extern inline int 212 isonum_721(p) 213 unsigned char *p; 214 { 215 return *p|((char)p[1] << 8); 216 } 217 218 extern inline int 219 isonum_722(p) 220 unsigned char *p; 221 { 222 return ((char)*p << 8)|p[1]; 223 } 224 225 extern inline int 226 isonum_723(p) 227 unsigned char *p; 228 { 229 return isonum_721(p); 230 } 231 232 extern inline int 233 isonum_731(p) 234 unsigned char *p; 235 { 236 return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24); 237 } 238 239 extern inline int 240 isonum_732(p) 241 unsigned char *p; 242 { 243 return (*p << 24)|(p[1] << 16)|(p[2] << 8)|p[3]; 244 } 245 246 extern inline int 247 isonum_733(p) 248 unsigned char *p; 249 { 250 return isonum_731(p); 251 } 252 253 int isofncmp __P((unsigned char *, int, unsigned char *, int)); 254 void isofntrans __P((unsigned char *, int, unsigned char *, unsigned short *, 255 int, int)); 256 257 /* 258 * Associated files have a leading '='. 259 */ 260 #define ASSOCCHAR '=' 261