]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
stat: recognize CIFS and HFS file system types
authorJim Meyering <meyering@redhat.com>
Thu, 8 Oct 2009 07:05:08 +0000 (09:05 +0200)
committerJim Meyering <meyering@redhat.com>
Thu, 8 Oct 2009 07:07:12 +0000 (09:07 +0200)
* src/stat.c (human_fstype) [CIFS, HFS]: Add new file system types.
Prompted by a report from Stuart Kemp.
Normalize the form of a few hexadecimal magic numbers.
Alphabetize on S_MAGIC_ case names.
* src/Makefile.am (fs-magic-compare, fs-def, fs-magic): New rules, to
automate comparison of our list with that in the Linux statfs man page.
* NEWS (Bug fixes): Mention it.

NEWS
src/Makefile.am
src/stat.c

diff --git a/NEWS b/NEWS
index ff5e9a2043c89df95e2532f12b8577bdc4c19783..cca3328d5a1aaa608b123a69abbff7908a651791 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Bug fixes
 
+  stat -f recognizes more file system types: CIFS, HFS
+
 ** New features
 
   md5sum --check now also accepts openssl-style checksums.
index 0aa7599b4ac96661802f324687f5330b3fd9b60c..3bba86d9cef3b6bfac82cde85876fc26ed603b58 100644 (file)
@@ -330,6 +330,37 @@ wheel.h: wheel-gen.pl Makefile.am
 # Tell automake to exempt then from that installcheck test.
 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
+       join -v1 -t@ fs-magic fs-def
+
+CLEANFILES += fs-magic fs-def
+fs-def: fs.h
+       grep '^# *define ' $< > $@-t && mv $@-t $@
+
+fs-magic:
+       man statfs \
+          |perl -ne '/File system types:/.../Nobody kno/ and print'    \
+          |grep 0x | 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/CIFS_MAGIC_NUMBER/CIFS/;'                            \
+            -e 's/(_SUPER)?_MAGIC//;'                                  \
+            -e 's/\s+0x(\S+)/" 0x" . uc $$1/e;'                                \
+            -e 's/^\s+//;'                                             \
+            -e 's/^_(XIAFS)/$$1/;'                                     \
+            -e 's/^USBDEVICE/USBDEVFS/;'                               \
+            -e 's/NTFS_SB/NTFS/;'                                      \
+            -e 's/^/# define S_MAGIC_/;'                               \
+            -e 's,\s*/\* .*? \*/,,;'                                   \
+          | grep -v S_MAGIC_EXT3                                       \
+          | LC_ALL=C sort                                              \
+          > $@-t && mv $@-t $@
+
 BUILT_SOURCES += fs.h
 fs.h: stat.c extract-magic
        $(AM_V_GEN)rm -f $@
index 14654b174cd9423c4d2f2a59eca043dedad517d8..87f93b89b7c77ab27fdaf66803633c84ac6d40ea 100644 (file)
@@ -225,8 +225,10 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
       return "befs";
     case S_MAGIC_BFS: /* 0x1BADFACE */
       return "bfs";
-    case S_MAGIC_BINFMT_MISC: /* 0x42494e4d */
+    case S_MAGIC_BINFMT_MISC: /* 0x42494E4D */
       return "binfmt_misc";
+    case S_MAGIC_CIFS: /* 0xFF534D42 */
+      return "cifs";
     case S_MAGIC_CODA: /* 0x73757245 */
       return "coda";
     case S_MAGIC_COH: /* 0x012FF7B7 */
@@ -237,7 +239,7 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
       return "devfs";
     case S_MAGIC_DEVPTS: /* 0x1CD1 */
       return "devpts";
-    case S_MAGIC_EFS: /* 0x414A53 */
+    case S_MAGIC_EFS: /* 0x00414A53 */
       return "efs";
     case S_MAGIC_EXT: /* 0x137D */
       return "ext";
@@ -249,9 +251,11 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
       return "fat";
     case S_MAGIC_FUSECTL: /* 0x65735543 */
       return "fusectl";
+    case S_MAGIC_HFS: /* 0x4244 */
+      return "hfs";
     case S_MAGIC_HPFS: /* 0xF995E849 */
       return "hpfs";
-    case S_MAGIC_HUGETLBFS: /* 0x958458f6 */
+    case S_MAGIC_HUGETLBFS: /* 0x958458F6 */
       return "hugetlbfs";
     case S_MAGIC_ISOFS: /* 0x9660 */
       return "isofs";
@@ -259,10 +263,10 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
       return "isofs";
     case S_MAGIC_ISOFS_WIN: /* 0x4000 */
       return "isofs";
-    case S_MAGIC_JFFS2: /* 0x72B6 */
-      return "jffs2";
     case S_MAGIC_JFFS: /* 0x07C0 */
       return "jffs";
+    case S_MAGIC_JFFS2: /* 0x72B6 */
+      return "jffs2";
     case S_MAGIC_JFS: /* 0x3153464A */
       return "jfs";
     case S_MAGIC_LUSTRE: /* 0x0BD00BD0 */
@@ -285,7 +289,7 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
       return "nfsd";
     case S_MAGIC_NTFS: /* 0x5346544E */
       return "ntfs";
-    case S_MAGIC_OPENPROM: /* 0x9fa1 */
+    case S_MAGIC_OPENPROM: /* 0x9FA1 */
       return "openprom";
     case S_MAGIC_PROC: /* 0x9FA0 */
       return "proc";
@@ -307,7 +311,7 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
       return "sysv2";
     case S_MAGIC_SYSV4: /* 0x012FF7B5 */
       return "sysv4";
-    case S_MAGIC_TMPFS: /* 0x1021994 */
+    case S_MAGIC_TMPFS: /* 0x01021994 */
       return "tmpfs";
     case S_MAGIC_UDF: /* 0x15013346 */
       return "udf";