1 /* @(#)iso9660.h 1.22 11/06/04 joerg */ 2 /* 3 * Header file iso9660.h - assorted structure definitions and typecasts. 4 * specific to iso9660 filesystem. 5 * 6 * Written by Eric Youngdale (1993). 7 * 8 * Copyright 1993 Yggdrasil Computing, Incorporated 9 * Copyright (c) 1999,2000-2007 J. Schilling 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2, or (at your option) 14 * any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program; if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 */ 25 #ifndef _ISOFS_FS_H 26 #define _ISOFS_FS_H 27 28 /* 29 * The isofs filesystem constants/structures 30 */ 31 32 /* This part borrowed from the bsd386 isofs */ 33 #define ISODCL(from, to) (to - from + 1) 34 35 struct iso_volume_descriptor { 36 char type [ISODCL(1, 1)]; /* 711 */ 37 char id [ISODCL(2, 6)]; 38 char version [ISODCL(7, 7)]; 39 char data [ISODCL(8, 2048)]; 40 }; 41 42 /* volume descriptor types */ 43 #define ISO_VD_PRIMARY 1 44 #define ISO_VD_SUPPLEMENTARY 2 /* Used by Joliet */ 45 #define ISO_VD_END 255 46 47 #define ISO_STANDARD_ID "CD001" 48 49 #define EL_TORITO_ID "EL TORITO SPECIFICATION" 50 #define EL_TORITO_ARCH_x86 0 51 #define EL_TORITO_ARCH_PPC 1 52 #define EL_TORITO_ARCH_MAC 2 53 #define EL_TORITO_ARCH_EFI 0xEF 54 55 #define EL_TORITO_BOOTABLE 0x88 56 #define EL_TORITO_NOT_BOOTABLE 0 57 58 #define EL_TORITO_MEDIA_NOEMUL 0 59 #define EL_TORITO_MEDIA_12FLOP 1 60 #define EL_TORITO_MEDIA_144FLOP 2 61 #define EL_TORITO_MEDIA_288FLOP 3 62 #define EL_TORITO_MEDIA_HD 4 63 64 struct iso_primary_descriptor { 65 char type [ISODCL(1, 1)]; /* 711 */ 66 char id [ISODCL(2, 6)]; 67 char version [ISODCL(7, 7)]; /* 711 */ 68 char unused1 [ISODCL(8, 8)]; 69 char system_id [ISODCL(9, 40)]; /* achars */ 70 char volume_id [ISODCL(41, 72)]; /* dchars */ 71 char unused2 [ISODCL(73, 80)]; 72 char volume_space_size [ISODCL(81, 88)]; /* 733 */ 73 char escape_sequences [ISODCL(89, 120)]; 74 char volume_set_size [ISODCL(121, 124)]; /* 723 */ 75 char volume_sequence_number [ISODCL(125, 128)]; /* 723 */ 76 char logical_block_size [ISODCL(129, 132)]; /* 723 */ 77 char path_table_size [ISODCL(133, 140)]; /* 733 */ 78 char type_l_path_table [ISODCL(141, 144)]; /* 731 */ 79 char opt_type_l_path_table [ISODCL(145, 148)]; /* 731 */ 80 char type_m_path_table [ISODCL(149, 152)]; /* 732 */ 81 char opt_type_m_path_table [ISODCL(153, 156)]; /* 732 */ 82 char root_directory_record [ISODCL(157, 190)]; /* 9.1 */ 83 char volume_set_id [ISODCL(191, 318)]; /* dchars */ 84 char publisher_id [ISODCL(319, 446)]; /* achars */ 85 char preparer_id [ISODCL(447, 574)]; /* achars */ 86 char application_id [ISODCL(575, 702)]; /* achars */ 87 char copyright_file_id [ISODCL(703, 739)]; /* 7.5 dchars */ 88 char abstract_file_id [ISODCL(740, 776)]; /* 7.5 dchars */ 89 char bibliographic_file_id [ISODCL(777, 813)]; /* 7.5 dchars */ 90 char creation_date [ISODCL(814, 830)]; /* 8.4.26.1 */ 91 char modification_date [ISODCL(831, 847)]; /* 8.4.26.1 */ 92 char expiration_date [ISODCL(848, 864)]; /* 8.4.26.1 */ 93 char effective_date [ISODCL(865, 881)]; /* 8.4.26.1 */ 94 char file_structure_version [ISODCL(882, 882)]; /* 711 */ 95 char unused4 [ISODCL(883, 883)]; 96 char application_data [ISODCL(884, 1395)]; 97 char unused5 [ISODCL(1396, 2048)]; 98 }; 99 100 /* 101 * Supplementary or enhanced volume descriptor 102 */ 103 struct iso_enhanced_descriptor { 104 char type [ISODCL(1, 1)]; /* 711 */ 105 char id [ISODCL(2, 6)]; 106 char version [ISODCL(7, 7)]; /* 711 */ 107 char flags [ISODCL(8, 8)]; 108 char system_id [ISODCL(9, 40)]; /* achars */ 109 char volume_id [ISODCL(41, 72)]; /* dchars */ 110 char unused2 [ISODCL(73, 80)]; 111 char volume_space_size [ISODCL(81, 88)]; /* 733 */ 112 char escape_sequences [ISODCL(89, 120)]; 113 char volume_set_size [ISODCL(121, 124)]; /* 723 */ 114 char volume_sequence_number [ISODCL(125, 128)]; /* 723 */ 115 char logical_block_size [ISODCL(129, 132)]; /* 723 */ 116 char path_table_size [ISODCL(133, 140)]; /* 733 */ 117 char type_l_path_table [ISODCL(141, 144)]; /* 731 */ 118 char opt_type_l_path_table [ISODCL(145, 148)]; /* 731 */ 119 char type_m_path_table [ISODCL(149, 152)]; /* 732 */ 120 char opt_type_m_path_table [ISODCL(153, 156)]; /* 732 */ 121 char root_directory_record [ISODCL(157, 190)]; /* 9.1 */ 122 char volume_set_id [ISODCL(191, 318)]; /* dchars */ 123 char publisher_id [ISODCL(319, 446)]; /* achars */ 124 char preparer_id [ISODCL(447, 574)]; /* achars */ 125 char application_id [ISODCL(575, 702)]; /* achars */ 126 char copyright_file_id [ISODCL(703, 739)]; /* 7.5 dchars */ 127 char abstract_file_id [ISODCL(740, 776)]; /* 7.5 dchars */ 128 char bibliographic_file_id [ISODCL(777, 813)]; /* 7.5 dchars */ 129 char creation_date [ISODCL(814, 830)]; /* 8.4.26.1 */ 130 char modification_date [ISODCL(831, 847)]; /* 8.4.26.1 */ 131 char expiration_date [ISODCL(848, 864)]; /* 8.4.26.1 */ 132 char effective_date [ISODCL(865, 881)]; /* 8.4.26.1 */ 133 char file_structure_version [ISODCL(882, 882)]; /* 711 */ 134 char unused4 [ISODCL(883, 883)]; 135 char application_data [ISODCL(884, 1395)]; 136 char unused5 [ISODCL(1396, 2048)]; 137 }; 138 139 /* El Torito Boot Record Volume Descriptor */ 140 struct eltorito_boot_descriptor { 141 char type [ISODCL(1, 1)]; /* 711 */ 142 char id [ISODCL(2, 6)]; 143 char version [ISODCL(7, 7)]; /* 711 */ 144 char system_id [ISODCL(8, 39)]; 145 char unused2 [ISODCL(40, 71)]; 146 char bootcat_ptr [ISODCL(72, 75)]; 147 char unused5 [ISODCL(76, 2048)]; 148 }; 149 150 /* Validation entry for El Torito */ 151 /* 152 * headerid must be 1 153 * id is the manufacturer ID 154 * cksum to make the sum of all shorts in this record 0 155 */ 156 struct eltorito_validation_entry { 157 char headerid [ISODCL(1, 1)]; /* 711 */ 158 char arch [ISODCL(2, 2)]; 159 char pad1 [ISODCL(3, 4)]; /* 721 */ 160 char id [ISODCL(5, 28)]; /* CD devel/man*/ 161 char cksum [ISODCL(29, 30)]; 162 char key1 [ISODCL(31, 31)]; 163 char key2 [ISODCL(32, 32)]; 164 }; 165 166 /* El Torito initial/default entry in boot catalog */ 167 struct eltorito_defaultboot_entry { 168 char boot_id [ISODCL(1, 1)]; /* 711 */ 169 char boot_media [ISODCL(2, 2)]; 170 char loadseg [ISODCL(3, 4)]; /* 721 */ 171 char sys_type [ISODCL(5, 5)]; 172 char pad1 [ISODCL(6, 6)]; 173 char nsect [ISODCL(7, 8)]; 174 char bootoff [ISODCL(9, 12)]; 175 char pad2 [ISODCL(13, 32)]; 176 }; 177 178 /* El Torito section header entry in boot catalog */ 179 struct eltorito_sectionheader_entry { 180 #define EL_TORITO_SHDR_ID_SHDR 0x90 181 #define EL_TORITO_SHDR_ID_LAST_SHDR 0x91 182 char header_id [ISODCL(1, 1)]; /* 711 */ 183 char platform_id [ISODCL(2, 2)]; 184 char entry_count [ISODCL(3, 4)]; /* 721 */ 185 char id [ISODCL(5, 32)]; 186 }; 187 188 /* El Torito section entry in boot catalog */ 189 struct eltorito_section_entry { 190 char boot_id [ISODCL(1, 1)]; /* 711 */ 191 char boot_media [ISODCL(2, 2)]; 192 char loadseg [ISODCL(3, 4)]; /* 721 */ 193 char sys_type [ISODCL(5, 5)]; 194 char pad1 [ISODCL(6, 6)]; 195 char nsect [ISODCL(7, 8)]; 196 char bootoff [ISODCL(9, 12)]; 197 char sel_criteria [ISODCL(13, 13)]; 198 char vendor_sel_criteria [ISODCL(14, 32)]; 199 }; 200 201 /* 202 * XXX JS: The next two structures have odd lengths! 203 * Some compilers (e.g. on Sun3/mc68020) padd the structures to even length. 204 * For this reason, we cannot use sizeof (struct iso_path_table) or 205 * sizeof (struct iso_directory_record) to compute on disk sizes. 206 * Instead, we use offsetof(..., name) and add the name size. 207 * See mkisofs.h 208 */ 209 210 /* We use this to help us look up the parent inode numbers. */ 211 212 struct iso_path_table { 213 unsigned char name_len[2]; /* 721 */ 214 char extent[4]; /* 731 */ 215 char parent[2]; /* 721 */ 216 char name[1]; 217 }; 218 219 /* 220 * A ISO filename is: "abcde.eee;1" -> <filename> '.' <ext> ';' <version #> 221 * 222 * The maximum needed string length is: 223 * 30 chars (filename + ext) 224 * + 2 chars ('.' + ';') 225 * + strlen("32767") 226 * + null byte 227 * ================================ 228 * = 38 chars 229 * 230 * We currently do not support CD-ROM-XA entension records, but we must honor 231 * the needed space for ISO-9660:1999 (Version 2). 232 * 233 * XXX If we ever will start to support XA records, we will need to take care 234 * XXX that the the maximum ISO-9660 name length will be reduced by another 235 * XXX 14 bytes resulting in a new total of 179 Bytes. 236 */ 237 #define LEN_ISONAME 31 238 #define MAX_ISONAME_V1 37 239 #define MAX_ISONAME_V2 207 /* 254 - 33 - 14 (XA Record) */ 240 #define MAX_ISONAME_V2_RR 193 /* 254 - 33 - 28 (CE Record) */ 241 #define MAX_ISONAME_V2_RR_XA 179 /* 254 - 33 - 14 - 28 */ 242 #define MAX_ISONAME MAX_ISONAME_V2 /* Used for array space defs */ 243 #define MAX_ISODIR 254 /* Must be even and <= 255 */ 244 245 struct iso_directory_record { 246 unsigned char length [ISODCL(1, 1)]; /* 711 */ 247 char ext_attr_length [ISODCL(2, 2)]; /* 711 */ 248 char extent [ISODCL(3, 10)]; /* 733 */ 249 char size [ISODCL(11, 18)]; /* 733 */ 250 char date [ISODCL(19, 25)]; /* 7 by 711 */ 251 unsigned char flags [ISODCL(26, 26)]; 252 char file_unit_size [ISODCL(27, 27)]; /* 711 */ 253 char interleave [ISODCL(28, 28)]; /* 711 */ 254 char volume_sequence_number [ISODCL(29, 32)]; /* 723 */ 255 unsigned char name_len [ISODCL(33, 33)]; /* 711 */ 256 char name [MAX_ISONAME+1]; /* Not really, but we need something here */ 257 }; 258 259 260 /* 261 * Iso directory flags. 262 */ 263 #define ISO_FILE 0 /* Not really a flag... */ 264 #define ISO_EXISTENCE 1 /* Do not make existence known (hidden) */ 265 #define ISO_DIRECTORY 2 /* This file is a directory */ 266 #define ISO_ASSOCIATED 4 /* This file is an assiciated file */ 267 #define ISO_RECORD 8 /* Record format in extended attr. != 0 */ 268 #define ISO_PROTECTION 16 /* No read/execute perm. in ext. attr. */ 269 #define ISO_DRESERVED1 32 /* Reserved bit 5 */ 270 #define ISO_DRESERVED2 64 /* Reserved bit 6 */ 271 #define ISO_MULTIEXTENT 128 /* Not final entry of a mult. ext. file */ 272 273 274 struct iso_ext_attr_record { 275 char owner [ISODCL(1, 4)]; /* 723 */ 276 char group [ISODCL(5, 8)]; /* 723 */ 277 char permissions [ISODCL(9, 10)]; /* 16 bits */ 278 char creation_date [ISODCL(11, 27)]; /* 8.4.26.1 */ 279 char modification_date [ISODCL(28, 44)]; /* 8.4.26.1 */ 280 char expiration_date [ISODCL(45, 61)]; /* 8.4.26.1 */ 281 char effective_date [ISODCL(62, 78)]; /* 8.4.26.1 */ 282 char record_format [ISODCL(79, 79)]; /* 711 */ 283 char record_attributes [ISODCL(80, 80)]; /* 711 */ 284 char record_length [ISODCL(81, 84)]; /* 723 */ 285 char system_id [ISODCL(85, 116)]; /* achars */ 286 char system_use [ISODCL(117, 180)]; 287 char ext_attr_version [ISODCL(181, 181)]; /* 711 */ 288 char esc_seq_len [ISODCL(182, 182)]; /* 711 */ 289 char reserved [ISODCL(183, 246)]; /* for future use */ 290 char appl_use_len [ISODCL(247, 250)]; /* 723 */ 291 char appl_use[1]; /* really more */ 292 /* char esc_seq[]; escape sequences recorded after appl_use */ 293 }; 294 295 /* 296 * Iso extended attribute permissions. 297 */ 298 #define ISO_GS_READ 0x0001 /* System Group Read */ 299 #define ISO_BIT_1 0x0002 300 #define ISO_GS_EXEC 0x0004 /* System Group Execute */ 301 #define ISO_BIT_3 0x0008 302 303 #define ISO_O_READ 0x0010 /* Owner Read */ 304 #define ISO_BIT_5 0x0020 305 #define ISO_O_EXEC 0x0040 /* Owner Exexute */ 306 #define ISO_BIT_7 0x0080 307 308 #define ISO_G_READ 0x0100 /* Group Read */ 309 #define ISO_BIT_9 0x0200 310 #define ISO_G_EXEC 0x0400 /* Group Execute */ 311 #define ISO_BIT_11 0x0800 312 313 #define ISO_W_READ 0x1000 /* World (other) Read */ 314 #define ISO_BIT_13 0x2000 315 #define ISO_W_EXEC 0x4000 /* World (other) Execute */ 316 #define ISO_BIT_15 0x8000 317 318 #define ISO_MB_ONE (ISO_BIT_1|ISO_BIT_3|ISO_BIT_5|ISO_BIT_7| \ 319 ISO_BIT_9|ISO_BIT_11|ISO_BIT_13|ISO_BIT_15) 320 321 /* 322 * Extended Attributes record according to Yellow Book. 323 */ 324 struct iso_xa_dir_record { 325 char group_id [ISODCL(1, 2)]; 326 char user_id [ISODCL(3, 4)]; 327 char attributes [ISODCL(5, 6)]; 328 char signature [ISODCL(7, 8)]; 329 char file_number [ISODCL(9, 9)]; 330 char reserved [ISODCL(10, 14)]; 331 }; 332 333 /* 334 * Definitions for XA attributes 335 */ 336 #define XA_O_READ 0x0001 /* Owner Read */ 337 #define XA_O_RES 0x0002 /* Owner Reserved (write ?) */ 338 #define XA_O_EXEC 0x0004 /* Owner Execute */ 339 #define XA_O_RES2 0x0008 /* Owner Reserved */ 340 #define XA_G_READ 0x0010 /* Group Read */ 341 #define XA_G_RES 0x0020 /* Group Reserved (write ?) */ 342 #define XA_G_EXEC 0x0040 /* Group Execute */ 343 #define XA_G_RES2 0x0080 /* Group Reserved */ 344 #define XA_W_READ 0x0100 /* World Read */ 345 #define XA_W_RES 0x0200 /* World Reserved (write ?) */ 346 #define XA_W_EXEC 0x0400 /* World Execute */ 347 348 #define XA_FORM1 0x0800 /* File contains Form 1 sector */ 349 #define XA_FORM2 0x1000 /* File contains Form 2 sector */ 350 #define XA_INTERLEAVED 0x2000 /* File contains interleaved sectors */ 351 #define XA_CDDA 0x4000 /* File contains audio data */ 352 #define XA_DIR 0x8000 /* This is a directory */ 353 354 /* 355 * Definitions for CD-ROM XA-Mode-2-form-1/2 sector sub-headers 356 */ 357 struct xa_subhdr { 358 Uchar file_number; /* Identifies file for block */ 359 Uchar channel_number; /* Playback channel selection */ 360 Uchar sub_mode; /* See bit definitions below */ 361 Uchar coding; /* Coding information */ 362 }; 363 364 /* 365 * Sub mode bit definitions 366 */ 367 #define XA_SUBH_EOR 0x01 /* End-Of-Record */ 368 #define XA_SUBH_VIDEO 0x02 /* Video Block */ 369 #define XA_SUBH_AUDIO 0x04 /* Audio Block (not CD-DA) */ 370 #define XA_SUBH_DATA 0x08 /* Data Block */ 371 #define XA_SUBH_TRIGGER 0x10 /* Trigger Block */ 372 #define XA_SUBH_FORM2 0x20 /* 0 == Form1, 1 == Form2 */ 373 #define XA_SUBH_REALTIME 0x40 /* Real Time Block */ 374 #define XA_SUBH_EOF 0x80 /* End-Of-File */ 375 376 #endif /* _ISOFS_FS_H */ 377