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:
parent
6f763ae673
commit
bcf0d452c9
@ -272,19 +272,19 @@ impl<R: Read> SequentialDecoder<R> {
|
|||||||
acl.add_entry_full(
|
acl.add_entry_full(
|
||||||
acl::ACL_USER_OBJ,
|
acl::ACL_USER_OBJ,
|
||||||
None,
|
None,
|
||||||
mode_user_to_acl_permissions(entry.mode),
|
acl::mode_user_to_acl_permissions(entry.mode),
|
||||||
)?;
|
)?;
|
||||||
acl.add_entry_full(
|
acl.add_entry_full(
|
||||||
acl::ACL_OTHER,
|
acl::ACL_OTHER,
|
||||||
None,
|
None,
|
||||||
mode_other_to_acl_permissions(entry.mode),
|
acl::mode_other_to_acl_permissions(entry.mode),
|
||||||
)?;
|
)?;
|
||||||
match &attr.acl_group_obj {
|
match &attr.acl_group_obj {
|
||||||
Some(group_obj) => {
|
Some(group_obj) => {
|
||||||
acl.add_entry_full(
|
acl.add_entry_full(
|
||||||
acl::ACL_MASK,
|
acl::ACL_MASK,
|
||||||
None,
|
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)?;
|
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.add_entry_full(
|
||||||
acl::ACL_GROUP_OBJ,
|
acl::ACL_GROUP_OBJ,
|
||||||
None,
|
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
|
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
|
|
||||||
}
|
|
||||||
|
@ -270,3 +270,18 @@ impl<'a> Iterator for &'a mut ACLEntriesIterator {
|
|||||||
None
|
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
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user