Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

libmount: add statfs_magic.h

Signed-off-by: Karel Zak <kzak@redhat.com>
  • Loading branch information...
commit df019e9be7587e3b966a5b1a8490a4a17e9191f4 1 parent 65acdc8
@karelzak authored
Showing with 164 additions and 75 deletions.
  1. +2 −1  include/Makemodule.am
  2. +88 −0 include/statfs_magic.h
  3. +74 −74 libmount/src/utils.c
View
3  include/Makemodule.am
@@ -52,4 +52,5 @@ dist_noinst_HEADERS += \
include/pt-bsd.h \
include/pt-mbr.h \
include/pt-mbr-partnames.h \
- include/pt-sun.h
+ include/pt-sun.h \
+ include/statfs_magic.h
View
88 include/statfs_magic.h
@@ -0,0 +1,88 @@
+#ifndef UTIL_LINUX_STATFS_MAGIC_H
+#define UTIL_LINUX_STATFS_MAGIC_H
+
+/*
+ * Unfortunately, Linux kernel hedeader file <linux/magic.h> is incomplete
+ * mess and kernel returns by statfs f_type many numbers that are nowhere
+ * specified (in API).
+ *
+ * This is collection of the magic numbers.
+ */
+#define STATFS_ADFS_MAGIC 0xadf5
+#define STATFS_AFFS_MAGIC 0xadff
+#define STATFS_AFS_MAGIC 0x5346414F
+#define STATFS_AUTOFS_MAGIC 0x0187
+#define STATFS_BDEVFS_MAGIC 0x62646576
+#define STATFS_BEFS_MAGIC 0x42465331
+#define STATFS_BFS_MAGIC 0x1BADFACE
+#define STATFS_BINFMTFS_MAGIC 0x42494e4d
+#define STATFS_BTRFS_MAGIC 0x9123683E
+#define STATFS_CEPH_MAGIC 0x00c36400
+#define STATFS_CGROUP_MAGIC 0x27e0eb
+#define STATFS_CIFS_MAGIC 0xff534d42
+#define STATFS_CODA_MAGIC 0x73757245
+#define STATFS_CONFIGFS_MAGIC 0x62656570
+#define STATFS_CRAMFS_MAGIC 0x28cd3d45
+#define STATFS_DEBUGFS_MAGIC 0x64626720
+#define STATFS_DEVPTS_MAGIC 0x1cd1
+#define STATFS_ECRYPTFS_MAGIC 0xf15f
+#define STATFS_EFIVARFS_MAGIC 0xde5e81e4
+#define STATFS_EFS_MAGIC 0x414A53
+#define STATFS_EXOFS_MAGIC 0x5DF5
+#define STATFS_EXT2_MAGIC 0xEF53
+#define STATFS_EXT3_MAGIC 0xEF53
+#define STATFS_EXT4_MAGIC 0xEF53
+#define STATFS_F2FS_MAGIC 0xF2F52010
+#define STATFS_FUSE_MAGIC 0x65735546
+#define STATFS_FUTEXFS_MAGIC 0xBAD1DEA
+#define STATFS_GFS2_MAGIC 0x01161970
+#define STATFS_HFSPLUS_MAGIC 0x482b
+#define STATFS_HOSTFS_MAGIC 0x00c0ffee
+#define STATFS_HPFS_MAGIC 0xf995e849
+#define STATFS_HPPFS_MAGIC 0xb00000ee
+#define STATFS_HUGETLBFS_MAGIC 0x958458f6
+#define STATFS_ISOFS_MAGIC 0x9660
+#define STATFS_JFFS2_MAGIC 0x72b6
+#define STATFS_JFS_MAGIC 0x3153464a
+#define STATFS_LOGFS_MAGIC 0xc97e8168
+#define STATFS_MINIX2_MAGIC 0x2468
+#define STATFS_MINIX2_MAGIC2 0x2478
+#define STATFS_MINIX3_MAGIC 0x4d5a
+#define STATFS_MINIX_MAGIC 0x137F
+#define STATFS_MINIX_MAGIC2 0x138F
+#define STATFS_MQUEUE_MAGIC 0x19800202
+#define STATFS_MSDOS_MAGIC 0x4d44
+#define STATFS_NCP_MAGIC 0x564c
+#define STATFS_NFS_MAGIC 0x6969
+#define STATFS_NILFS_MAGIC 0x3434
+#define STATFS_NTFS_MAGIC 0x5346544e
+#define STATFS_OCFS2_MAGIC 0x7461636f
+#define STATFS_OMFS_MAGIC 0xC2993D87
+#define STATFS_OPENPROMFS_MAGIC 0x9fa1
+#define STATFS_PIPEFS_MAGIC 0x50495045
+#define STATFS_PROC_MAGIC 0x9fa0
+#define STATFS_PSTOREFS_MAGIC 0x6165676C
+#define STATFS_QNX4_MAGIC 0x002f
+#define STATFS_QNX6_MAGIC 0x68191122
+#define STATFS_RAMFS_MAGIC 0x858458f6
+#define STATFS_REISERFS_MAGIC 0x52654973
+#define STATFS_ROMFS_MAGIC 0x7275
+#define STATFS_SECURITYFS_MAGIC 0x73636673
+#define STATFS_SELINUXFS_MAGIC 0xf97cff8c
+#define STATFS_SMACKFS_MAGIC 0x43415d53
+#define STATFS_SMB_MAGIC 0x517B
+#define STATFS_SOCKFS_MAGIC 0x534F434B
+#define STATFS_SQUASHFS_MAGIC 0x73717368
+#define STATFS_SYSFS_MAGIC 0x62656572
+#define STATFS_TMPFS_MAGIC 0x01021994
+#define STATFS_UBIFS_MAGIC 0x24051905
+#define STATFS_UDF_MAGIC 0x15013346
+#define STATFS_UFS2_MAGIC 0x19540119
+#define STATFS_UFS_MAGIC 0x00011954
+#define STATFS_V9FS_MAGIC 0x01021997
+#define STATFS_VXFS_MAGIC 0xa501FCF5
+#define STATFS_XENFS_MAGIC 0xabba1974
+#define STATFS_XFS_MAGIC 0x58465342
+
+#endif /* UTIL_LINUX_STATFS_MAGIC_H */
+
View
148 libmount/src/utils.c
@@ -15,7 +15,6 @@
#include <pwd.h>
#include <grp.h>
#include <blkid.h>
-#include <linux/magic.h>
#include "strutils.h"
#include "pathnames.h"
@@ -24,6 +23,7 @@
#include "canonicalize.h"
#include "env.h"
#include "match.h"
+#include "statfs_magic.h"
int append_string(char **a, const char *b)
{
@@ -321,84 +321,84 @@ int mnt_fstype_is_netfs(const char *type)
return 0;
}
-#ifndef CIFS_SUPER_MAGIC
-# define CIFS_SUPER_MAGIC 0xFF534D42
-#endif
-#ifndef XFS_SUPER_MAGIC
-# define XFS_SUPER_MAGIC 0x58465342
-#endif
-#ifndef MQUEUE_SUPER_MAGIC
-# define MQUEUE_SUPER_MAGIC 0x19800202
-#endif
-#ifndef CONFIGFS_SUPER_MAGIC
-# define CONFIGFS_SUPER_MAGIC 0x62656570
-#endif
-#ifndef BTRFS_TEST_MAGIC
-# define BTRFS_TEST_MAGIC 0x73727279
-#endif
-
const char *mnt_statfs_get_fstype(struct statfs *vfs)
{
assert(vfs);
switch (vfs->f_type) {
- case ADFS_SUPER_MAGIC: return "adfs";
- case AFFS_SUPER_MAGIC: return "affs";
- case AFS_SUPER_MAGIC: return "afs";
- case AUTOFS_SUPER_MAGIC: return "autofs";
- case CIFS_SUPER_MAGIC: return "cifs";
- case CODA_SUPER_MAGIC: return "coda";
- case CRAMFS_MAGIC: return "cramfs";
- case DEBUGFS_MAGIC: return "debugfs";
- case SECURITYFS_MAGIC: return "securityfs";
- case SELINUX_MAGIC: return "selinuxfs";
- case SMACK_MAGIC: return "smackfs";
- case RAMFS_MAGIC: return "ramfs";
- case TMPFS_MAGIC: return "tmpfs";
- case HUGETLBFS_MAGIC: return "hugetlbfs";
- case SQUASHFS_MAGIC: return "squashfs";
- case ECRYPTFS_SUPER_MAGIC: return "ecryptfs";
- case EFS_SUPER_MAGIC: return "efs";
- case EXT4_SUPER_MAGIC: return "ext4";
- case BTRFS_SUPER_MAGIC: return "btrfs";
- case NILFS_SUPER_MAGIC: return "nilfs2";
- case F2FS_SUPER_MAGIC: return "f2fs";
- case HPFS_SUPER_MAGIC: return "hpfs";
- case ISOFS_SUPER_MAGIC: return "iso9660";
- case JFFS2_SUPER_MAGIC: return "jffs";
- case EFIVARFS_MAGIC: return "efivarfs";
- case HOSTFS_SUPER_MAGIC: return "hostfs";
-
- case MINIX_SUPER_MAGIC:
- case MINIX_SUPER_MAGIC2:
- case MINIX2_SUPER_MAGIC: return "minix";
-
- case MSDOS_SUPER_MAGIC: return "vfat";
- case NCP_SUPER_MAGIC: return "ncp";
- case NFS_SUPER_MAGIC: return "nfs";
- case OPENPROM_SUPER_MAGIC: return "openprom";
- case PROC_SUPER_MAGIC: return "proc";
- case SOCKFS_MAGIC: return "sockfs";
- case SYSFS_MAGIC: return "sysfs";
- case USBDEVICE_SUPER_MAGIC: return "usbdevice";
- case CGROUP_SUPER_MAGIC: return "cgroup";
- case PSTOREFS_MAGIC: return "pstore";
- case BINFMTFS_MAGIC: return "binfmt_misc";
- case XENFS_SUPER_MAGIC: return "xenfs";
-
- case QNX4_SUPER_MAGIC: return "qnx4";
- case QNX6_SUPER_MAGIC: return "qnx4";
- case REISERFS_SUPER_MAGIC: return "reiser4";
- case SMB_SUPER_MAGIC: return "smb";
-
- case DEVPTS_SUPER_MAGIC: return "devpts";
- case FUTEXFS_SUPER_MAGIC: return "futexfs";
- case PIPEFS_MAGIC: return "pipefs";
- case MQUEUE_SUPER_MAGIC: return "mqueue";
- case CONFIGFS_SUPER_MAGIC: return "configfs";
-
- case BTRFS_TEST_MAGIC: return "btrfs";
- case XFS_SUPER_MAGIC: return "xfs";
+ case STATFS_ADFS_MAGIC: return "adfs";
+ case STATFS_AFFS_MAGIC: return "affs";
+ case STATFS_AFS_MAGIC: return "afs";
+ case STATFS_AUTOFS_MAGIC: return "autofs";
+ case STATFS_BDEVFS_MAGIC: return "bdev";
+ case STATFS_BEFS_MAGIC: return "befs";
+ case STATFS_BFS_MAGIC: return "befs";
+ case STATFS_BINFMTFS_MAGIC: return "binfmt_misc";
+ case STATFS_BTRFS_MAGIC: return "btrfs";
+ case STATFS_CEPH_MAGIC: return "ceph";
+ case STATFS_CGROUP_MAGIC: return "cgroup";
+ case STATFS_CIFS_MAGIC: return "cifs";
+ case STATFS_CODA_MAGIC: return "coda";
+ case STATFS_CONFIGFS_MAGIC: return "configfs";
+ case STATFS_CRAMFS_MAGIC: return "cramfs";
+ case STATFS_DEBUGFS_MAGIC: return "debugfs";
+ case STATFS_DEVPTS_MAGIC: return "devpts";
+ case STATFS_ECRYPTFS_MAGIC: return "ecryptfs";
+ case STATFS_EFIVARFS_MAGIC: return "efivarfs";
+ case STATFS_EFS_MAGIC: return "efs";
+ case STATFS_EXOFS_MAGIC: return "exofs";
+ case STATFS_EXT4_MAGIC: return "ext4"; /* all extN use the same magic */
+ case STATFS_F2FS_MAGIC: return "f2fs";
+ case STATFS_FUSE_MAGIC: return "fuse";
+ case STATFS_FUTEXFS_MAGIC: return "futexfs";
+ case STATFS_GFS2_MAGIC: return "gfs2";
+ case STATFS_HFSPLUS_MAGIC: return "hfsplus";
+ case STATFS_HOSTFS_MAGIC: return "hostfs";
+ case STATFS_HPFS_MAGIC: return "hpfs";
+ case STATFS_HPPFS_MAGIC: return "hppfs";
+ case STATFS_HUGETLBFS_MAGIC: return "hugetlbfs";
+ case STATFS_ISOFS_MAGIC: return "iso9660";
+ case STATFS_JFFS2_MAGIC: return "jffs2";
+ case STATFS_JFS_MAGIC: return "jfs";
+ case STATFS_LOGFS_MAGIC: return "logfs";
+ case STATFS_MINIX2_MAGIC:
+ case STATFS_MINIX2_MAGIC2:
+ case STATFS_MINIX3_MAGIC:
+ case STATFS_MINIX_MAGIC:
+ case STATFS_MINIX_MAGIC2: return "minix";
+ case STATFS_MQUEUE_MAGIC: return "mqueue";
+ case STATFS_MSDOS_MAGIC: return "vfat";
+ case STATFS_NCP_MAGIC: return "ncp";
+ case STATFS_NFS_MAGIC: return "nfs";
+ case STATFS_NILFS_MAGIC: return "nilfs2";
+ case STATFS_NTFS_MAGIC: return "ntfs";
+ case STATFS_OCFS2_MAGIC: return "ocfs2";
+ case STATFS_OMFS_MAGIC: return "omfs";
+ case STATFS_OPENPROMFS_MAGIC: return "openpromfs";
+ case STATFS_PIPEFS_MAGIC: return "pipefs";
+ case STATFS_PROC_MAGIC: return "proc";
+ case STATFS_PSTOREFS_MAGIC: return "pstore";
+ case STATFS_QNX4_MAGIC: return "qnx4";
+ case STATFS_QNX6_MAGIC: return "qnx6";
+ case STATFS_RAMFS_MAGIC: return "ramfs";
+ case STATFS_REISERFS_MAGIC: return "reiser4";
+ case STATFS_ROMFS_MAGIC: return "romfs";
+ case STATFS_SECURITYFS_MAGIC: return "securityfs";
+ case STATFS_SELINUXFS_MAGIC: return "selinuxfs";
+ case STATFS_SMACKFS_MAGIC: return "smackfs";
+ case STATFS_SMB_MAGIC: return "smb";
+ case STATFS_SOCKFS_MAGIC: return "sockfs";
+ case STATFS_SQUASHFS_MAGIC: return "squashfs";
+ case STATFS_SYSFS_MAGIC: return "sysfs";
+ case STATFS_TMPFS_MAGIC: return "tmpfs";
+ case STATFS_UBIFS_MAGIC: return "ubifs";
+ case STATFS_UDF_MAGIC: return "udf";
+ case STATFS_UFS2_MAGIC:
+ case STATFS_UFS_MAGIC: return "ufs";
+ case STATFS_V9FS_MAGIC: return "9p";
+ case STATFS_VXFS_MAGIC: return "vxfs";
+ case STATFS_XENFS_MAGIC: return "xenfs";
+ case STATFS_XFS_MAGIC: return "xfs";
default:
break;
}

0 comments on commit df019e9

Please sign in to comment.
Something went wrong with that request. Please try again.