[PATCH 2/2] stat: add support for many more file system types

From: Jim Meyering
Date: Thu Oct 08 2009 - 04:06:42 EST


* src/stat.c (human_fstype): Add the following FS types,
from <linux/magic.h>: afs, anon-inode FS, btrfs, cgroupfs,
cramfs-wend, debugfs, futexfs, inotifyfs, minux3, securityfs,
selinux, xenfs.
Also add "nilfs".
* src/Makefile.am (fs-kernel-magic): New rule.
---
src/Makefile.am | 32 ++++++++++++++++++++++++++++----
src/stat.c | 28 +++++++++++++++++++++++++++-
2 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 3bba86d..0c70914 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -333,14 +333,16 @@ AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
# Compare fs.h with the list of file system names/magic-numbers in the
# Linux statfs man page. This target prints any new name/number pairs.
.PHONY: fs-magic-compare
-fs-magic-compare: fs-magic fs-def
+fs-magic-compare: fs-magic fs-kernel-magic fs-def
join -v1 -t@ fs-magic fs-def
+ join -v1 -t@ fs-kernel-magic fs-def

-CLEANFILES += fs-magic fs-def
+CLEANFILES += fs-def
fs-def: fs.h
grep '^# *define ' $< > $@-t && mv $@-t $@

-fs-magic:
+CLEANFILES += fs-magic
+fs-magic: Makefile
man statfs \
|perl -ne '/File system types:/.../Nobody kno/ and print' \
|grep 0x | perl -p \
@@ -357,7 +359,29 @@ fs-magic:
-e 's/NTFS_SB/NTFS/;' \
-e 's/^/# define S_MAGIC_/;' \
-e 's,\s*/\* .*? \*/,,;' \
- | grep -v S_MAGIC_EXT3 \
+ | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
+ | LC_ALL=C sort \
+ > $@-t && mv $@-t $@
+
+CLEANFILES += fs-kernel-magic
+fs-kernel-magic: Makefile
+ perl -ne '/^#define.*0x/ and print' /usr/include/linux/magic.h \
+ | perl -p \
+ -e 's/MINIX_SUPER_MAGIC\b/MINIX/;' \
+ -e 's/MINIX_SUPER_MAGIC2\b/MINIX_30/;' \
+ -e 's/MINIX2_SUPER_MAGIC\b/MINIX_V2/;' \
+ -e 's/MINIX2_SUPER_MAGIC2\b/MINIX_V2_30/;' \
+ -e 's/MINIX3_SUPER_MAGIC\b/MINIX_V3/;' \
+ -e 's/(_SUPER)?_MAGIC//;' \
+ -e 's/\s+0x(\S+)/" 0x" . uc $$1/e;' \
+ -e 's/(\s+0x)(\X{3})\b/$${1}0$$2/;' \
+ -e 's/(\s+0x)(\X{6})\b/$${1}00$$2/;' \
+ -e 's/(\s+0x)(\X{7})\b/$${1}0$$2/;' \
+ -e 's/^#define\s+//;' \
+ -e 's/^USBDEVICE/USBDEVFS/;' \
+ -e 's/^/# define S_MAGIC_/;' \
+ -e 's,\s*/\* .*? \*/,,;' \
+ | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
| LC_ALL=C sort \
> $@-t && mv $@-t $@

diff --git a/src/stat.c b/src/stat.c
index 87f93b8..02d0ead 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -219,7 +219,11 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "adfs";
case S_MAGIC_AFFS: /* 0xADFF */
return "affs";
- case S_MAGIC_AUTOFS: /* 0x187 */
+ case S_MAGIC_AFS: /* 0x5346414F */
+ return "afs";
+ case S_MAGIC_ANON_INODE_FS: /* 0x09041934 */
+ return "anon-inode FS";
+ case S_MAGIC_AUTOFS: /* 0x0187 */
return "autofs";
case S_MAGIC_BEFS: /* 0x42465331 */
return "befs";
@@ -227,6 +231,10 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "bfs";
case S_MAGIC_BINFMT_MISC: /* 0x42494E4D */
return "binfmt_misc";
+ case S_MAGIC_BTRFS: /* 0x9123683E */
+ return "btrfs";
+ case S_MAGIC_CGROUP: /* 0x0027E0EB */
+ return "cgroupfs";
case S_MAGIC_CIFS: /* 0xFF534D42 */
return "cifs";
case S_MAGIC_CODA: /* 0x73757245 */
@@ -235,6 +243,10 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "coh";
case S_MAGIC_CRAMFS: /* 0x28CD3D45 */
return "cramfs";
+ case S_MAGIC_CRAMFS_WEND: /* 0x453DCD28 */
+ return "cramfs-wend";
+ case S_MAGIC_DEBUGFS: /* 0x64626720 */
+ return "debugfs";
case S_MAGIC_DEVFS: /* 0x1373 */
return "devfs";
case S_MAGIC_DEVPTS: /* 0x1CD1 */
@@ -251,12 +263,16 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "fat";
case S_MAGIC_FUSECTL: /* 0x65735543 */
return "fusectl";
+ case S_MAGIC_FUTEXFS: /* 0x0BAD1DEA */
+ return "futexfs";
case S_MAGIC_HFS: /* 0x4244 */
return "hfs";
case S_MAGIC_HPFS: /* 0xF995E849 */
return "hpfs";
case S_MAGIC_HUGETLBFS: /* 0x958458F6 */
return "hugetlbfs";
+ case S_MAGIC_INOTIFYFS: /* 0x2BAD1DEA */
+ return "inotifyfs";
case S_MAGIC_ISOFS: /* 0x9660 */
return "isofs";
case S_MAGIC_ISOFS_R_WIN: /* 0x4004 */
@@ -279,6 +295,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "minix v2";
case S_MAGIC_MINIX_V2_30: /* 0x2478 */
return "minix v2 (30 char.)";
+ case S_MAGIC_MINIX_V3: /* 0x4D5A */
+ return "minux3";
case S_MAGIC_MSDOS: /* 0x4D44 */
return "msdos";
case S_MAGIC_NCP: /* 0x564C */
@@ -287,6 +305,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "nfs";
case S_MAGIC_NFSD: /* 0x6E667364 */
return "nfsd";
+ case S_MAGIC_NILFS: /* 0x3434 */
+ return "nilfs";
case S_MAGIC_NTFS: /* 0x5346544E */
return "ntfs";
case S_MAGIC_OPENPROM: /* 0x9FA1 */
@@ -301,6 +321,10 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "reiserfs";
case S_MAGIC_ROMFS: /* 0x7275 */
return "romfs";
+ case S_MAGIC_SECURITYFS: /* 0x73636673 */
+ return "securityfs";
+ case S_MAGIC_SELINUX: /* 0xF97CFF8C */
+ return "selinux";
case S_MAGIC_SMB: /* 0x517B */
return "smb";
case S_MAGIC_SQUASHFS: /* 0x73717368 */
@@ -323,6 +347,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "usbdevfs";
case S_MAGIC_VXFS: /* 0xA501FCF5 */
return "vxfs";
+ case S_MAGIC_XENFS: /* 0xABBA1974 */
+ return "xenfs";
case S_MAGIC_XENIX: /* 0x012FF7B4 */
return "xenix";
case S_MAGIC_XFS: /* 0x58465342 */
--
1.6.5.rc2.204.g8ea19
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/