feat(ext4): directory entry find/add/remove operations
This commit is contained in:
@@ -2,6 +2,7 @@ pub mod io;
|
||||
pub mod superblock;
|
||||
pub mod bgd;
|
||||
pub mod bitmap;
|
||||
pub mod dir;
|
||||
|
||||
use port_block_device::BlockDevice;
|
||||
use crate::filesystem::{DirEntry, FileHandle, FileName, FileSystem};
|
||||
@@ -194,6 +195,24 @@ impl<B: BlockDevice> Ext4<B> {
|
||||
bitmap::free_inode(&mut self.device, &mut self.sb, self.gdt_block, inode, spb);
|
||||
}
|
||||
|
||||
pub fn find_in_dir_pub(&mut self, dir_inode_num: u32, name: &[u8]) -> Option<u32> {
|
||||
let inode = self.read_inode(dir_inode_num)?;
|
||||
dir::find_entry(&mut self.device, &self.sb, self.gdt_block, &inode, name)
|
||||
}
|
||||
|
||||
pub fn add_dir_entry(&mut self, dir_inode_num: u32, name: &[u8], child_inode: u32, file_type: u8) -> bool {
|
||||
let inode = match self.read_inode(dir_inode_num) {
|
||||
Some(i) => i,
|
||||
None => return false,
|
||||
};
|
||||
dir::add_entry(&mut self.device, &self.sb, self.gdt_block, &inode, name, child_inode, file_type)
|
||||
}
|
||||
|
||||
pub fn remove_dir_entry(&mut self, dir_inode_num: u32, name: &[u8]) -> Option<u32> {
|
||||
let inode = self.read_inode(dir_inode_num)?;
|
||||
dir::remove_entry(&mut self.device, &self.sb, self.gdt_block, &inode, name)
|
||||
}
|
||||
|
||||
fn read_extents(&self, inode: &Inode) -> Option<Extent> {
|
||||
if !inode.uses_extents() { return None; }
|
||||
let hdr = &inode.block_data;
|
||||
|
||||
Reference in New Issue
Block a user