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

Rob Landley rob at landley.net
Tue Feb 7 21:36:54 PST 2023


Test assumes a test image you want me to create with a tool I don't have
installed, and I'm not near net access at the moment. Huh, I thought busybox had
a mkisofs. I guess that was just on my todo heap to implement way back when. (I
haven't got one installed either, it seems...) Where are my notes...

It's after mkfs.vfat in my todo list because of rock ridge weirdness. Right.

Right, boot up the oldest knoppix image I have lying around... v3.6 from 2004.
That has mkisofs installed by default. Right:

  $ mkdir sub
  $ echo hello > sub/file.txt
  $ mkisofs sub > file.iso
  $ gzip file.iso
  $ uuencode file.iso.gz < file.iso.gz > uue.txt
  $ netcat 10.0.2.2 9876 < uue.txt

And on the host:

  $ echo -e '#!/bin/bash\ncat > file.txt\n' > catt.sh
  $ chmod +x catt.sh
  $ toybox netcat -s 127.0.0.1 -p 9876 -l ./catt.sh
  $ toybox uudecode file.txt
  $ gunzip file.iso.gz
  $ file file.iso
  file.iso: ISO 9660 CD-ROM filesystem data 'CDROM'

Well it's something. (It's nice to have something old enough that it STILL HAS
ALL THE TOOLS INSTALLED BY DEFAULT. I need to add mkisofs to toybox...)

And now I need to go back and add a couple extra paremeters, because TEST_HOST
is saying...

FAIL: blkid iso
echo -ne '' | BLKID iso
--- expected	2023-02-07 23:02:05.903941946 -0600
+++ actual	2023-02-07 23:02:05.911941946 -0600
@@ -1 +1 @@
-temp.img: SEC_TYPE="msdos" LABEL="MYISO" UUID="1970-01-02-12-55-42-00"
TYPE="iso9660"
+temp.img: UUID="2023-02-08-04-47-27-00" LABEL="CDROM" TYPE="iso9660"

And... sigh. Why are the fields out of order?

On 2/6/23 10:11, Eric Molitor wrote:
> 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' \
>    "" ""

You removed SEC_TYPE from the output but debian is still producing it. Why did
you do that? I'd think "adjusting the tests to match the different output my
patch produces" would warrant at least a comment...

I see TEST_HOST is also producing a LABEL_FATBOOT field that seems to duplicate
LABEL, so I should look at that. Darn moving targets. I apparently hadn't
regression tested it recently because debian INSANELY excludes /sbin and
/usr/sbin from the non-root $PATH so I have to remember to add it back in or
some tests get skipped because command not present in $PATH. That decision was
still not as stupid as redirecting /bin/sh to point away from bash, but it's up
there. Even that's eclipsed by systemd, which is why I actually use devuan, but
this smaller mistake is the same for both forks...

> +++ 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;

If you added the show_tag() back, why remove it from all the tests?

Also, why not just:

--- a/toys/other/blkid.c
+++ b/toys/other/blkid.c
@@ -167,7 +167,7 @@ static void do_blkid(int fd, char *name)
   if (!FLAG(U) && len) {
     s = toybuf+fstypes[i].label_off-off;
     if (!strcmp(type, "vfat")) {
-      show_tag("SEC_TYPE", "msdos");
+      if (*type=='v') show_tag("SEC_TYPE", "msdos");
       while (len && s[len-1]==' ') len--;
       if (strstart(&s, "NO NAME")) len=0;
     }

Rob


More information about the Toybox mailing list