feat(ext4): block and inode bitmap allocation/deallocation
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
pub mod io;
|
||||
pub mod superblock;
|
||||
pub mod bgd;
|
||||
pub mod bitmap;
|
||||
|
||||
use port_block_device::BlockDevice;
|
||||
use crate::filesystem::{DirEntry, FileHandle, FileName, FileSystem};
|
||||
@@ -173,6 +174,26 @@ impl<B: BlockDevice> Ext4<B> {
|
||||
self.write_inode(inode_num, inode)
|
||||
}
|
||||
|
||||
pub fn alloc_block(&mut self) -> Option<u32> {
|
||||
let spb = self.sb.sectors_per_block();
|
||||
bitmap::alloc_block(&mut self.device, &mut self.sb, self.gdt_block, spb)
|
||||
}
|
||||
|
||||
pub fn free_block(&mut self, block: u32) {
|
||||
let spb = self.sb.sectors_per_block();
|
||||
bitmap::free_block(&mut self.device, &mut self.sb, self.gdt_block, block, spb);
|
||||
}
|
||||
|
||||
pub fn alloc_inode(&mut self) -> Option<u32> {
|
||||
let spb = self.sb.sectors_per_block();
|
||||
bitmap::alloc_inode(&mut self.device, &mut self.sb, self.gdt_block, spb)
|
||||
}
|
||||
|
||||
pub fn free_inode(&mut self, inode: u32) {
|
||||
let spb = self.sb.sectors_per_block();
|
||||
bitmap::free_inode(&mut self.device, &mut self.sb, self.gdt_block, inode, spb);
|
||||
}
|
||||
|
||||
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