iso9660/types.rs
1//! Common types and constants for ISO9660
2
3// Vec is imported but not used in current stubs
4#[allow(unused_imports)]
5use alloc::vec::Vec;
6
7/// ISO9660 sector size (always 2048 bytes)
8pub const SECTOR_SIZE: usize = 2048;
9
10/// Volume descriptor set starts at sector 16
11pub const VOLUME_DESCRIPTOR_START: u64 = 16;
12
13/// Maximum path length
14pub const MAX_PATH_LENGTH: usize = 255;
15
16/// Maximum directory depth
17pub const MAX_DIRECTORY_DEPTH: usize = 8;
18
19/// Volume descriptor type codes
20#[derive(Debug, Clone, Copy, PartialEq, Eq)]
21#[repr(u8)]
22pub enum VolumeDescriptorType {
23 /// Boot Record (El Torito)
24 BootRecord = 0,
25 /// Primary Volume Descriptor
26 Primary = 1,
27 /// Supplementary Volume Descriptor (Joliet)
28 Supplementary = 2,
29 /// Volume Partition Descriptor
30 Partition = 3,
31 /// Volume Descriptor Set Terminator
32 Terminator = 255,
33}
34
35/// Parsed volume information
36#[derive(Debug, Clone)]
37pub struct VolumeInfo {
38 /// Volume identifier (32 chars)
39 pub volume_id: [u8; 32],
40
41 /// Root directory extent location (LBA)
42 pub root_extent_lba: u32,
43
44 /// Root directory extent length (bytes)
45 pub root_extent_len: u32,
46
47 /// Logical block size (usually 2048)
48 pub logical_block_size: u16,
49
50 /// Volume space size (total sectors)
51 pub volume_space_size: u32,
52
53 /// El Torito boot catalog LBA (if present)
54 pub boot_catalog_lba: Option<u32>,
55
56 /// Whether Joliet extensions are present
57 pub has_joliet: bool,
58
59 /// Whether Rock Ridge extensions are present
60 pub has_rock_ridge: bool,
61}
62
63/// File entry metadata
64#[derive(Debug, Clone)]
65pub struct FileEntry {
66 /// File identifier (name as UTF-8)
67 pub name: alloc::string::String,
68
69 /// File size in bytes
70 pub size: u64,
71
72 /// Extent location (LBA)
73 pub extent_lba: u32,
74
75 /// Data length (bytes)
76 pub data_length: u32,
77
78 /// File flags
79 pub flags: FileFlags,
80
81 /// File unit size (interleaved files)
82 pub file_unit_size: u8,
83
84 /// Interleave gap size
85 pub interleave_gap: u8,
86}
87
88/// File flags from directory record
89#[derive(Debug, Clone, Copy, PartialEq, Eq)]
90pub struct FileFlags {
91 /// Hidden file
92 pub hidden: bool,
93
94 /// Directory (not a file)
95 pub directory: bool,
96
97 /// Associated file
98 pub associated: bool,
99
100 /// Extended attribute record format
101 pub extended_format: bool,
102
103 /// Owner/group permissions in extended attributes
104 pub extended_permissions: bool,
105
106 /// Not final directory record for this file
107 pub not_final: bool,
108}
109
110/// Boot image information (El Torito)
111#[derive(Debug, Clone)]
112pub struct BootImage {
113 /// Bootable flag
114 pub bootable: bool,
115
116 /// Boot media type
117 pub media_type: BootMediaType,
118
119 /// Load segment (x86)
120 pub load_segment: u16,
121
122 /// System type
123 pub system_type: u8,
124
125 /// Sector count
126 pub sector_count: u16,
127
128 /// Virtual disk LBA
129 pub load_rba: u32,
130
131 /// Platform ID
132 pub platform: BootPlatform,
133}
134
135/// Boot media type
136#[derive(Debug, Clone, Copy, PartialEq, Eq)]
137#[repr(u8)]
138pub enum BootMediaType {
139 /// No emulation
140 NoEmulation = 0,
141 /// 1.2MB floppy
142 Floppy12M = 1,
143 /// 1.44MB floppy
144 Floppy144M = 2,
145 /// 2.88MB floppy
146 Floppy288M = 3,
147 /// Hard disk
148 HardDisk = 4,
149}
150
151/// Boot platform ID
152#[derive(Debug, Clone, Copy, PartialEq, Eq)]
153#[repr(u8)]
154pub enum BootPlatform {
155 /// x86 PC
156 X86 = 0,
157 /// PowerPC
158 PowerPC = 1,
159 /// Mac
160 Mac = 2,
161 /// EFI
162 Efi = 0xEF,
163}