Detect LZ4 files correctly now
This commit is contained in:
@@ -8,11 +8,6 @@ pub type LBANameVec = Vec<String>;
|
||||
|
||||
mod main;
|
||||
|
||||
/*
|
||||
Size in sectors [22, 31];
|
||||
Is LZ4 compressed [19];
|
||||
LBA value [0, 18]
|
||||
*/
|
||||
#[repr(packed)]
|
||||
struct LBAEntry {
|
||||
raw: u32,
|
||||
@@ -20,10 +15,10 @@ struct LBAEntry {
|
||||
|
||||
impl LBAEntry {
|
||||
const SIZE_IN_SECTOR_RANGE:BitRange = BitRange::from_to(22, 31);
|
||||
const _IS_LZ4_COMPRESSED:Bit = Bit::at(19);
|
||||
const IS_LZ4_COMPRESSED:Bit = Bit::at(19);
|
||||
const LBA_VALUE_RANGE:BitRange = BitRange::from_to(0, 18);
|
||||
|
||||
pub fn write_entry(&mut self, lba: usize, size_bytes: usize, _is_lz4: bool) -> Result<(), Error> {
|
||||
pub fn write_entry(&mut self, lba: usize, size_bytes: usize, is_lz4: bool) -> Result<(), Error> {
|
||||
if lba > Self::LBA_VALUE_RANGE.max_value() {
|
||||
return Err(Error::from_text(format!("LBA of value {} is impossible and can not be encoded! Maximum LBA value is: {}", lba, Self::LBA_VALUE_RANGE.max_value())));
|
||||
}
|
||||
@@ -40,7 +35,11 @@ impl LBAEntry {
|
||||
return Err(Error::from_str("LBA Entry will overwrite non-zero value!\nIs no space allocated for the LBA Entries?"));
|
||||
}
|
||||
|
||||
self.raw = Self::SIZE_IN_SECTOR_RANGE.or_value(Self::LBA_VALUE_RANGE.or_value(0, lba), size_in_sectors) as u32;
|
||||
let new_raw = Self::LBA_VALUE_RANGE.or_value(0, lba);
|
||||
let new_raw = Self::SIZE_IN_SECTOR_RANGE.or_value(new_raw, size_in_sectors);
|
||||
let new_raw = Self::IS_LZ4_COMPRESSED.or_value(new_raw, is_lz4);
|
||||
|
||||
self.raw = new_raw as u32;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user