1#[derive(Debug, thiserror::Error)]
5pub enum NtfsError {
6 #[error("input too short for {what}: need {need} bytes, got {got}")]
8 TooShort {
9 what: &'static str,
10 need: usize,
11 got: usize,
12 },
13
14 #[error("not an NTFS volume: OEM ID is {0:x?}, expected \"NTFS \"")]
16 BadOemId([u8; 8]),
17
18 #[error("invalid bytes-per-sector: {0} (must be a power of two in 256..=4096)")]
20 BadBytesPerSector(u16),
21
22 #[error("invalid sectors-per-cluster encoding: {0:#04x}")]
24 BadSectorsPerCluster(u8),
25
26 #[error("invalid MFT record size encoding: byte {0:#04x}")]
28 BadRecordSize(u8),
29
30 #[error("invalid index record size encoding: byte {0:#04x}")]
32 BadIndexRecordSize(u8),
33
34 #[error("bad MFT record signature: {0:x?} (expected \"FILE\" or \"BAAD\")")]
36 BadRecordSignature([u8; 4]),
37
38 #[error("fixup mismatch in sector {sector}: expected USN {expected:#06x}, found {found:#06x}")]
41 FixupMismatch {
42 sector: usize,
43 expected: u16,
44 found: u16,
45 },
46
47 #[error("malformed update sequence array: {0}")]
49 BadUpdateSequence(&'static str),
50
51 #[error("corrupt attribute at offset {offset}: {detail}")]
54 BadAttribute { offset: usize, detail: &'static str },
55
56 #[error("malformed runlist: {0}")]
58 BadRunlist(&'static str),
59
60 #[error("malformed index: {0}")]
62 BadIndex(&'static str),
63
64 #[error("malformed compressed data: {0}")]
66 BadCompression(&'static str),
67
68 #[error("malformed attribute list: {0}")]
70 BadAttributeList(&'static str),
71
72 #[error("path not found: {0}")]
74 NotFound(String),
75
76 #[error("not a directory: {0}")]
78 NotADirectory(String),
79
80 #[error("refusing to allocate {bytes} bytes")]
84 TooLarge { bytes: u64 },
85
86 #[error("I/O error: {0}")]
88 Io(#[from] std::io::Error),
89}
90
91pub type Result<T> = std::result::Result<T, NtfsError>;