pxar: move acl helper functions to src/tools/acl.rs

They are not only needed by the pxar::sequential_decoder but also for the fuse
xattr impl, so it makes more sense to have them there.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Christian Ebner 2020-01-28 12:42:21 +01:00 committed by Wolfgang Bumiller
parent 6f763ae673
commit bcf0d452c9
2 changed files with 19 additions and 16 deletions

View File

@ -272,19 +272,19 @@ impl<R: Read> SequentialDecoder<R> {
acl.add_entry_full(
acl::ACL_USER_OBJ,
None,
mode_user_to_acl_permissions(entry.mode),
acl::mode_user_to_acl_permissions(entry.mode),
)?;
acl.add_entry_full(
acl::ACL_OTHER,
None,
mode_other_to_acl_permissions(entry.mode),
acl::mode_other_to_acl_permissions(entry.mode),
)?;
match &attr.acl_group_obj {
Some(group_obj) => {
acl.add_entry_full(
acl::ACL_MASK,
None,
mode_group_to_acl_permissions(entry.mode),
acl::mode_group_to_acl_permissions(entry.mode),
)?;
acl.add_entry_full(acl::ACL_GROUP_OBJ, None, group_obj.permissions)?;
}
@ -292,7 +292,7 @@ impl<R: Read> SequentialDecoder<R> {
acl.add_entry_full(
acl::ACL_GROUP_OBJ,
None,
mode_group_to_acl_permissions(entry.mode),
acl::mode_group_to_acl_permissions(entry.mode),
)?;
}
}
@ -1175,15 +1175,3 @@ fn nsec_to_update_timespec(mtime_nsec: u64) -> [libc::timespec; 2] {
times
}
fn mode_user_to_acl_permissions(mode: u64) -> u64 {
(mode >> 6) & 7
}
fn mode_group_to_acl_permissions(mode: u64) -> u64 {
(mode >> 3) & 7
}
fn mode_other_to_acl_permissions(mode: u64) -> u64 {
mode & 7
}

View File

@ -270,3 +270,18 @@ impl<'a> Iterator for &'a mut ACLEntriesIterator {
None
}
}
/// Helper to transform `PxarEntry`s user mode to acl permissions.
pub fn mode_user_to_acl_permissions(mode: u64) -> u64 {
(mode >> 6) & 7
}
/// Helper to transform `PxarEntry`s group mode to acl permissions.
pub fn mode_group_to_acl_permissions(mode: u64) -> u64 {
(mode >> 3) & 7
}
/// Helper to transform `PxarEntry`s other mode to acl permissions.
pub fn mode_other_to_acl_permissions(mode: u64) -> u64 {
mode & 7
}