[Toybox] [PATCH 2/2] BLKID: Fix SEC_TYPE for vfat and iso9660

Eric Molitor emolitor at molitor.org
Mon Feb 6 08:11:45 PST 2023


Move SEC_TYPE for vfat to not display when searching by label
Remove SEC_TYPE from iso9660
---
 tests/blkid.test   | 6 +++---
 toys/other/blkid.c | 4 +++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/blkid.test b/tests/blkid.test
index 4c385dcb..37bce67a 100755
--- a/tests/blkid.test
+++ b/tests/blkid.test
@@ -29,10 +29,10 @@ testing "f2fs" "BLKID f2fs" \
   'temp.img: LABEL="myf2fs" UUID="b53d3619-c204-4c0b-8504-36363578491c"
TYPE="f2fs"\n' \
   "" ""
 testing "iso" "BLKID iso" \
-  'temp.img: SEC_TYPE="msdos" LABEL="MYISO" UUID="1970-01-02-12-55-42-00"
TYPE="iso9660"\n' \
+  'temp.img: LABEL="MYISO" UUID="1970-01-02-12-55-42-00" TYPE="iso9660"\n'
\
   "" ""
 testing "msdos" "BLKID msdos" \
-  'temp.img: SEC_TYPE="msdos" LABEL="mymsdos" UUID="6E1E-0851"
TYPE="vfat"\n' \
+  'temp.img: LABEL="mymsdos" UUID="6E1E-0851" SEC_TYPE="msdos"
TYPE="vfat"\n' \
   "" ""

 # We use -s here because toybox blkid can't do ntfs volume labels yet.
@@ -43,7 +43,7 @@ testing "reiserfs" "BLKID reiser3" \
   "" ""
 testing "squashfs" "BLKID squashfs" 'temp.img: TYPE="squashfs"\n' "" ""
 testing "vfat" "BLKID vfat" \
-  'temp.img: SEC_TYPE="msdos" LABEL="myvfat" UUID="7356-B91D"
TYPE="vfat"\n' \
+  'temp.img: LABEL="myvfat" UUID="7356-B91D" SEC_TYPE="msdos"
TYPE="vfat"\n' \
   "" ""
 testing "xfs" "BLKID xfs" \
   'temp.img: LABEL="XFS_test" UUID="d63a1dc3-27d5-4dd4-8b38-f4f97f495c6f"
TYPE="xfs"\n' \
diff --git a/toys/other/blkid.c b/toys/other/blkid.c
index 726ae754..632e0c80 100644
--- a/toys/other/blkid.c
+++ b/toys/other/blkid.c
@@ -168,7 +168,6 @@ static void do_blkid(int fd, char *name)
   if (!FLAG(U) && len) {
     s = toybuf+fstypes[i].label_off-off;
     if (!strcmp(type, "vfat") || !strcmp(type, "iso9660")) {
-      show_tag("SEC_TYPE", "msdos");
       while (len && s[len-1]==' ') len--;
       if (strstart(&s, "NO NAME")) len=0;
     }
@@ -220,6 +219,9 @@ static void do_blkid(int fd, char *name)
   if ((!strcmp(type, "ext3")||!strcmp(type,"ext4")) &&
!(toybuf[1120]&~0x12))
     show_tag("SEC_TYPE", "ext2");

+  if (!strcmp(type, "vfat"))
+    show_tag("SEC_TYPE", "msdos");
+
   if (FLAG(U) || FLAG(L)) return;

   show_tag("TYPE", type);
-- 
2.39.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20230206/3081b61a/attachment-0001.htm>


More information about the Toybox mailing list