diff --git a/src/fs/fields.rs b/src/fs/fields.rs index ee25e91..65e5289 100644 --- a/src/fs/fields.rs +++ b/src/fs/fields.rs @@ -67,6 +67,10 @@ pub struct Permissions { pub other_read: bool, pub other_write: bool, pub other_execute: bool, + + pub sticky: bool, + pub setgid: bool, + pub setuid: bool, } /// The three pieces of information that are displayed as a single column in diff --git a/src/fs/file.rs b/src/fs/file.rs index 6430862..c0a0653 100644 --- a/src/fs/file.rs +++ b/src/fs/file.rs @@ -309,19 +309,25 @@ impl<'dir> File<'dir> { /// This file’s permissions, with flags for each bit. pub fn permissions(&self) -> f::Permissions { - let bits = self.metadata.permissions().mode(); + let bits = self.metadata.mode(); let has_bit = |bit| { bits & bit == bit }; f::Permissions { user_read: has_bit(modes::USER_READ), user_write: has_bit(modes::USER_WRITE), user_execute: has_bit(modes::USER_EXECUTE), + group_read: has_bit(modes::GROUP_READ), group_write: has_bit(modes::GROUP_WRITE), group_execute: has_bit(modes::GROUP_EXECUTE), + other_read: has_bit(modes::OTHER_READ), other_write: has_bit(modes::OTHER_WRITE), other_execute: has_bit(modes::OTHER_EXECUTE), + + sticky: has_bit(modes::STICKY), + setgid: has_bit(modes::SETGID), + setuid: has_bit(modes::SETUID), } } @@ -437,12 +443,18 @@ mod modes { pub const USER_READ: Mode = libc::S_IRUSR as Mode; pub const USER_WRITE: Mode = libc::S_IWUSR as Mode; pub const USER_EXECUTE: Mode = libc::S_IXUSR as Mode; + pub const GROUP_READ: Mode = libc::S_IRGRP as Mode; pub const GROUP_WRITE: Mode = libc::S_IWGRP as Mode; pub const GROUP_EXECUTE: Mode = libc::S_IXGRP as Mode; + pub const OTHER_READ: Mode = libc::S_IROTH as Mode; pub const OTHER_WRITE: Mode = libc::S_IWOTH as Mode; pub const OTHER_EXECUTE: Mode = libc::S_IXOTH as Mode; + + pub const STICKY: Mode = libc::S_ISVTX as Mode; + pub const SETGID: Mode = libc::S_ISGID as Mode; + pub const SETUID: Mode = libc::S_ISUID as Mode; } diff --git a/src/output/render/permissions.rs b/src/output/render/permissions.rs index 903b99d..aa6decb 100644 --- a/src/output/render/permissions.rs +++ b/src/output/render/permissions.rs @@ -79,9 +79,9 @@ pub mod test { details.colours.punctuation = Fixed(44).normal(); let bits = f::Permissions { - user_read: false, user_write: false, user_execute: false, - group_read: false, group_write: false, group_execute: false, - other_read: false, other_write: false, other_execute: false, + user_read: false, user_write: false, user_execute: false, setuid: false, + group_read: false, group_write: false, group_execute: false, setgid: false, + other_read: false, other_write: false, other_execute: false, sticky: false, }; let expected = TextCellContents::from(vec![ @@ -109,9 +109,9 @@ pub mod test { details.colours.perms.other_execute = Fixed(109).normal(); let bits = f::Permissions { - user_read: true, user_write: true, user_execute: true, - group_read: true, group_write: true, group_execute: true, - other_read: true, other_write: true, other_execute: true, + user_read: true, user_write: true, user_execute: true, setuid: false, + group_read: true, group_write: true, group_execute: true, setgid: false, + other_read: true, other_write: true, other_execute: true, sticky: false, }; let expected = TextCellContents::from(vec![