JuliOS/src/fs/iso/iso9660.rs
Julien CLEMENT c4531b5074
All checks were successful
continuous-integration/drone/push Build is passing
struct size hacking shenanigans
Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
2022-12-17 20:31:14 +01:00

25 lines
727 B
Rust

#[repr(C, packed)]
pub struct IsoPathTable {
idf_len: u8, // Identifier name length
ext_size: u8, // Extended attribute record length
data_blk: u8, // File data block index
parent_dir: u16, // Number of the parent dir
idf: [char; 0] // Directory name, of size Self::idf_len
}
impl IsoPathTable {
pub fn from(mapping: &u8) -> &Self {
let ptr: *const u8 = mapping;
let path_table_ptr: *const IsoPathTable = ptr as *const IsoPathTable;
unsafe {
&*path_table_ptr
}
}
#[allow(unaligned_references)]
pub fn get_idf(&self) -> &[char] {
unsafe {
core::slice::from_raw_parts(self.idf.as_ptr(), self.idf_len as usize)
}
}
}