From 92caf51634176b3ef7ec8227252b0497d7f548f7 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 22 Nov 2021 13:36:55 +0100 Subject: [PATCH] proxmox-sys: split xattr code into extra file Signed-off-by: Dietmar Maurer --- proxmox-sys/src/fs/fsx_attr.rs | 39 +++++++++++++++++++++++++++++++++ proxmox-sys/src/fs/mod.rs | 3 +++ proxmox-sys/src/fs/read_dir.rs | 40 ---------------------------------- 3 files changed, 42 insertions(+), 40 deletions(-) create mode 100644 proxmox-sys/src/fs/fsx_attr.rs diff --git a/proxmox-sys/src/fs/fsx_attr.rs b/proxmox-sys/src/fs/fsx_attr.rs new file mode 100644 index 00000000..d393cfe3 --- /dev/null +++ b/proxmox-sys/src/fs/fsx_attr.rs @@ -0,0 +1,39 @@ +// /usr/include/linux/fs.h: #define FS_IOC_GETFLAGS _IOR('f', 1, long) +// read Linux file system attributes (see man chattr) +nix::ioctl_read!(read_attr_fd, b'f', 1, libc::c_long); +nix::ioctl_write_ptr!(write_attr_fd, b'f', 2, libc::c_long); + +// /usr/include/linux/msdos_fs.h: #define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u32) +// read FAT file system attributes +nix::ioctl_read!(read_fat_attr_fd, b'r', 0x10, u32); +nix::ioctl_write_ptr!(write_fat_attr_fd, b'r', 0x11, u32); + +// From /usr/include/linux/fs.h +// #define FS_IOC_FSGETXATTR _IOR('X', 31, struct fsxattr) +// #define FS_IOC_FSSETXATTR _IOW('X', 32, struct fsxattr) +nix::ioctl_read!(fs_ioc_fsgetxattr, b'X', 31, FSXAttr); +nix::ioctl_write_ptr!(fs_ioc_fssetxattr, b'X', 32, FSXAttr); + +#[repr(C)] +#[derive(Debug)] +pub struct FSXAttr { + pub fsx_xflags: u32, + pub fsx_extsize: u32, + pub fsx_nextents: u32, + pub fsx_projid: u32, + pub fsx_cowextsize: u32, + pub fsx_pad: [u8; 8], +} + +impl Default for FSXAttr { + fn default() -> Self { + FSXAttr { + fsx_xflags: 0u32, + fsx_extsize: 0u32, + fsx_nextents: 0u32, + fsx_projid: 0u32, + fsx_cowextsize: 0u32, + fsx_pad: [0u8; 8], + } + } +} diff --git a/proxmox-sys/src/fs/mod.rs b/proxmox-sys/src/fs/mod.rs index 1cb1681b..84a3fa85 100644 --- a/proxmox-sys/src/fs/mod.rs +++ b/proxmox-sys/src/fs/mod.rs @@ -18,6 +18,9 @@ pub use dir::*; mod read_dir; pub use read_dir::*; +mod fsx_attr; +pub use fsx_attr::*; + /// Change ownership of an open file handle pub fn fchown(fd: RawFd, owner: Option, group: Option) -> Result<(), Error> { // According to the POSIX specification, -1 is used to indicate that owner and group diff --git a/proxmox-sys/src/fs/read_dir.rs b/proxmox-sys/src/fs/read_dir.rs index 8cfc5eff..1c06d8f4 100644 --- a/proxmox-sys/src/fs/read_dir.rs +++ b/proxmox-sys/src/fs/read_dir.rs @@ -258,46 +258,6 @@ where } } -// /usr/include/linux/fs.h: #define FS_IOC_GETFLAGS _IOR('f', 1, long) -// read Linux file system attributes (see man chattr) -nix::ioctl_read!(read_attr_fd, b'f', 1, libc::c_long); -nix::ioctl_write_ptr!(write_attr_fd, b'f', 2, libc::c_long); - -// /usr/include/linux/msdos_fs.h: #define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u32) -// read FAT file system attributes -nix::ioctl_read!(read_fat_attr_fd, b'r', 0x10, u32); -nix::ioctl_write_ptr!(write_fat_attr_fd, b'r', 0x11, u32); - -// From /usr/include/linux/fs.h -// #define FS_IOC_FSGETXATTR _IOR('X', 31, struct fsxattr) -// #define FS_IOC_FSSETXATTR _IOW('X', 32, struct fsxattr) -nix::ioctl_read!(fs_ioc_fsgetxattr, b'X', 31, FSXAttr); -nix::ioctl_write_ptr!(fs_ioc_fssetxattr, b'X', 32, FSXAttr); - -#[repr(C)] -#[derive(Debug)] -pub struct FSXAttr { - pub fsx_xflags: u32, - pub fsx_extsize: u32, - pub fsx_nextents: u32, - pub fsx_projid: u32, - pub fsx_cowextsize: u32, - pub fsx_pad: [u8; 8], -} - -impl Default for FSXAttr { - fn default() -> Self { - FSXAttr { - fsx_xflags: 0u32, - fsx_extsize: 0u32, - fsx_nextents: 0u32, - fsx_projid: 0u32, - fsx_cowextsize: 0u32, - fsx_pad: [0u8; 8], - } - } -} - /// Attempt to acquire a shared flock on the given path, 'what' and /// 'would_block_message' are used for error formatting. pub fn lock_dir_noblock_shared(