feat(ext4): directory entry find/add/remove operations

This commit is contained in:
2026-10-18 23:14:02 +02:00
parent fe0693b969
commit bff18df349
3 changed files with 274 additions and 0 deletions

View File

@@ -342,6 +342,32 @@ fn free_block_makes_it_available_again() {
assert_eq!(b1, b2);
}
#[test]
fn add_and_find_dir_entry() {
let mut fs = Ext4::mount(format_ext4_disk()).unwrap();
assert!(fs.find_in_dir_pub(2, b"hello").is_some());
assert!(fs.add_dir_entry(2, b"world", 4, 1));
assert_eq!(fs.find_in_dir_pub(2, b"world"), Some(4));
}
#[test]
fn remove_dir_entry() {
let mut fs = Ext4::mount(format_ext4_disk()).unwrap();
assert!(fs.find_in_dir_pub(2, b"hello").is_some());
let removed = fs.remove_dir_entry(2, b"hello");
assert_eq!(removed, Some(3));
assert!(fs.find_in_dir_pub(2, b"hello").is_none());
}
#[test]
fn list_dir_after_add() {
let mut fs = Ext4::mount(format_ext4_disk()).unwrap();
fs.add_dir_entry(2, b"second", 4, 1);
let mut entries = [DirEntry::empty(); 8];
let count = fs.list_dir(b"/", &mut entries).unwrap();
assert_eq!(count, 2);
}
#[test]
fn read_past_eof_returns_zero() {
let mut fs = Ext4::mount(format_ext4_disk()).unwrap();