VirtualBox

source: vbox/trunk/include/iprt/formats/iso9660.h@ 67502

Last change on this file since 67502 was 67437, checked in by vboxsync, 8 years ago

IPRT: More ISO maker code (booting related).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 36.1 KB
Line 
1/* $Id: iso9660.h 67437 2017-06-16 13:14:39Z vboxsync $ */
2/** @file
3 * IPRT, ISO 9660 File System
4 */
5
6/*
7 * Copyright (C) 2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___iprt_formats_iso9660_h
28#define ___iprt_formats_iso9660_h
29
30#include <iprt/types.h>
31#include <iprt/assert.h>
32
33
34/** @defgroup grp_rt_formats_iso9660 ISO 9660 structures and definitions
35 * @ingroup grp_rt_formats
36 * @{
37 */
38
39
40/** The (default) logical sectors size of ISO 9660. */
41#define ISO9660_SECTOR_SIZE 2048
42/** Maximum filename length (level 2 & 3). */
43#define ISO9660_MAX_NAME_LEN 30
44
45
46/** Accessor for ISO9660U16 and ISO9660U32 that retrievs the member value for
47 * the host endianess. */
48#ifdef RT_BIG_ENDIAN
49# define ISO9660_GET_ENDIAN(a_pInt) ((a_pInt)->be)
50#else
51# define ISO9660_GET_ENDIAN(a_pInt) ((a_pInt)->le)
52#endif
53
54
55/**
56 * ISO 9660 16-bit unsigned integer type.
57 */
58typedef struct ISO9660U16
59{
60 /** Little endian. */
61 uint16_t le;
62 /** Big endian. */
63 uint16_t be;
64} ISO9660U16;
65/** Pointer to an ISO 9660 16-bit unsigned integer type. */
66typedef ISO9660U16 *PISO9660U16;
67/** Pointer to a const ISO 9660 16-bit unsigned integer type. */
68typedef ISO9660U16 const *PCISO9660U16;
69
70/** ISO 9660 big endian 16-bit unsigned integer. */
71typedef uint16_t ISO9660U16BE;
72
73
74/**
75 * ISO 9660 32-bit unsigned integer type.
76 */
77typedef struct ISO9660U32
78{
79 /** Little endian. */
80 uint32_t le;
81 /** Big endian. */
82 uint32_t be;
83} ISO9660U32;
84/** Pointer to an ISO 9660 32-bit unsigned integer type. */
85typedef ISO9660U32 *PISO9660U32;
86/** Pointer to a const ISO 9660 32-bit unsigned integer type. */
87typedef ISO9660U32 const *PCISO9660U32;
88
89/** ISO 9660 little endian 32-bit unsigned integer. */
90typedef uint32_t ISO9660U32LE;
91/** ISO 9660 big endian 32-bit unsigned integer. */
92typedef uint32_t ISO9660U32BE;
93
94/**
95 * ISO 9660 timestamp (date & time).
96 */
97typedef struct ISO9660TIMESTAMP
98{
99 /** 0x00: For digit year (0001-9999). */
100 char achYear[4];
101 /** 0x04: Month of the year (01-12). */
102 char achMonth[2];
103 /** 0x06: Day of month (01-31). */
104 char achDay[2];
105 /** 0x08: Hour of day (00-23). */
106 char achHour[2];
107 /** 0x0a: Minute of hour (00-59). */
108 char achMinute[2];
109 /** 0x0c: Second of minute (00-59). */
110 char achSecond[2];
111 /** 0x0e: Hundreth of second (00-99). */
112 char achCentisecond[2];
113 /** 0x10: The UTC (GMT) offset in 15 min units. */
114 int8_t offUtc;
115} ISO9660TIMESTAMP;
116AssertCompileSize(ISO9660TIMESTAMP, 17);
117/** Pointer to an ISO 9660 timestamp. */
118typedef ISO9660TIMESTAMP *PISO9660TIMESTAMP;
119/** Pointer to a const ISO 9660 timestamp. */
120typedef ISO9660TIMESTAMP const *PCISO9660TIMESTAMP;
121
122/**
123 * ISO 9660 record timestamp (date & time).
124 */
125typedef struct ISO9660RECTIMESTAMP
126{
127 /** 0: Years since 1900. */
128 uint8_t bYear;
129 /** 1: Month of year (1-12). */
130 uint8_t bMonth;
131 /** 2: Day of month (1-31). */
132 uint8_t bDay;
133 /** 3: Hour of day (0-23). */
134 uint8_t bHour;
135 /** 4: Minute of hour (0-59). */
136 uint8_t bMinute;
137 /** 5: Second of minute (0-59). */
138 uint8_t bSecond;
139 /** 6: The UTC (GMT) offset in 15 min units. */
140 int8_t offUtc;
141} ISO9660RECTIMESTAMP;
142AssertCompileSize(ISO9660RECTIMESTAMP, 7);
143/** Pointer to an ISO 9660 record timestamp. */
144typedef ISO9660RECTIMESTAMP *PISO9660RECTIMESTAMP;
145/** Pointer to a const ISO 9660 record timestamp. */
146typedef ISO9660RECTIMESTAMP const *PCISO9660RECTIMESTAMP;
147
148
149/**
150 * ISO 9660 directory record.
151 */
152#pragma pack(1)
153typedef struct ISO9660DIRREC
154{
155 /** 0x00: Length of this record in bytes. */
156 uint8_t cbDirRec;
157 /** 0x01: Extended attribute record length in logical blocks. */
158 uint8_t cExtAttrBlocks;
159 /** 0x02: Location of extent (logical block number).
160 * @note Misaligned. */
161 ISO9660U32 offExtent;
162 /** 0x0a: Size of the data (file section). Does not include EAs.
163 * @note Misaligned. */
164 ISO9660U32 cbData;
165 /** 0x12: Recording time and date. */
166 ISO9660RECTIMESTAMP RecTime;
167 /** 0x19: File flags (ISO9660_FILE_FLAGS_XXX). */
168 uint8_t fFileFlags;
169 /** 0x1a: File unit size for interlaved mode. */
170 uint8_t bFileUnitSize;
171 /** 0x1b: Interlave gap size. */
172 uint8_t bInterleaveGapSize;
173 /** 0x1c: Volume sequence number where the extent resides. */
174 ISO9660U16 VolumeSeqNo;
175 /** 0x20: Length of file identifier field. */
176 uint8_t bFileIdLength;
177 /** 0x21: File identifier (d-characters or d1-characters). */
178 char achFileId[1];
179 /* There are more fields following:
180 * - one byte optional padding so the following field is at an even boundrary.
181 * - system use field until cbDirRec is reached.
182 */
183} ISO9660DIRREC;
184#pragma pack()
185AssertCompileMemberOffset(ISO9660DIRREC, offExtent, 0x02);
186AssertCompileMemberOffset(ISO9660DIRREC, cbData, 0x0a);
187AssertCompileMemberOffset(ISO9660DIRREC, RecTime, 0x12);
188AssertCompileMemberOffset(ISO9660DIRREC, fFileFlags, 0x19);
189AssertCompileMemberOffset(ISO9660DIRREC, bFileIdLength, 0x20);
190AssertCompileMemberOffset(ISO9660DIRREC, achFileId, 0x21);
191/** Pointer to an ISO 9660 directory record. */
192typedef ISO9660DIRREC *PISO9660DIRREC;
193/** Pointer to a const ISO 9660 directory record. */
194typedef ISO9660DIRREC const *PCISO9660DIRREC;
195
196/** @name ISO9660_FILE_FLAGS_XXX
197 * @{ */
198/** Existence - Hide the file from the user. */
199#define ISO9660_FILE_FLAGS_HIDDEN UINT8_C(0x01)
200/** Directory - Indicates a directory as apposed to a regular file (0). */
201#define ISO9660_FILE_FLAGS_DIRECTORY UINT8_C(0x02)
202/** Assocated File - Indicates that the file is an associated file. */
203#define ISO9660_FILE_FLAGS_ASSOCIATED_FILE UINT8_C(0x04)
204/** Record - Indicates specified file content record format (see EAs). */
205#define ISO9660_FILE_FLAGS_RECORD UINT8_C(0x08)
206/** Protection - Indicates owner/group or permission protection in EAs. */
207#define ISO9660_FILE_FLAGS_PROTECTION UINT8_C(0x10)
208/** Reserved bit, MBZ. */
209#define ISO9660_FILE_FLAGS_RESERVED_5 UINT8_C(0x20)
210/** Reserved bit, MBZ. */
211#define ISO9660_FILE_FLAGS_RESERVED_6 UINT8_C(0x40)
212/** Multi-extend - Indicates that this isn't the final record for the file.
213 * @remarks Use for working around 4 GiB file size limitation. */
214#define ISO9660_FILE_FLAGS_MULTI_EXTENT UINT8_C(0x80)
215/** @} */
216
217
218/**
219 * ISO 9660 path table record.
220 */
221#pragma pack(1)
222typedef struct ISO9660PATHREC
223{
224 /** 0x00: Length of the achDirId field in bytes. */
225 uint8_t cbDirId;
226 /** 0x01: Extended attribute record length in bytes? */
227 uint8_t cbExtAttr;
228 /** 0x02: Location of extent (logical block number).
229 * @note Endianess depends on table.
230 * @note Misaligned. */
231 uint32_t offExtent;
232 /** 0x06: Parent directory number.
233 * @note Endianess depends on table. */
234 uint16_t idParentRec;
235 /** 0x08: Directory identifier (d-characters or d1-characters). */
236 char achDirId[RT_FLEXIBLE_ARRAY];
237 /* There will be a zero padding byte following if the directory identifier length is odd. */
238} ISO9660PATHREC;
239#pragma pack()
240AssertCompileMemberOffset(ISO9660PATHREC, cbExtAttr, 0x01);
241AssertCompileMemberOffset(ISO9660PATHREC, offExtent, 0x02);
242AssertCompileMemberOffset(ISO9660PATHREC, idParentRec, 0x06);
243AssertCompileMemberOffset(ISO9660PATHREC, achDirId, 0x08);
244/** Pointer to an ISO 9660 path table record. */
245typedef ISO9660PATHREC *PISO9660PATHREC;
246/** Pointer to a const ISO 9660 path table record. */
247typedef ISO9660PATHREC const *PCISO9660PATHREC;
248
249
250/**
251 * ISO 9660 extended attribute record.
252 */
253typedef struct ISO9660EXATTRREC
254{
255 /** 0x000: The owener ID. */
256 ISO9660U16 idOwner;
257 /** 0x004: The owener ID. */
258 ISO9660U16 idGroup;
259 /** 0x008: File permissions (ISO9660_PERM_XXX). */
260 ISO9660U16BE fPermissions;
261 /** 0x00a: File creation timestamp. */
262 ISO9660TIMESTAMP BirthTimestamp;
263 /** 0x01b: File modification timestamp. */
264 ISO9660TIMESTAMP ModifyTimestamp;
265 /** 0x02c: File expiration timestamp. */
266 ISO9660TIMESTAMP ExpireTimestamp;
267 /** 0x03d: File effective timestamp. */
268 ISO9660TIMESTAMP EffectiveTimestamp;
269 /** 0x04e: Record format. */
270 uint8_t bRecordFormat;
271 /** 0x04f: Record attributes. */
272 uint8_t fRecordAttrib;
273 /** 0x050: Record length. */
274 ISO9660U16 RecordLength;
275 /** 0x054: System identifier (a-characters or a1-characters). */
276 char achSystemId[0x20];
277 /** 0x074: System specific bytes. */
278 uint8_t abSystemUse[64];
279 /** 0x0b4: Extended attribute record version (ISO9660EXATTRREC_VERSION). */
280 uint8_t bExtRecVersion;
281 /** 0x0b5: Length of escape sequences. */
282 uint8_t cbEscapeSequences;
283 /** 0x0b6: Reserved for the future, MBZ. */
284 uint8_t abReserved183[64];
285 /** 0x0f6: Length of the application use field. */
286 ISO9660U16 cbAppUse;
287 /** 0x0fa: Variable sized application use field. */
288 uint8_t abAppUse[RT_FLEXIBLE_ARRAY];
289 /* This is followed by escape sequences with length given by cbEscapeSequnces. */
290} ISO9660EXATTRREC;
291AssertCompileMemberOffset(ISO9660EXATTRREC, EffectiveTimestamp, 0x03d);
292AssertCompileMemberOffset(ISO9660EXATTRREC, cbAppUse, 0x0f6);
293
294/** The ISO9660EXATTRREC::bExtRecVersion value. */
295#define ISO9660EXATTRREC_VERSION UINT8_C(0x01)
296
297/** @name ISO9660_PERM_XXX - ISO9660EXATTRREC::fPermissions
298 * @{ */
299/** @todo figure out this wird permission stuff... */
300/** @} */
301
302
303/**
304 * ISO 9660 volume descriptor header.
305 */
306typedef struct ISO9660VOLDESCHDR
307{
308 /** Descriptor type ISO9660VOLDESC_TYPE_XXX. */
309 uint8_t bDescType;
310 /** Standard identifier 'CD001' */
311 uint8_t achStdId[5];
312 /** The descriptor version. */
313 uint8_t bDescVersion;
314 /* (This is followed by the descriptor specific data). */
315} ISO9660VOLDESCHDR;
316AssertCompileSize(ISO9660VOLDESCHDR, 7);
317/** Pointer to a volume descriptor header. */
318typedef ISO9660VOLDESCHDR *PISO9660VOLDESCHDR;
319/** Pointer to a const volume descriptor header. */
320typedef ISO9660VOLDESCHDR const *PCISO9660VOLDESCHDR;
321
322/** @name ISO9660VOLDESC_TYPE_XXX - volume descriptor types
323 * @{ */
324/** See ISO9660BOOTRECORD. */
325#define ISO9660VOLDESC_TYPE_BOOT_RECORD UINT8_C(0x00)
326/** See ISO9660PRIMARYVOLDESC. */
327#define ISO9660VOLDESC_TYPE_PRIMARY UINT8_C(0x01)
328/** See ISO9660SUPVOLDESC. */
329#define ISO9660VOLDESC_TYPE_SUPPLEMENTARY UINT8_C(0x02)
330/** See ISO9660VOLPARTDESC. */
331#define ISO9660VOLDESC_TYPE_PARTITION UINT8_C(0x03)
332/** Terminates the volume descriptor set. Has no data (zeros), version is 1. */
333#define ISO9660VOLDESC_TYPE_TERMINATOR UINT8_C(0xff)
334/** @} */
335
336/** The value of ISO9660VOLDESCHDR::achStdId */
337#define ISO9660VOLDESC_STD_ID "CD001"
338#define ISO9660VOLDESC_STD_ID_0 'C'
339#define ISO9660VOLDESC_STD_ID_1 'D'
340#define ISO9660VOLDESC_STD_ID_2 '0'
341#define ISO9660VOLDESC_STD_ID_3 '0'
342#define ISO9660VOLDESC_STD_ID_4 '1'
343
344
345
346/**
347 * ISO 9660 boot record (volume descriptor).
348 */
349typedef struct ISO9660BOOTRECORD
350{
351 /** The volume descriptor header.
352 * Type is ISO9660VOLDESC_TYPE_BOOT_RECORD and version
353 * ISO9660BOOTRECORD_VERSION. */
354 ISO9660VOLDESCHDR Hdr;
355 /** Boot system identifier string (a-characters). */
356 char achBootSystemId[32];
357 /** Boot identifier (a-characters). */
358 char achBootId[32];
359 /** Boot system specific content. */
360 uint8_t abBootSystemSpecific[1977];
361} ISO9660BOOTRECORD;
362AssertCompileSize(ISO9660BOOTRECORD, ISO9660_SECTOR_SIZE);
363/** Pointer to an ISO 9660 boot record. */
364typedef ISO9660BOOTRECORD *PISO9660BOOTRECORD;
365/** Pointer to a const ISO 9660 boot record. */
366typedef ISO9660BOOTRECORD const *PCISO9660BOOTRECORD;
367
368/** The value of ISO9660BOOTRECORD::Hdr.uDescVersion. */
369#define ISO9660BOOTRECORD_VERSION UINT8_C(1)
370
371
372/**
373 * ISO 9660 boot record (volume descriptor), El Torito variant.
374 */
375#pragma pack(1)
376typedef struct ISO9660BOOTRECORDELTORITO
377{
378 /** 0x000: The volume descriptor header.
379 * Type is ISO9660VOLDESC_TYPE_BOOT_RECORD and version
380 * ISO9660BOOTRECORD_VERSION. */
381 ISO9660VOLDESCHDR Hdr;
382 /** 0x007: Boot system identifier string,
383 * zero padded ISO9660BOOTRECORDELTORITO_BOOT_SYSTEM_ID. */
384 char achBootSystemId[32];
385 /** 0x027: Boot identifier - all zeros. */
386 char achBootId[32];
387 /** 0x047: Boot catalog location (block offset), always (?) little endian.
388 * @note Misaligned. */
389 uint32_t offBootCatalog;
390 /** 0x04b: Unused - all zeros. */
391 uint8_t abBootSystemSpecific[1973];
392} ISO9660BOOTRECORDELTORITO;
393#pragma pack()
394AssertCompileSize(ISO9660BOOTRECORDELTORITO, ISO9660_SECTOR_SIZE);
395/** Pointer to an ISO 9660 El Torito boot record. */
396typedef ISO9660BOOTRECORDELTORITO *PISO9660BOOTRECORDELTORITO;
397/** Pointer to a const ISO 9660 El Torito boot record. */
398typedef ISO9660BOOTRECORDELTORITO const *PCISO9660BOOTRECORDELTORITO;
399
400/** The value of ISO9660BOOTRECORDELTORITO::achBootSystemId (zero padded). */
401#define ISO9660BOOTRECORDELTORITO_BOOT_SYSTEM_ID "EL TORITO SPECIFICATION"
402
403
404/**
405 * ISO 9660 primary volume descriptor.
406 */
407typedef struct ISO9660PRIMARYVOLDESC
408{
409 /** 0x000: The volume descriptor header.
410 * Type is ISO9660VOLDESC_TYPE_PRIMARY and version
411 * ISO9660PRIMARYVOLDESC_VERSION. */
412 ISO9660VOLDESCHDR Hdr;
413 /** 0x007: Explicit alignment zero padding. */
414 uint8_t bPadding8;
415 /** 0x008: System identifier (a-characters). */
416 char achSystemId[32];
417 /** 0x028: Volume identifier (d-characters). */
418 char achVolumeId[32];
419 /** 0x048: Unused field, zero filled. */
420 ISO9660U32 Unused73;
421 /** 0x050: Volume space size in logical blocks (cbLogicalBlock). */
422 ISO9660U32 VolumeSpaceSize;
423 /** 0x058: Unused field(s), zero filled. */
424 uint8_t abUnused89[32];
425 /** 0x078: The number of volumes in the volume set. */
426 ISO9660U16 cVolumesInSet;
427 /** 0x07c: Volume sequence number. */
428 ISO9660U16 VolumeSeqNo;
429 /** 0x080: Logical block size in bytes. */
430 ISO9660U16 cbLogicalBlock;
431 /** 0x084: Path table size. */
432 ISO9660U32 cbPathTable;
433 /** 0x08c: Type L(ittle endian) path table location (block offset). */
434 ISO9660U32LE offTypeLPathTable;
435 /** 0x090: Optional type L(ittle endian) path table location (block offset). */
436 ISO9660U32LE offOptionalTypeLPathTable;
437 /** 0x094: Type M (big endian) path table location (block offset). */
438 ISO9660U32BE offTypeMPathTable;
439 /** 0x098: Optional type M (big endian) path table location (block offset). */
440 ISO9660U32BE offOptionalTypeMPathTable;
441 /** 0x09c: Directory entry for the root directory (union). */
442 union
443 {
444 uint8_t ab[34];
445 ISO9660DIRREC DirRec;
446 } RootDir;
447 /** 0x0be: Volume set identifier (d-characters). */
448 char achVolumeSetId[128];
449 /** 0x13e: Publisher identifier (a-characters). Alternatively, it may refere to
450 * a file in the root dir if it starts with 0x5f and restricts itself to 8
451 * d-characters. */
452 char achPublisherId[128];
453 /** 0x1be: Data preparer identifier (a-characters).
454 * Same file reference alternative as previous field. */
455 char achDataPreparerId[128];
456 /** 0x23e: Application identifier (a-characters).
457 * Same file reference alternative as previous field. */
458 char achApplicationId[128];
459 /** 0x2be: Copyright (root) file identifier (d-characters).
460 * All spaces if none. */
461 char achCopyrightFileId[37];
462 /** 0x2e3: Abstract (root) file identifier (d-characters).
463 * All spaces if none. */
464 char achAbstractFileId[37];
465 /** 0x308: Bibliographic file identifier (d-characters).
466 * All spaces if none. */
467 char achBibliographicFileId[37];
468 /** 0x32d: Volume creation date and time. */
469 ISO9660TIMESTAMP BirthTime;
470 /** 0x33e: Volume modification date and time. */
471 ISO9660TIMESTAMP ModifyTime;
472 /** 0x34f: Volume (data) expiration date and time.
473 * If not specified, don't regard data as obsolete. */
474 ISO9660TIMESTAMP ExpireTime;
475 /** 0x360: Volume (data) effective date and time.
476 * If not specified, info can be used immediately. */
477 ISO9660TIMESTAMP EffectiveTime;
478 /** 0x371: File structure version (ISO9660_FILE_STRUCTURE_VERSION). */
479 uint8_t bFileStructureVersion;
480 /** 0x372: Reserve for future, MBZ. */
481 uint8_t bReserved883;
482 /** 0x373: Reserve for future, MBZ. */
483 uint8_t abAppUse[512];
484 /** 0x573: Reserved for future standardization, MBZ. */
485 uint8_t abReserved1396[653];
486} ISO9660PRIMARYVOLDESC;
487AssertCompileSize(ISO9660PRIMARYVOLDESC, ISO9660_SECTOR_SIZE);
488/** Pointer to a ISO 9660 primary volume descriptor. */
489typedef ISO9660PRIMARYVOLDESC *PISO9660PRIMARYVOLDESC;
490/** Pointer to a const ISO 9660 primary volume descriptor. */
491typedef ISO9660PRIMARYVOLDESC const *PCISO9660PRIMARYVOLDESC;
492
493/** The value of ISO9660PRIMARYVOLDESC::Hdr.uDescVersion. */
494#define ISO9660PRIMARYVOLDESC_VERSION UINT8_C(1)
495/** The value of ISO9660PRIMARYVOLDESC::bFileStructureVersion and
496 * ISO9660SUPVOLDESC::bFileStructureVersion. */
497#define ISO9660_FILE_STRUCTURE_VERSION UINT8_C(1)
498
499
500
501/**
502 * ISO 9660 supplementary volume descriptor.
503 *
504 * This is in the large parts identicial to the primary descriptor, except it
505 * have a few more fields where the primary one has reserved spaces.
506 */
507typedef struct ISO9660SUPVOLDESC
508{
509 /** 0x000: The volume descriptor header.
510 * Type is ISO9660VOLDESC_TYPE_SUPPLEMENTARY and version
511 * ISO9660SUPVOLDESC_VERSION. */
512 ISO9660VOLDESCHDR Hdr;
513 /** 0x007: Volume flags (ISO9660SUPVOLDESC_VOL_F_XXX).
514 * @note This is reserved in the primary volume descriptor. */
515 uint8_t fVolumeFlags;
516 /** 0x008: System identifier (a1-characters) of system that can act upon
517 * sectors 0 thru 15.
518 * @note Purpose differs from primary description. */
519 char achSystemId[32];
520 /** 0x028: Volume identifier (d1-characters).
521 * @note Character set differs from primary description. */
522 char achVolumeId[32];
523 /** 0x048: Unused field, zero filled. */
524 ISO9660U32 Unused73;
525 /** 0x050: Volume space size in logical blocks (cbLogicalBlock). */
526 ISO9660U32 VolumeSpaceSize;
527 /** 0x058: Escape sequences.
528 * Complicated stuff, see ISO 2022 and ECMA-35.
529 * @note This is reserved in the primary volume descriptor. */
530 uint8_t abEscapeSequences[32];
531 /** 0x078: The number of volumes in the volume set. */
532 ISO9660U16 cVolumesInSet;
533 /** 0x07c: Volume sequence number. */
534 ISO9660U16 VolumeSeqNo;
535 /** 0x080: Logical block size in bytes. */
536 ISO9660U16 cbLogicalBlock;
537 /** 0x084: Path table size. */
538 ISO9660U32 cbPathTable;
539 /** 0x08c: Type L(ittle endian) path table location (block offset). */
540 ISO9660U32LE offTypeLPathTable;
541 /** 0x090: Optional type L(ittle endian) path table location (block offset). */
542 ISO9660U32LE offOptionalTypeLPathTable;
543 /** 0x094: Type M (big endian) path table location (block offset). */
544 ISO9660U32BE offTypeMPathTable;
545 /** 0x098: Optional type M (big endian) path table location (block offset). */
546 ISO9660U32BE offOptionalTypeMPathTable;
547 /** 0x09c: Directory entry for the root directory (union). */
548 union
549 {
550 uint8_t ab[34];
551 ISO9660DIRREC DirRec;
552 } RootDir;
553 /** 0x0be: Volume set identifier (d1-characters).
554 * @note Character set differs from primary description. */
555 char achVolumeSetId[128];
556 /** 0x13e: Publisher identifier (a1-characters). Alternatively, it may refere
557 * to a file in the root dir if it starts with 0x5f and restricts itself to 8
558 * d1-characters.
559 * @note Character set differs from primary description. */
560 char achPublisherId[128];
561 /** 0x1be: Data preparer identifier (a1-characters).
562 * Same file reference alternative as previous field.
563 * @note Character set differs from primary description. */
564 char achDataPreparerId[128];
565 /** 0x23e: Application identifier (a1-characters).
566 * Same file reference alternative as previous field.
567 * @note Character set differs from primary description. */
568 char achApplicationId[128];
569 /** 0x2be: Copyright (root) file identifier (d1-characters).
570 * All spaces if none.
571 * @note Character set differs from primary description. */
572 char achCopyrightFileId[37];
573 /** 0x2e3: Abstract (root) file identifier (d1-characters).
574 * All spaces if none.
575 * @note Character set differs from primary description. */
576 char achAbstractFileId[37];
577 /** 0x308: Bibliographic file identifier (d1-characters).
578 * All spaces if none.
579 * @note Character set differs from primary description. */
580 char achBibliographicFileId[37];
581 /** 0x32d: Volume creation date and time. */
582 ISO9660TIMESTAMP BirthTime;
583 /** 0x33e: Volume modification date and time. */
584 ISO9660TIMESTAMP ModifyTime;
585 /** 0x34f: Volume (data) expiration date and time.
586 * If not specified, don't regard data as obsolete. */
587 ISO9660TIMESTAMP ExpireTime;
588 /** 0x360: Volume (data) effective date and time.
589 * If not specified, info can be used immediately. */
590 ISO9660TIMESTAMP EffectiveTime;
591 /** 0x371: File structure version (ISO9660_FILE_STRUCTURE_VERSION). */
592 uint8_t bFileStructureVersion;
593 /** 0x372: Reserve for future, MBZ. */
594 uint8_t bReserved883;
595 /** 0x373: Reserve for future, MBZ. */
596 uint8_t abAppUse[512];
597 /** 0x573: Reserved for future standardization, MBZ. */
598 uint8_t abReserved1396[653];
599} ISO9660SUPVOLDESC;
600AssertCompileSize(ISO9660SUPVOLDESC, ISO9660_SECTOR_SIZE);
601/** Pointer to a ISO 9660 supplementary volume descriptor. */
602typedef ISO9660SUPVOLDESC *PISO9660SUPVOLDESC;
603/** Pointer to a const ISO 9660 supplementary volume descriptor. */
604typedef ISO9660SUPVOLDESC const *PCISO9660SUPVOLDESC;
605/** The value of ISO9660SUPVOLDESC::Hdr.uDescVersion. */
606#define ISO9660SUPVOLDESC_VERSION UINT8_C(1)
607
608/** @name ISO9660SUPVOLDESC_VOL_F_XXX - ISO9660SUPVOLDESC::fVolumeFlags
609 * @{ */
610#define ISO9660SUPVOLDESC_VOL_F_ESC_ONLY_REG UINT8_C(0x00)
611#define ISO9660SUPVOLDESC_VOL_F_ESC_NOT_REG UINT8_C(0x01)
612/** @} */
613
614
615
616/**
617 * ISO 9660 volume partition descriptor.
618 */
619typedef struct ISO9660VOLPARTDESC
620{
621 /** 0x000: The volume descriptor header.
622 * Type is ISO9660VOLDESC_TYPE_PARTITION and version
623 * ISO9660VOLPARTDESC_VERSION. */
624 ISO9660VOLDESCHDR Hdr;
625 /** 0x007: Alignment padding. */
626 uint8_t bPadding8;
627 /** 0x008: System identifier (a-characters). */
628 char achSystemId[32];
629 /** 0x028: Volume partition identifier (d-characters). */
630 char achVolumePartitionId[32];
631 /** 0x048: The location of the partition (logical block number). */
632 ISO9660U32 offVolumePartition;
633 /** 0x050: The partition size in logical blocks (cbLogicalBlock). */
634 ISO9660U32 VolumePartitionSize;
635 /** 0x058: System specific data. */
636 uint8_t achSystemUse[1960];
637} ISO9660VOLPARTDESC;
638AssertCompileSize(ISO9660VOLPARTDESC, ISO9660_SECTOR_SIZE);
639/** Pointer to an ISO 9660 volume partition description. */
640typedef ISO9660VOLPARTDESC *PISO9660VOLPARTDESC;
641/** Pointer to a const ISO 9660 volume partition description. */
642typedef ISO9660VOLPARTDESC const *PCISO9660VOLPARTDESC;
643/** The value of ISO9660VOLPARTDESC::Hdr.uDescVersion. */
644#define ISO9660VOLPARTDESC_VERSION UINT8_C(1)
645
646
647
648/** @name Joliet escape sequence identifiers.
649 *
650 * These bytes appears in the supplementary volume descriptor field
651 * abEscapeSequences. The ISO9660SUPVOLDESC_VOL_F_ESC_NOT_REG flags will not
652 * be set.
653 *
654 * @{ */
655#define ISO9660_JOLIET_ESC_SEQ_0 UINT8_C(0x25) /**< First escape sequence byte.*/
656#define ISO9660_JOLIET_ESC_SEQ_1 UINT8_C(0x2f) /**< Second escape sequence byte.*/
657#define ISO9660_JOLIET_ESC_SEQ_2_LEVEL_1 UINT8_C(0x40) /**< Third escape sequence byte: level 1 */
658#define ISO9660_JOLIET_ESC_SEQ_2_LEVEL_2 UINT8_C(0x43) /**< Third escape sequence byte: level 2 */
659#define ISO9660_JOLIET_ESC_SEQ_2_LEVEL_3 UINT8_C(0x45) /**< Third escape sequence byte: level 3 */
660/** @} */
661
662
663/**
664 * El Torito boot catalog: Validation entry.
665 *
666 * This is the first entry in the boot catalog. It is followed by a
667 * ISO9660ELTORITODEFAULTENTRY, which in turn is followed by a
668 * ISO9660ELTORITOSECTIONHEADER.
669 */
670typedef struct ISO9660ELTORITOVALIDATIONENTRY
671{
672 /** 0x00: The header ID (ISO9660_ELTORITO_HEADER_ID_VALIDATION_ENTRY). */
673 uint8_t bHeaderId;
674 /** 0x01: The platform ID (ISO9660_ELTORITO_PLATFORM_ID_XXX). */
675 uint8_t bPlatformId;
676 /** 0x02: Reserved, MBZ. */
677 uint16_t u16Reserved;
678 /** 0x04: String ID of the developer of the CD/DVD-ROM. */
679 char achId[24];
680 /** 0x1c: The checksum. */
681 uint16_t u16Checksum;
682 /** 0x1e: Key byte 1 (ISO9660_ELTORITO_KEY_BYTE_1). */
683 uint8_t bKey1;
684 /** 0x1f: Key byte 2 (ISO9660_ELTORITO_KEY_BYTE_2). */
685 uint8_t bKey2;
686} ISO9660ELTORITOVALIDATIONENTRY;
687AssertCompileSize(ISO9660ELTORITOVALIDATIONENTRY, 0x20);
688/** Pointer to an El Torito validation entry. */
689typedef ISO9660ELTORITOVALIDATIONENTRY *PISO9660ELTORITOVALIDATIONENTRY;
690/** Pointer to a const El Torito validation entry. */
691typedef ISO9660ELTORITOVALIDATIONENTRY const *PCISO9660ELTORITOVALIDATIONENTRY;
692
693/** ISO9660ELTORITOVALIDATIONENTRY::bKey1 value. */
694#define ISO9660_ELTORITO_KEY_BYTE_1 UINT8_C(0x55)
695/** ISO9660ELTORITOVALIDATIONENTRY::bKey2 value. */
696#define ISO9660_ELTORITO_KEY_BYTE_2 UINT8_C(0xaa)
697
698
699/** @name ISO9660_ELTORITO_HEADER_ID_XXX - header IDs.
700 * @{ */
701/** Header ID for a ISO9660ELTORITOVALIDATIONENTRY. */
702#define ISO9660_ELTORITO_HEADER_ID_VALIDATION_ENTRY UINT8_C(0x01)
703/** Header ID for a ISO9660ELTORITOSECTIONHEADER. */
704#define ISO9660_ELTORITO_HEADER_ID_SECTION_HEADER UINT8_C(0x90)
705/** Header ID for the final ISO9660ELTORITOSECTIONHEADER. */
706#define ISO9660_ELTORITO_HEADER_ID_FINAL_SECTION_HEADER UINT8_C(0x91)
707/** @} */
708
709
710/** @name ISO9660_ELTORITO_PLATFORM_ID_XXX - El Torito Platform IDs
711 * @{ */
712#define ISO9660_ELTORITO_PLATFORM_ID_X86 UINT8_C(0x00) /**< 80x86 */
713#define ISO9660_ELTORITO_PLATFORM_ID_PPC UINT8_C(0x01) /**< PowerPC */
714#define ISO9660_ELTORITO_PLATFORM_ID_MAC UINT8_C(0x02) /**< Mac */
715#define ISO9660_ELTORITO_PLATFORM_ID_EFI UINT8_C(0xef) /**< UEFI */
716/** @} */
717
718
719/**
720 * El Torito boot catalog: Section header entry.
721 *
722 * A non-final section header entry is followed by
723 * ISO9660ELTORITOSECTIONHEADER::cEntries ISO9660ELTORITOSECTIONTENTRY instances.
724 */
725typedef struct ISO9660ELTORITOSECTIONHEADER
726{
727 /** 0x00: Header ID - ISO9660_ELTORITO_HEADER_ID_SECTION_HEADER or
728 * ISO9660_ELTORITO_HEADER_ID_FINAL_SECTION_HEADER (if final). */
729 uint8_t bHeaderId;
730 /** 0x01: The platform ID (ISO9660_ELTORITO_PLATFORM_ID_XXX). */
731 uint8_t bPlatformId;
732 /** 0x02: Number of entries in this section (i.e. following this header). */
733 uint16_t cEntries;
734 /** 0x04: String ID for the section. */
735 char achSectionId[28];
736} ISO9660ELTORITOSECTIONHEADER;
737AssertCompileSize(ISO9660ELTORITOSECTIONHEADER, 0x20);
738/** Pointer to an El Torito section header entry. */
739typedef ISO9660ELTORITOSECTIONHEADER *PISO9660ELTORITOSECTIONHEADER;
740/** Pointer to a const El Torito section header entry. */
741typedef ISO9660ELTORITOSECTIONHEADER const *PCISO9660ELTORITOSECTIONHEADER;
742
743
744/**
745 * El Torito boot catalog: Default (initial) entry.
746 *
747 * Followed by ISO9660ELTORITOSECTIONHEADER.
748 *
749 * Differs from ISO9660ELTORITOSECTIONENTRY in that it doesn't have a
750 * selection criteria and no media flags (only type).
751 */
752typedef struct ISO9660ELTORITODEFAULTENTRY
753{
754 /** 0x00: Boot indicator (ISO9660_ELTORITO_BOOT_INDICATOR_XXX). */
755 uint8_t bBootIndicator;
756 /** 0x01: Boot media type. The first four bits are defined by
757 * ISO9660_ELTORITO_BOOT_MEDIA_TYPE_XXX, whereas the top four bits MBZ. */
758 uint8_t bBootMediaType;
759 /** 0x02: Load segment - load address divided by 0x10. */
760 uint16_t uLoadSeg;
761 /** 0x04: System type from image partition table. */
762 uint8_t bSystemType;
763 /** 0x05: Unused, MBZ. */
764 uint8_t bUnused;
765 /** 0x06: Number of emulated 512 byte sectors to load. */
766 uint16_t cEmulatedSectorsToLoad;
767 /** 0x08: Image location in the ISO (block offset), always (?) little endian. */
768 uint32_t offBootImage;
769 /** 0x0c: Reserved, MBZ */
770 uint8_t abReserved[20];
771} ISO9660ELTORITODEFAULTENTRY;
772AssertCompileSize(ISO9660ELTORITODEFAULTENTRY, 0x20);
773/** Pointer to an El Torito default (initial) entry. */
774typedef ISO9660ELTORITODEFAULTENTRY *PISO9660ELTORITODEFAULTENTRY;
775/** Pointer to a const El Torito default (initial) entry. */
776typedef ISO9660ELTORITODEFAULTENTRY const *PCISO9660ELTORITODEFAULTENTRY;
777
778
779/**
780 * El Torito boot catalg: Section entry.
781 */
782typedef struct ISO9660ELTORITOSECTIONENTRY
783{
784 /** 0x00: Boot indicator (ISO9660_ELTORITO_BOOT_INDICATOR_XXX). */
785 uint8_t bBootIndicator;
786 /** 0x01: Boot media type and flags. The first four bits are defined by
787 * ISO9660_ELTORITO_BOOT_MEDIA_TYPE_XXX and the top four bits by
788 * ISO9660_ELTORITO_BOOT_MEDIA_F_XXX. */
789 uint8_t bBootMediaType;
790 /** 0x02: Load segment - load address divided by 0x10. */
791 uint16_t uLoadSeg;
792 /** 0x04: System type from image partition table. */
793 uint8_t bSystemType;
794 /** 0x05: Unused, MBZ. */
795 uint8_t bUnused;
796 /** 0x06: Number of emulated 512 byte sectors to load. */
797 uint16_t cEmulatedSectorsToLoad;
798 /** 0x08: Image location in the ISO (block offset), always (?) little endian. */
799 uint32_t offBootImage;
800 /** 0x0c: Selection criteria type (ISO9660_ELTORITO_SEL_CRIT_TYPE_XXX). */
801 uint8_t bSelectionCriteriaType;
802 /** 0x0c: Selection criteria specific data. */
803 uint8_t abSelectionCriteria[19];
804} ISO9660ELTORITOSECTIONENTRY;
805AssertCompileSize(ISO9660ELTORITOSECTIONENTRY, 0x20);
806/** Pointer to an El Torito default (initial) entry. */
807typedef ISO9660ELTORITOSECTIONENTRY *PISO9660ELTORITOSECTIONENTRY;
808/** Pointer to a const El Torito default (initial) entry. */
809typedef ISO9660ELTORITOSECTIONENTRY const *PCISO9660ELTORITOSECTIONENTRY;
810
811
812/** @name ISO9660_ELTORITO_BOOT_INDICATOR_XXX - Boot indicators.
813 * @{ */
814#define ISO9660_ELTORITO_BOOT_INDICATOR_BOOTABLE UINT8_C(0x88)
815#define ISO9660_ELTORITO_BOOT_INDICATOR_NOT_BOOTABLE UINT8_C(0x00)
816/** @} */
817
818/** @name ISO9660_ELTORITO_BOOT_MEDIA_TYPE_XXX - Boot media types.
819 * @{ */
820#define ISO9660_ELTORITO_BOOT_MEDIA_TYPE_NO_EMULATION UINT8_C(0x0)
821#define ISO9660_ELTORITO_BOOT_MEDIA_TYPE_FLOPPY_1_2_MB UINT8_C(0x1)
822#define ISO9660_ELTORITO_BOOT_MEDIA_TYPE_FLOPPY_1_44_MB UINT8_C(0x2)
823#define ISO9660_ELTORITO_BOOT_MEDIA_TYPE_FLOPPY_2_88_MB UINT8_C(0x3)
824#define ISO9660_ELTORITO_BOOT_MEDIA_TYPE_HARD_DISK UINT8_C(0x4)
825#define ISO9660_ELTORITO_BOOT_MEDIA_TYPE_MASK UINT8_C(0xf) /**< The media type mask. */
826/** @} */
827
828/** @name ISO9660_ELTORITO_BOOT_MEDIA_F_XXX - Boot media flags.
829 * These only applies to the section entry, not to the default (initial) entry.
830 * @{ */
831#define ISO9660_ELTORITO_BOOT_MEDIA_F_RESERVED UINT8_C(0x10) /**< Reserved bit, MBZ. */
832#define ISO9660_ELTORITO_BOOT_MEDIA_F_CONTINUATION UINT8_C(0x20) /**< Contiunation entry follows. */
833#define ISO9660_ELTORITO_BOOT_MEDIA_F_ATAPI_DRIVER UINT8_C(0x40) /**< Image contains an ATAPI driver. */
834#define ISO9660_ELTORITO_BOOT_MEDIA_F_SCSI_DRIVERS UINT8_C(0x80) /**< Image contains SCSI drivers. */
835#define ISO9660_ELTORITO_BOOT_MEDIA_F_MASK UINT8_C(0xf0) /**< The media/entry flag mask. */
836/** @} */
837
838/** @name ISO9660_ELTORITO_SEL_CRIT_TYPE_XXX - Selection criteria type.
839 * @{ */
840#define ISO9660_ELTORITO_SEL_CRIT_TYPE_NONE UINT8_C(0x00) /**< No selection criteria */
841#define ISO9660_ELTORITO_SEL_CRIT_TYPE_LANG_AND_VERSION UINT8_C(0x01) /**< Language and version (IBM). */
842/** @} */
843
844
845/**
846 * El Torito boot catalog: Section entry extension.
847 *
848 * This is used for carrying additional selection criteria data. It follows
849 * a ISO9660ELTORITOSECTIONENTRY.
850 */
851typedef struct ISO9660ELTORITOSECTIONENTRYEXT
852{
853 /** 0x00: Extension indicator (ISO9660_ELTORITO_SECTION_ENTRY_EXT_ID). */
854 uint8_t bExtensionId;
855 /** 0x01: Selection criteria extension flags (ISO9660_ELTORITO_SECTION_ENTRY_EXT_F_XXX). */
856 uint8_t fFlags;
857 /** 0x02: Selection critiera data. */
858 uint8_t abSelectionCriteria[30];
859} ISO9660ELTORITOSECTIONENTRYEXT;
860AssertCompileSize(ISO9660ELTORITOSECTIONENTRYEXT, 0x20);
861/** Pointer to an El Torito default (initial) entry. */
862typedef ISO9660ELTORITOSECTIONENTRYEXT *PISO9660ELTORITOSECTIONENTRYEXT;
863/** Pointer to a const El Torito default (initial) entry. */
864typedef ISO9660ELTORITOSECTIONENTRYEXT const *PCISO9660ELTORITOSECTIONENTRYEXT;
865
866/** Value of ISO9660ELTORITOSECTIONENTRYEXT::bExtensionId. */
867#define ISO9660_ELTORITO_SECTION_ENTRY_EXT_ID UINT_C(0x44)
868
869/** @name ISO9660_ELTORITO_SECTION_ENTRY_EXT_F_XXX - ISO9660ELTORITOSECTIONENTRYEXT::fFlags
870 * @{ */
871#define ISO9660_ELTORITO_SECTION_ENTRY_EXT_F_MORE UINT8_C(0x20) /**< Further extension entries follows. */
872#define ISO9660_ELTORITO_SECTION_ENTRY_EXT_F_UNUSED_MASK UINT8_C(0xef) /**< Mask of all unused bits. */
873/** @} */
874
875
876/**
877 * Boot information table used by isolinux and GRUB2 El Torito boot files.
878 */
879typedef struct ISO9660SYSLINUXINFOTABLE
880{
881 /** 0x00/0x08: Offset of the primary volume descriptor (block offset). */
882 uint32_t offPrimaryVolDesc;
883 /** 0x04/0x0c: Offset of the boot file (block offset). */
884 uint32_t offBootFile;
885 /** 0x08/0x10: Size of the boot file in bytes. */
886 uint32_t cbBootFile;
887 /** 0x0c/0x14: Boot file checksum.
888 * This is the sum of all the 32-bit words in the image, start at the end of
889 * this structure (i.e. offset 64). */
890 uint32_t uChecksum;
891 /** 0x10/0x18: Reserved for future fun. */
892 uint32_t auReserved[10];
893} ISO9660SYSLINUXINFOTABLE;
894AssertCompileSize(ISO9660SYSLINUXINFOTABLE, 56);
895/** Pointer to a syslinux boot information table. */
896typedef ISO9660SYSLINUXINFOTABLE *PISO9660SYSLINUXINFOTABLE;
897/** Pointer to a const syslinux boot information table. */
898typedef ISO9660SYSLINUXINFOTABLE const *PCISO9660SYSLINUXINFOTABLE;
899
900/** @} */
901
902#endif
903
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette