Skip to content

Commit ecded87

Browse files
More journal work
1 parent 3343d70 commit ecded87

File tree

6 files changed

+412
-27
lines changed

6 files changed

+412
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* Added `Ext4::uuid` to get the filesystem UUID.
1010
* Made the `Corrupt` type opaque. It is no longer possible to `match` on
1111
specific types of corruption.
12+
* Added support for reading filesystems that weren't cleanly unmounted.
1213

1314
## 0.7.0
1415

src/error.rs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,27 @@ pub(crate) enum CorruptKind {
226226
u32,
227227
),
228228

229+
/// Journal size is invalid.
230+
JournalSize,
231+
232+
/// Journal magic is invalid.
233+
JournalMagic,
234+
235+
/// Journal superblock checksum is invalid.
236+
JournalSuperblockChecksum,
237+
238+
/// Journal block size does not match the filesystem block size.
239+
JournalBlockSize,
240+
241+
/// Journal does not have the expected number of blocks.
242+
JournalTruncated,
243+
244+
/// Journal first commit doesn't match the sequence number in the superblock.
245+
JournalSequence,
246+
247+
/// Journal has a descriptor block that contains no tag with the last-tag flag set.
248+
JournalDescriptorBlockMissingLastTag,
249+
229250
/// An inode's checksum is invalid.
230251
InodeChecksum(
231252
/// Inode number.
@@ -333,6 +354,30 @@ impl Display for CorruptKind {
333354
f,
334355
"invalid checksum for block group descriptor {block_group_num}"
335356
),
357+
Self::JournalSize => {
358+
write!(f, "journal size is invalid")
359+
}
360+
Self::JournalMagic => {
361+
write!(f, "journal magic is invalid")
362+
}
363+
Self::JournalSuperblockChecksum => {
364+
write!(f, "journal superblock checksum is invalid")
365+
}
366+
Self::JournalBlockSize => {
367+
write!(
368+
f,
369+
"journal block size does not match filesystem block size"
370+
)
371+
}
372+
Self::JournalTruncated => write!(f, "journal is truncated"),
373+
Self::JournalSequence => write!(
374+
f,
375+
"journal's first commit doesn't match the expected sequence"
376+
),
377+
Self::JournalDescriptorBlockMissingLastTag => write!(
378+
f,
379+
"a journal descriptor block has no tag with the last-tag flag set"
380+
),
336381
Self::InodeChecksum(inode) => {
337382
write!(f, "invalid checksum for inode {inode}")
338383
}
@@ -450,6 +495,24 @@ pub enum Incompatible {
450495
/// Inode number.
451496
u32,
452497
),
498+
499+
/// The journal superblock type is not supported.
500+
JournalSuperblockType(
501+
/// Raw journal block type.
502+
u32,
503+
),
504+
505+
/// The journal checksum type is not supported.
506+
JournalChecksumType(
507+
/// Raw journal checksum type.
508+
u8,
509+
),
510+
511+
/// The journal uses features not supported by this library.
512+
JournalIncompatibleFeatures(
513+
/// Raw feature bits.
514+
u32,
515+
),
453516
}
454517

455518
impl Display for Incompatible {
@@ -470,6 +533,15 @@ impl Display for Incompatible {
470533
Self::DirectoryEncrypted(inode) => {
471534
write!(f, "directory in inode {inode} is encrypted")
472535
}
536+
Self::JournalSuperblockType(val) => {
537+
write!(f, "journal superblock type is not supported: {val}")
538+
}
539+
Self::JournalChecksumType(val) => {
540+
write!(f, "journal checksum type is not supported: {val}")
541+
}
542+
Self::JournalIncompatibleFeatures(val) => {
543+
write!(f, "unsupported journal features: {val:08x}")
544+
}
473545
}
474546
}
475547
}

0 commit comments

Comments
 (0)