diff options
Diffstat (limited to 'src/disk/inode.rs')
-rw-r--r-- | src/disk/inode.rs | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/src/disk/inode.rs b/src/disk/inode.rs index 1095aca..256d2f5 100644 --- a/src/disk/inode.rs +++ b/src/disk/inode.rs @@ -1,11 +1,11 @@ use bitflags::bitflags; use fuser::{FileAttr, FileType}; -use std::fs::File; +use crate::utils; -const DIRECT_NUMBER: usize = 15; +pub const DIRECT_NUMBER: usize = 15; #[derive(Debug, Clone, Copy)] -pub struct InodeMode(u16); +pub struct InodeMode(pub u16); bitflags! { impl InodeMode: u16 { @@ -33,6 +33,34 @@ bitflags! { } impl InodeMode { + pub(crate) fn exec_other(&self) -> bool { + self.0 & Self::IXOTH.0 != 0 + } + pub(crate) fn write_other(&self) -> bool { + self.0 & Self::IWOTH.0 != 0 + } + pub(crate) fn read_other(&self) -> bool { + self.0 & Self::IROTH.0 != 0 + } + pub(crate) fn exec_group(&self) -> bool { + self.0 & Self::IXGRP.0 != 0 + } + pub(crate) fn write_group(&self) -> bool { + self.0 & Self::IWGRP.0 != 0 + } + pub(crate) fn read_group(&self) -> bool { + self.0 & Self::IRGRP.0 != 0 + } + pub(crate) fn exec_user(&self) -> bool { + self.0 & Self::IXUSR.0 != 0 + } + pub(crate) fn write_user(&self) -> bool { + self.0 & Self::IWUSR.0 != 0 + } + pub(crate) fn read_user(&self) -> bool { + self.0 & Self::IRUSR.0 != 0 + } + pub(crate) fn perm(&self) -> u16 { self.0 & 0x0FFF } @@ -69,6 +97,13 @@ impl From<InodeMode> for FileType { } } +impl From<InodeMode> for u8 { + fn from(value: InodeMode) -> Self { + utils::from_filetype(value.into()) + } +} + + /// Pretty much the same with ext2, with minor changes: /// - removed OS dependent attributes (osd1 & osd2) /// - removed i_faddr since fragmentation is not supported |