From 9ed5ffc521c9118fb8ac753983717b3eff3b0e96 Mon Sep 17 00:00:00 2001 From: TheOddGarlic Date: Wed, 3 Aug 2022 19:45:04 +0300 Subject: [PATCH] vfs: FsNode::new() --- ableos/src/filesystem/mod.rs | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/ableos/src/filesystem/mod.rs b/ableos/src/filesystem/mod.rs index d2c629e0..1f661c64 100644 --- a/ableos/src/filesystem/mod.rs +++ b/ableos/src/filesystem/mod.rs @@ -41,8 +41,24 @@ pub struct FsNode { } impl FsNode { + pub fn new( + flags: FsNodeFlags, + length: u32, + inode: u32, + device_handle: Handle, + ptr: Weak, + ) -> Self { + Self { + flags, + length, + inode, + device_handle, + ptr, + } + } + // TODO: make this take flags - fn open(&self) -> Result { + pub fn open(&self) -> Result { let state = KERNEL_STATE.lock(); let device = state .get_storage_device(self.device_handle) @@ -51,7 +67,7 @@ impl FsNode { device.open(self) } - fn close(&self) -> Result<()> { + pub fn close(&self) -> Result<()> { let state = KERNEL_STATE.lock(); let device = state .get_storage_device(self.device_handle) @@ -60,7 +76,7 @@ impl FsNode { device.close(self) } - fn read(&self, offset: u32, size: u32) -> Result> { + pub fn read(&self, offset: u32, size: u32) -> Result> { let state = KERNEL_STATE.lock(); let device = state .get_storage_device(self.device_handle) @@ -69,7 +85,7 @@ impl FsNode { device.read(self, offset, size) } - fn write(&self, offset: u32, buffer: Box<[u8]>) -> Result<()> { + pub fn write(&self, offset: u32, buffer: Box<[u8]>) -> Result<()> { let state = KERNEL_STATE.lock(); let device = state .get_storage_device(self.device_handle) @@ -78,7 +94,7 @@ impl FsNode { device.write(self, offset, buffer) } - fn read_dir(&self, index: u32) -> Result { + pub fn read_dir(&self, index: u32) -> Result { let state = KERNEL_STATE.lock(); let device = state .get_storage_device(self.device_handle) @@ -87,7 +103,7 @@ impl FsNode { device.read_dir(self, index) } - fn find_dir(&self, name: &str) -> Result { + pub fn find_dir(&self, name: &str) -> Result { let state = KERNEL_STATE.lock(); let device = state .get_storage_device(self.device_handle)