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 * %sccs.include.redist.c% 11 * 12 * @(#)iso.h 8.2 (Berkeley) 01/23/94 13 */ 14 15 #define ISODCL(from, to) (to - from + 1) 16 17 struct iso_volume_descriptor { 18 char type[ISODCL(1,1)]; /* 711 */ 19 char id[ISODCL(2,6)]; 20 char version[ISODCL(7,7)]; 21 char data[ISODCL(8,2048)]; 22 }; 23 24 /* volume descriptor types */ 25 #define ISO_VD_PRIMARY 1 26 #define ISO_VD_END 255 27 28 #define ISO_STANDARD_ID "CD001" 29 #define ISO_ECMA_ID "CDW01" 30 31 struct iso_primary_descriptor { 32 char type [ISODCL ( 1, 1)]; /* 711 */ 33 char id [ISODCL ( 2, 6)]; 34 char version [ISODCL ( 7, 7)]; /* 711 */ 35 char unused1 [ISODCL ( 8, 8)]; 36 char system_id [ISODCL ( 9, 40)]; /* achars */ 37 char volume_id [ISODCL ( 41, 72)]; /* dchars */ 38 char unused2 [ISODCL ( 73, 80)]; 39 char volume_space_size [ISODCL ( 81, 88)]; /* 733 */ 40 char unused3 [ISODCL ( 89, 120)]; 41 char volume_set_size [ISODCL (121, 124)]; /* 723 */ 42 char volume_sequence_number [ISODCL (125, 128)]; /* 723 */ 43 char logical_block_size [ISODCL (129, 132)]; /* 723 */ 44 char path_table_size [ISODCL (133, 140)]; /* 733 */ 45 char type_l_path_table [ISODCL (141, 144)]; /* 731 */ 46 char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */ 47 char type_m_path_table [ISODCL (149, 152)]; /* 732 */ 48 char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */ 49 char root_directory_record [ISODCL (157, 190)]; /* 9.1 */ 50 char volume_set_id [ISODCL (191, 318)]; /* dchars */ 51 char publisher_id [ISODCL (319, 446)]; /* achars */ 52 char preparer_id [ISODCL (447, 574)]; /* achars */ 53 char application_id [ISODCL (575, 702)]; /* achars */ 54 char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */ 55 char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */ 56 char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */ 57 char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */ 58 char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */ 59 char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */ 60 char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */ 61 char file_structure_version [ISODCL (882, 882)]; /* 711 */ 62 char unused4 [ISODCL (883, 883)]; 63 char application_data [ISODCL (884, 1395)]; 64 char unused5 [ISODCL (1396, 2048)]; 65 }; 66 #define ISO_DEFAULT_BLOCK_SIZE 2048 67 68 struct iso_directory_record { 69 char length [ISODCL (1, 1)]; /* 711 */ 70 char ext_attr_length [ISODCL (2, 2)]; /* 711 */ 71 unsigned char extent [ISODCL (3, 10)]; /* 733 */ 72 unsigned char size [ISODCL (11, 18)]; /* 733 */ 73 char date [ISODCL (19, 25)]; /* 7 by 711 */ 74 char flags [ISODCL (26, 26)]; 75 char file_unit_size [ISODCL (27, 27)]; /* 711 */ 76 char interleave [ISODCL (28, 28)]; /* 711 */ 77 char volume_sequence_number [ISODCL (29, 32)]; /* 723 */ 78 char name_len [ISODCL (33, 33)]; /* 711 */ 79 char name [0]; 80 }; 81 /* can't take sizeof(iso_directory_record), because of possible alignment 82 of the last entry (34 instead of 33) */ 83 #define ISO_DIRECTORY_RECORD_SIZE 33 84 85 struct iso_extended_attributes { 86 unsigned char owner [ISODCL (1, 4)]; /* 723 */ 87 unsigned char group [ISODCL (5, 8)]; /* 723 */ 88 unsigned char perm [ISODCL (9, 10)]; /* 9.5.3 */ 89 char ctime [ISODCL (11, 27)]; /* 8.4.26.1 */ 90 char mtime [ISODCL (28, 44)]; /* 8.4.26.1 */ 91 char xtime [ISODCL (45, 61)]; /* 8.4.26.1 */ 92 char ftime [ISODCL (62, 78)]; /* 8.4.26.1 */ 93 char recfmt [ISODCL (79, 79)]; /* 711 */ 94 char recattr [ISODCL (80, 80)]; /* 711 */ 95 unsigned char reclen [ISODCL (81, 84)]; /* 723 */ 96 char system_id [ISODCL (85, 116)]; /* achars */ 97 char system_use [ISODCL (117, 180)]; 98 char version [ISODCL (181, 181)]; /* 711 */ 99 char len_esc [ISODCL (182, 182)]; /* 711 */ 100 char reserved [ISODCL (183, 246)]; 101 unsigned char len_au [ISODCL (247, 250)]; /* 723 */ 102 }; 103 104 /* CD-ROM Format type */ 105 enum ISO_FTYPE { ISO_FTYPE_DEFAULT, ISO_FTYPE_9660, ISO_FTYPE_RRIP, ISO_FTYPE_ECMA }; 106 107 #ifndef ISOFSMNT_ROOT 108 #define ISOFSMNT_ROOT 0 109 #endif 110 111 struct iso_mnt { 112 int im_flags; 113 114 struct mount *im_mountp; 115 dev_t im_dev; 116 struct vnode *im_devvp; 117 118 int logical_block_size; 119 int im_bshift; 120 int im_bmask; 121 122 int volume_space_size; 123 char im_fsmnt[50]; 124 struct netexport im_export; 125 126 char root[ISODCL (157, 190)]; 127 int root_extent; 128 int root_size; 129 enum ISO_FTYPE iso_ftype; 130 131 int rr_skip; 132 int rr_skip0; 133 }; 134 135 #define VFSTOISOFS(mp) ((struct iso_mnt *)((mp)->mnt_data)) 136 137 #define iso_blkoff(imp, loc) ((loc) & (imp)->im_bmask) 138 #define iso_lblkno(imp, loc) ((loc) >> (imp)->im_bshift) 139 #define iso_blksize(imp, ip, lbn) ((imp)->logical_block_size) 140 #define iso_lblktosize(imp, blk) ((blk) << (imp)->im_bshift) 141 142 int cd9660_mount __P((struct mount *, 143 char *, caddr_t, struct nameidata *, struct proc *)); 144 int cd9660_start __P((struct mount *, int, struct proc *)); 145 int cd9660_unmount __P((struct mount *, int, struct proc *)); 146 int cd9660_root __P((struct mount *, struct vnode **)); 147 int cd9660_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *)); 148 int cd9660_statfs __P((struct mount *, struct statfs *, struct proc *)); 149 int cd9660_sync __P((struct mount *, int, struct ucred *, struct proc *)); 150 int cd9660_vget __P((struct mount *, ino_t, struct vnode **)); 151 int cd9660_fhtovp __P((struct mount *, struct fid *, struct mbuf *, 152 struct vnode **, int *, struct ucred **)); 153 int cd9660_vptofh __P((struct vnode *, struct fid *)); 154 int cd9660_init __P(()); 155 156 struct iso_node; 157 int iso_blkatoff __P((struct iso_node *ip, long offset, struct buf **bpp)); 158 int iso_iget __P((struct iso_node *xp, ino_t ino, int relocated, 159 struct iso_node **ipp, struct iso_directory_record *isodir)); 160 int iso_iput __P((struct iso_node *ip)); 161 int iso_ilock __P((struct iso_node *ip)); 162 int iso_iunlock __P((struct iso_node *ip)); 163 int cd9660_mountroot __P((void)); 164 165 extern int (**cd9660_vnodeop_p)(); 166 167 extern inline int 168 isonum_711(p) 169 unsigned char *p; 170 { 171 return *p; 172 } 173 174 extern inline int 175 isonum_712(p) 176 char *p; 177 { 178 return *p; 179 } 180 181 extern inline int 182 isonum_721(p) 183 unsigned char *p; 184 { 185 return *p|((char)p[1] << 8); 186 } 187 188 extern inline int 189 isonum_722(p) 190 unsigned char *p; 191 { 192 return ((char)*p << 8)|p[1]; 193 } 194 195 extern inline int 196 isonum_723(p) 197 unsigned char *p; 198 { 199 return isonum_721(p); 200 } 201 202 extern inline int 203 isonum_731(p) 204 unsigned char *p; 205 { 206 return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24); 207 } 208 209 extern inline int 210 isonum_732(p) 211 unsigned char *p; 212 { 213 return (*p << 24)|(p[1] << 16)|(p[2] << 8)|p[3]; 214 } 215 216 extern inline int 217 isonum_733(p) 218 unsigned char *p; 219 { 220 return isonum_731(p); 221 } 222 223 int isofncmp __P((unsigned char *, int, unsigned char *, int)); 224 void isofntrans __P((unsigned char *, int, unsigned char *, unsigned short *, 225 int, int)); 226 227 /* 228 * Associated files have a leading '='. 229 */ 230 #define ASSOCCHAR '=' 231