pxar: cleanup: move filesystem related magic numbers to tools/fs/magic.rs
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
parent
b335f5b713
commit
91451c4355
@ -224,8 +224,11 @@ impl <'a, W: Write> Encoder<'a, W> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn read_fat_attr(&self, fd: RawFd, magic: i64, entry: &mut CaFormatEntry) -> Result<(), Error> {
|
fn read_fat_attr(&self, fd: RawFd, magic: i64, entry: &mut CaFormatEntry) -> Result<(), Error> {
|
||||||
|
use fs::magic::*;
|
||||||
|
|
||||||
if magic != MSDOS_SUPER_MAGIC && magic != FUSE_SUPER_MAGIC { return Ok(()); }
|
if magic != MSDOS_SUPER_MAGIC && magic != FUSE_SUPER_MAGIC {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let mut attr: u32 = 0;
|
let mut attr: u32 = 0;
|
||||||
|
|
||||||
@ -429,7 +432,10 @@ impl <'a, W: Write> Encoder<'a, W> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
match magic {
|
match magic {
|
||||||
EXT4_SUPER_MAGIC | XFS_SUPER_MAGIC | FUSE_SUPER_MAGIC | ZFS_SUPER_MAGIC => {
|
fs::magic::EXT4_SUPER_MAGIC |
|
||||||
|
fs::magic::XFS_SUPER_MAGIC |
|
||||||
|
fs::magic::FUSE_SUPER_MAGIC |
|
||||||
|
fs::magic::ZFS_SUPER_MAGIC => {
|
||||||
let mut fsxattr = fs::FSXAttr::default();
|
let mut fsxattr = fs::FSXAttr::default();
|
||||||
let res = unsafe {
|
let res = unsafe {
|
||||||
fs::fs_ioc_fsgetxattr(fd, &mut fsxattr)
|
fs::fs_ioc_fsgetxattr(fd, &mut fsxattr)
|
||||||
@ -1108,10 +1114,12 @@ fn detect_fs_type(fd: RawFd) -> Result<i64, Error> {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn is_temporary_file_system(magic: i64) -> bool {
|
pub fn is_temporary_file_system(magic: i64) -> bool {
|
||||||
|
use fs::magic::*;
|
||||||
magic == RAMFS_MAGIC || magic == TMPFS_MAGIC
|
magic == RAMFS_MAGIC || magic == TMPFS_MAGIC
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_virtual_file_system(magic: i64) -> bool {
|
pub fn is_virtual_file_system(magic: i64) -> bool {
|
||||||
|
use fs::magic::*;
|
||||||
|
|
||||||
match magic {
|
match magic {
|
||||||
BINFMTFS_MAGIC |
|
BINFMTFS_MAGIC |
|
||||||
|
@ -389,35 +389,6 @@ pub fn ca_feature_flags_from_fat_attr(attr: u32) -> u64 {
|
|||||||
flags
|
flags
|
||||||
}
|
}
|
||||||
|
|
||||||
// from /usr/include/linux/magic.h
|
|
||||||
// and from casync util.h
|
|
||||||
pub const BINFMTFS_MAGIC: i64 = 0x42494e4d;
|
|
||||||
pub const CGROUP2_SUPER_MAGIC: i64 = 0x63677270;
|
|
||||||
pub const CGROUP_SUPER_MAGIC: i64 = 0x0027e0eb;
|
|
||||||
pub const CONFIGFS_MAGIC: i64 = 0x62656570;
|
|
||||||
pub const DEBUGFS_MAGIC: i64 = 0x64626720;
|
|
||||||
pub const DEVPTS_SUPER_MAGIC: i64 = 0x00001cd1;
|
|
||||||
pub const EFIVARFS_MAGIC: i64 = 0xde5e81e4;
|
|
||||||
pub const FUSE_CTL_SUPER_MAGIC: i64 = 0x65735543;
|
|
||||||
pub const HUGETLBFS_MAGIC: i64 = 0x958458f6;
|
|
||||||
pub const MQUEUE_MAGIC: i64 = 0x19800202;
|
|
||||||
pub const NFSD_MAGIC: i64 = 0x6e667364;
|
|
||||||
pub const PROC_SUPER_MAGIC: i64 = 0x00009fa0;
|
|
||||||
pub const PSTOREFS_MAGIC: i64 = 0x6165676C;
|
|
||||||
pub const RPCAUTH_GSSMAGIC: i64 = 0x67596969;
|
|
||||||
pub const SECURITYFS_MAGIC: i64 = 0x73636673;
|
|
||||||
pub const SELINUX_MAGIC: i64 = 0xf97cff8c;
|
|
||||||
pub const SMACK_MAGIC: i64 = 0x43415d53;
|
|
||||||
pub const RAMFS_MAGIC: i64 = 0x858458f6;
|
|
||||||
pub const TMPFS_MAGIC: i64 = 0x01021994;
|
|
||||||
pub const SYSFS_MAGIC: i64 = 0x62656572;
|
|
||||||
pub const MSDOS_SUPER_MAGIC: i64 = 0x00004d44;
|
|
||||||
pub const BTRFS_SUPER_MAGIC: i64 = 0x9123683E;
|
|
||||||
pub const FUSE_SUPER_MAGIC: i64 = 0x65735546;
|
|
||||||
pub const EXT4_SUPER_MAGIC: i64 = 0x0000EF53;
|
|
||||||
pub const XFS_SUPER_MAGIC: i64 = 0x58465342;
|
|
||||||
pub const ZFS_SUPER_MAGIC: i64 = 0x2FC12FC1;
|
|
||||||
|
|
||||||
/// Definitions of typical feature flags for the *pxar* encoder/decoder.
|
/// Definitions of typical feature flags for the *pxar* encoder/decoder.
|
||||||
/// By this expensive syscalls for unsupported features are avoided.
|
/// By this expensive syscalls for unsupported features are avoided.
|
||||||
|
|
||||||
@ -489,6 +460,8 @@ pub const CA_FORMAT_DEFAULT: u64 =
|
|||||||
|
|
||||||
/// Return the supported *pxar* feature flags based on the magic number of the filesystem.
|
/// Return the supported *pxar* feature flags based on the magic number of the filesystem.
|
||||||
pub fn feature_flags_from_magic(magic: i64) -> u64 {
|
pub fn feature_flags_from_magic(magic: i64) -> u64 {
|
||||||
|
use crate::tools::fs::magic::*;
|
||||||
|
|
||||||
match magic {
|
match magic {
|
||||||
MSDOS_SUPER_MAGIC => {
|
MSDOS_SUPER_MAGIC => {
|
||||||
CA_FORMAT_WITH_2SEC_TIME|
|
CA_FORMAT_WITH_2SEC_TIME|
|
||||||
|
@ -259,3 +259,5 @@ impl Default for FSXAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub (crate) mod magic;
|
||||||
|
30
src/tools/fs/magic.rs
Normal file
30
src/tools/fs/magic.rs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
//! Filesystem related magic numbers
|
||||||
|
|
||||||
|
// from /usr/include/linux/magic.h
|
||||||
|
// and from casync util.h
|
||||||
|
pub const BINFMTFS_MAGIC: i64 = 0x42494e4d;
|
||||||
|
pub const CGROUP2_SUPER_MAGIC: i64 = 0x63677270;
|
||||||
|
pub const CGROUP_SUPER_MAGIC: i64 = 0x0027e0eb;
|
||||||
|
pub const CONFIGFS_MAGIC: i64 = 0x62656570;
|
||||||
|
pub const DEBUGFS_MAGIC: i64 = 0x64626720;
|
||||||
|
pub const DEVPTS_SUPER_MAGIC: i64 = 0x00001cd1;
|
||||||
|
pub const EFIVARFS_MAGIC: i64 = 0xde5e81e4;
|
||||||
|
pub const FUSE_CTL_SUPER_MAGIC: i64 = 0x65735543;
|
||||||
|
pub const HUGETLBFS_MAGIC: i64 = 0x958458f6;
|
||||||
|
pub const MQUEUE_MAGIC: i64 = 0x19800202;
|
||||||
|
pub const NFSD_MAGIC: i64 = 0x6e667364;
|
||||||
|
pub const PROC_SUPER_MAGIC: i64 = 0x00009fa0;
|
||||||
|
pub const PSTOREFS_MAGIC: i64 = 0x6165676C;
|
||||||
|
pub const RPCAUTH_GSSMAGIC: i64 = 0x67596969;
|
||||||
|
pub const SECURITYFS_MAGIC: i64 = 0x73636673;
|
||||||
|
pub const SELINUX_MAGIC: i64 = 0xf97cff8c;
|
||||||
|
pub const SMACK_MAGIC: i64 = 0x43415d53;
|
||||||
|
pub const RAMFS_MAGIC: i64 = 0x858458f6;
|
||||||
|
pub const TMPFS_MAGIC: i64 = 0x01021994;
|
||||||
|
pub const SYSFS_MAGIC: i64 = 0x62656572;
|
||||||
|
pub const MSDOS_SUPER_MAGIC: i64 = 0x00004d44;
|
||||||
|
pub const BTRFS_SUPER_MAGIC: i64 = 0x9123683E;
|
||||||
|
pub const FUSE_SUPER_MAGIC: i64 = 0x65735546;
|
||||||
|
pub const EXT4_SUPER_MAGIC: i64 = 0x0000EF53;
|
||||||
|
pub const XFS_SUPER_MAGIC: i64 = 0x58465342;
|
||||||
|
pub const ZFS_SUPER_MAGIC: i64 = 0x2FC12FC1;
|
Loading…
Reference in New Issue
Block a user