Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions kernel/src/filesys/ext2/structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,72 @@
pub fn size(&self) -> u64 {
self.size_low as u64
}

/// Getters to determine permissions for the specified user on this file
pub fn user_execute(&self) -> bool {
FileMode::from_bits_retain(self.mode).contains(FileMode::UEXEC)
}
pub fn user_write(&self) -> bool {
FileMode::from_bits_retain(self.mode).contains(FileMode::UWRITE)
}
pub fn user_read(&self) -> bool {
FileMode::from_bits_retain(self.mode).contains(FileMode::UREAD)
}

/// Setters to alter permissions for the specified user on this file
pub fn set_user_exectute(&mut self, new_value: bool) {
self.mode = (self.mode & !0x40) | ((new_value as u16) << 6);
}
pub fn set_user_write(&mut self, new_value: bool) {
self.mode = (self.mode & !0x80) | ((new_value as u16) << 7);

Check warning on line 249 in kernel/src/filesys/ext2/structures.rs

View workflow job for this annotation

GitHub Actions / lint

Diff in /home/runner/work/TAOS/TAOS/kernel/src/filesys/ext2/structures.rs

Check warning on line 249 in kernel/src/filesys/ext2/structures.rs

View workflow job for this annotation

GitHub Actions / lint

Diff in /home/runner/work/TAOS/TAOS/kernel/src/filesys/ext2/structures.rs
}
pub fn set_user_read(&mut self, new_value: bool) {
self.mode = (self.mode & !0x100) | ((new_value as u16) << 8);
}

/// Getters to determine permissions for the specified user group on this file
pub fn group_execute(&self) -> bool {
FileMode::from_bits_retain(self.mode).contains(FileMode::GEXEC)
}
pub fn group_write(&self) -> bool {
FileMode::from_bits_retain(self.mode).contains(FileMode::GWRITE)
}
pub fn group_read(&self) -> bool {
FileMode::from_bits_retain(self.mode).contains(FileMode::GREAD)
}

/// Setters to alter permissions for the specified user group on this file
pub fn set_group_exectute(&mut self, new_value: bool) {
self.mode = (self.mode & !0x8) | ((new_value as u16) << 3);
}
pub fn set_group_write(&mut self, new_value: bool) {
self.mode = (self.mode & !0x10) | ((new_value as u16) << 4);
}
pub fn set_group_read(&mut self, new_value: bool) {
self.mode = (self.mode & !0x20) | ((new_value as u16) << 5);
}

/// Getters to determine permissions for the unspecified users on this file
pub fn other_exectute(&self) -> bool {
FileMode::from_bits_retain(self.mode).contains(FileMode::OEXEC)
}
pub fn other_write(&self) -> bool {
FileMode::from_bits_retain(self.mode).contains(FileMode::OWRITE)
}
pub fn other_read(&self) -> bool {
FileMode::from_bits_retain(self.mode).contains(FileMode::OREAD)
}

/// Setters to alter permissions for unspecified users on this file
pub fn set_other_exectute(&mut self, new_value: bool) {
self.mode = (self.mode & !0x1) | new_value as u16;
}
pub fn set_other_write(&mut self, new_value: bool) {
self.mode = (self.mode & !0x2) | ((new_value as u16) << 1);
}
pub fn set_other_read(&mut self, new_value: bool) {
self.mode = (self.mode & !0x4) | ((new_value as u16) << 2);
}
}

/// Directory entry structure - variable length on disk
Expand Down
Loading