/*
==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--

Dia-Files

Copyright (C) 2019-2024  Anonymous

There are several releases over multiple years,
they are listed as ranges, such as: "2019-2024".

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

::--::--::--::--::--::--::--::--::--::--::--::--::--::--::--::--
*/

//! # File System

/// # File System
///
/// ## References
///
/// - `statfs(2)`
#[derive(Debug, Hash, Eq, PartialEq)]
pub enum FileSystem {

    /// # `libc::ADFS_SUPER_MAGIC`
    ADFSSuper,

    /// # `libc::AFFS_SUPER_MAGIC`
    AFFSSuper,

    /// # `libc::AFS_SUPER_MAGIC`
    AFSSuper,

    /// # `libc::AUTOFS_SUPER_MAGIC`
    AutoFSSuper,

    /// # `libc::BPF_FS_MAGIC`
    BpfFS,

    /// # `libc::BTRFS_SUPER_MAGIC`
    BtrFSSuper,

    /// # `libc::CGROUP_SUPER_MAGIC`
    CgroupSuper,

    /// # `libc::CGROUP2_SUPER_MAGIC`
    Cgroup2Super,

    /// # `libc::CODA_SUPER_MAGIC`
    CodaSuper,

    /// # `libc::CRAMFS_MAGIC`
    CramFS,

    /// # `libc::DEBUGFS_MAGIC`
    DebugFS,

    /// # `libc::DEVPTS_SUPER_MAGIC`
    DevPtsSuper,

    /// # `libc::ECRYPTFS_SUPER_MAGIC`
    EcryptFSSuper,

    /// # `libc::EFS_SUPER_MAGIC`
    EFSSuper,

    /// # `libc::EXT4_SUPER_MAGIC`
    Ext234Super,

    /// # `libc::F2FS_SUPER_MAGIC`
    F2FSSuper,

    /// # `libc::FUSE_SUPER_MAGIC`
    FuseSuper,

    /// # `libc::FUTEXFS_SUPER_MAGIC`
    FutexFSSuper,

    /// # `libc::HOSTFS_SUPER_MAGIC`
    HostFSSuper,

    /// # `libc::HPFS_SUPER_MAGIC`
    HPFSSuper,

    /// # `libc::HUGETLBFS_MAGIC`
    HugeTLBFS,

    /// # `libc::ISOFS_SUPER_MAGIC`
    IsoFSSuper,

    /// # `libc::JFFS2_SUPER_MAGIC`
    JFFS2Super,

    /// # `libc::MINIX_SUPER_MAGIC`
    MINIXSuper,

    /// # `libc::MINIX_SUPER_MAGIC2`
    MINIXSuper2,

    /// # `libc::MINIX2_SUPER_MAGIC`
    MINIX2Super,

    /// # `libc::MINIX2_SUPER_MAGIC2`
    MINIX2Super2,

    /// # `libc::MINIX3_SUPER_MAGIC`
    MINIX3Super,

    /// # `libc::MSDOS_SUPER_MAGIC`
    MSDOSSuper,

    /// # `libc::NCP_SUPER_MAGIC`
    NCPSuper,

    /// # `libc::NFS_SUPER_MAGIC`
    NFSSuper,

    /// # `libc::NILFS_SUPER_MAGIC`
    NILFSSuper,

    /// # `libc::NSFS_MAGIC`
    NSFS,

    /// # `libc::OCFS2_SUPER_MAGIC`
    OCFS2Super,

    /// # `libc::OPENPROM_SUPER_MAGIC`
    OpenPROMSuper,

    /// # `libc::OVERLAYFS_SUPER_MAGIC`
    OverlayFSSuper,

    /// # `libc::PROC_SUPER_MAGIC`
    ProcSuper,

    /// # `libc::QNX4_SUPER_MAGIC`
    QNX4Super,

    /// # `libc::QNX6_SUPER_MAGIC`
    QNX6Super,

    /// # `libc::REISERFS_SUPER_MAGIC`
    ReiserFSSuper,

    /// # `libc::SECURITYFS_MAGIC`
    SecurityFS,

    /// # `libc::SELINUX_MAGIC`
    SELinux,

    /// # `libc::SMACK_MAGIC`
    Smack,

    /// # `libc::SMB_SUPER_MAGIC`
    SMBSuper,

    /// # `libc::SYSFS_MAGIC`
    SysFS,

    /// # `libc::TMPFS_MAGIC`
    TmpFS,

    /// # `libc::TRACEFS_MAGIC`
    TraceFS,

    /// # `libc::UDF_SUPER_MAGIC`
    UDFSuper,

    /// # `libc::USBDEVICE_SUPER_MAGIC`
    USBDeviceSuper,

    /// # `libc::XENFS_SUPER_MAGIC`
    XENFSSuper,

    /// # `libc::XFS_SUPER_MAGIC`
    XFSSuper,

    /// # Unknown
    Unknown,

}

impl FileSystem {

    /// # Magic ID from `libc`
    #[cfg(all(feature="libc", unix))]
    #[doc(cfg(all(feature="libc", unix)))]
    pub const fn magic_id(&self) -> i64 {
        match self {
            Self::ADFSSuper => libc::ADFS_SUPER_MAGIC,
            Self::AFFSSuper => libc::AFFS_SUPER_MAGIC,
            Self::AFSSuper => libc::AFS_SUPER_MAGIC,
            Self::AutoFSSuper => libc::AUTOFS_SUPER_MAGIC,
            Self::BpfFS => libc::BPF_FS_MAGIC,
            Self::BtrFSSuper => libc::BTRFS_SUPER_MAGIC,
            Self::CgroupSuper => libc::CGROUP_SUPER_MAGIC,
            Self::Cgroup2Super => libc::CGROUP2_SUPER_MAGIC,
            Self::CodaSuper => libc::CODA_SUPER_MAGIC,
            Self::CramFS => libc::CRAMFS_MAGIC,
            Self::DebugFS => libc::DEBUGFS_MAGIC,
            Self::DevPtsSuper => libc::DEVPTS_SUPER_MAGIC,
            Self::EcryptFSSuper => libc::ECRYPTFS_SUPER_MAGIC,
            Self::EFSSuper => libc::EFS_SUPER_MAGIC,
            Self::Ext234Super => libc::EXT4_SUPER_MAGIC,
            Self::F2FSSuper => libc::F2FS_SUPER_MAGIC,
            Self::FuseSuper => libc::FUSE_SUPER_MAGIC,
            Self::FutexFSSuper => libc::FUTEXFS_SUPER_MAGIC,
            Self::HostFSSuper => libc::HOSTFS_SUPER_MAGIC,
            Self::HPFSSuper => libc::HPFS_SUPER_MAGIC,
            Self::HugeTLBFS => libc::HUGETLBFS_MAGIC,
            Self::IsoFSSuper => libc::ISOFS_SUPER_MAGIC,
            Self::JFFS2Super => libc::JFFS2_SUPER_MAGIC,
            Self::MINIXSuper => libc::MINIX_SUPER_MAGIC,
            Self::MINIXSuper2 => libc::MINIX_SUPER_MAGIC2,
            Self::MINIX2Super => libc::MINIX2_SUPER_MAGIC,
            Self::MINIX2Super2 => libc::MINIX2_SUPER_MAGIC2,
            Self::MINIX3Super => libc::MINIX3_SUPER_MAGIC,
            Self::MSDOSSuper => libc::MSDOS_SUPER_MAGIC,
            Self::NCPSuper => libc::NCP_SUPER_MAGIC,
            Self::NFSSuper => libc::NFS_SUPER_MAGIC,
            Self::NILFSSuper => libc::NILFS_SUPER_MAGIC,
            Self::NSFS => libc::NSFS_MAGIC,
            Self::OCFS2Super => libc::OCFS2_SUPER_MAGIC,
            Self::OpenPROMSuper => libc::OPENPROM_SUPER_MAGIC,
            Self::OverlayFSSuper => libc::OVERLAYFS_SUPER_MAGIC,
            Self::ProcSuper => libc::PROC_SUPER_MAGIC,
            Self::QNX4Super => libc::QNX4_SUPER_MAGIC,
            Self::QNX6Super => libc::QNX6_SUPER_MAGIC,
            Self::ReiserFSSuper => libc::REISERFS_SUPER_MAGIC,
            Self::SecurityFS => libc::SECURITYFS_MAGIC,
            Self::SELinux => libc::SELINUX_MAGIC,
            Self::Smack => libc::SMACK_MAGIC,
            Self::SMBSuper => libc::SMB_SUPER_MAGIC,
            Self::SysFS => libc::SYSFS_MAGIC,
            Self::TmpFS => libc::TMPFS_MAGIC,
            Self::TraceFS => libc::TRACEFS_MAGIC,
            Self::UDFSuper => libc::UDF_SUPER_MAGIC,
            Self::USBDeviceSuper => libc::USBDEVICE_SUPER_MAGIC,
            Self::XENFSSuper => libc::XENFS_SUPER_MAGIC,
            Self::XFSSuper => libc::XFS_SUPER_MAGIC,
            Self::Unknown => 0,
        }
    }

}
