use thiserror::Error;
#[derive(Debug, Error, PartialEq, Eq)]
#[non_exhaustive]
pub enum UfsError {
#[error("buffer too small for {structure}: need {need} bytes, have {have}")]
Truncated {
structure: &'static str,
need: usize,
have: usize,
},
#[error(
"bad UFS superblock magic at offset {offset}: bytes {bytes:02x?} \
(LE {le:#010x}, BE {be:#010x}); expected UFS1 0x00011954 or UFS2 0x19540119"
)]
BadMagic {
offset: usize,
bytes: [u8; 4],
le: u32,
be: u32,
},
#[error(
"bad cylinder-group magic: found {found:#010x} (endian {endian:?}), expected 0x00090255"
)]
BadCgMagic {
found: u32,
endian: crate::Endian,
},
#[error("impossible geometry: {field} = {value} exceeds bound {limit}")]
ImpossibleGeometry {
field: &'static str,
value: u64,
limit: u64,
},
#[error("inode {ino} out of range: filesystem has {count} inodes (0..{count})")]
InodeOutOfRange {
ino: u64,
count: u64,
},
}