changeset 1614:21867cda5e41 draft

Give fstype its own config symbol (separate from blkid), and fix blkid not using more accurate ext3/ext4 filesystem sub-type.
author Rob Landley <rob@landley.net>
date Thu, 18 Dec 2014 11:05:06 -0600
parents 96aa7ec74936
children 95b6ae6498fd
files toys/other/blkid.c
diffstat 1 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/toys/other/blkid.c	Mon Dec 15 03:34:55 2014 -0600
+++ b/toys/other/blkid.c	Thu Dec 18 11:05:06 2014 -0600
@@ -5,15 +5,23 @@
  * See ftp://ftp.kernel.org/pub/linux/utils/util-linux/v2.24/libblkid-docs/api-index-full.html
 
 USE_BLKID(NEWTOY(blkid, "<1", TOYFLAG_BIN))
-USE_BLKID(OLDTOY(fstype, blkid, "<1", TOYFLAG_BIN))
+USE_FSTYPE(NEWTOY(fstype, "<1", TOYFLAG_BIN))
 
 config BLKID
   bool "blkid"
   default y
   help
-    usage: blkid [block device...]
+    usage: blkid DEV...
+
+    Prints type, label and UUID of filesystem on a block device or image.
 
-    Prints type, label and UUID of filesystem.
+config FSTYPE
+  bool "fstype"
+  default y
+  help
+    usage: fstype DEV...
+
+    Prints type of filesystem on a block device or image.
 */
 
 #define FOR_blkid
@@ -26,9 +34,8 @@
 };
 
 static const struct fstype fstypes[] = {
-  // ext3 = buf[1116]&4 ext4 = buf[1120]&64
-  {"ext2", 0xEF53, 2, 1080, 1128, 16, 1144},
-  // label actually 8/16 0x4d80 but horrible: 16 bit wide characters via
+  {"ext2", 0xEF53, 2, 1080, 1128, 16, 1144}, // keep this first for ext3/4 check
+  // NTFS label actually 8/16 0x4d80 but horrible: 16 bit wide characters via
   // codepage, something called a uuid that's only 8 bytes long...
   {"ntfs", 0x5346544e, 4, 3, 0x48+(8<<24), 0, 0},
 
@@ -124,10 +131,15 @@
     printf("\"");
   }
 
-  printf(" TYPE=\"%s\"\n", fstypes[i].name);
+  printf(" TYPE=\"%s\"\n", type);
 }
 
 void blkid_main(void)
 {
   loopfiles(toys.optargs, do_blkid);
 }
+
+void fstype_main(void)
+{
+  blkid_main();
+}