struct size hacking shenanigans
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
Julien CLEMENT 2022-12-17 20:31:14 +01:00
parent 96e7b1cd8e
commit c4531b5074
2 changed files with 5 additions and 5 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
/target
iso
/iso
*.iso
*.o
julios

View File

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