]> err.no Git - util-linux/commitdiff
blkid: add \n to the "-o udev" output when probe more devices
authorKarel Zak <kzak@redhat.com>
Thu, 15 Apr 2010 11:15:35 +0000 (13:15 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 15 Apr 2010 11:15:35 +0000 (13:15 +0200)
Old output:
# blkid -p -o udev /dev/sda{1,3}
ID_FS_LABEL=/boot
ID_FS_LABEL_ENC=\x2fboot
ID_FS_UUID=f1cd38fa-c887-4ab8-834b-c8ee659b97fe
ID_FS_UUID_ENC=f1cd38fa-c887-4ab8-834b-c8ee659b97fe
ID_FS_VERSION=1.0
ID_FS_TYPE=ext3
ID_FS_USAGE=filesystem
ID_FS_LABEL=BAR
ID_FS_LABEL_ENC=BAR
ID_FS_UUID=1f2aa318-9c34-462e-8d29-260819ffd657
ID_FS_UUID_ENC=1f2aa318-9c34-462e-8d29-260819ffd657
ID_FS_VERSION=2
ID_FS_TYPE=swap
ID_FS_USAGE=other

new output:
# blkid -p -o udev /dev/sda{1,3}
ID_FS_LABEL=/boot
ID_FS_LABEL_ENC=\x2fboot
ID_FS_UUID=f1cd38fa-c887-4ab8-834b-c8ee659b97fe
ID_FS_UUID_ENC=f1cd38fa-c887-4ab8-834b-c8ee659b97fe
ID_FS_VERSION=1.0
ID_FS_TYPE=ext3
ID_FS_USAGE=filesystem

ID_FS_LABEL=BAR
ID_FS_LABEL_ENC=BAR
ID_FS_UUID=1f2aa318-9c34-462e-8d29-260819ffd657
ID_FS_UUID_ENC=1f2aa318-9c34-462e-8d29-260819ffd657
ID_FS_VERSION=2
ID_FS_TYPE=swap
ID_FS_USAGE=other

Reported-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/blkid.c

index 651deb3d83a3967790653f7f788fdd56a9826426..08df09e1a899f65b994433673509db0eeebd26a3 100644 (file)
@@ -424,6 +424,7 @@ static int lowprobe_device(blkid_probe pr, const char *devname,     char *show[],
        int fd;
        int rc = 0;
        struct stat st;
+       static int first = 1;
 
        fd = open(devname, O_RDONLY);
        if (fd < 0) {
@@ -493,6 +494,10 @@ static int lowprobe_device(blkid_probe pr, const char *devname,    char *show[],
 
        nvals = blkid_probe_numof_values(pr);
 
+       if (nvals && !first && output & OUTPUT_UDEV_LIST)
+               /* add extra line between output from devices */
+               fputc('\n', stdout);
+
        if (output & OUTPUT_DEVICE_ONLY) {
                printf("%s\n", devname);
                goto done;
@@ -507,6 +512,8 @@ static int lowprobe_device(blkid_probe pr, const char *devname,     char *show[],
                print_value(output, num++, devname, (char *) data, name, len);
        }
 
+       if (first)
+               first = 0;
        if (nvals >= 1 && !(output & (OUTPUT_VALUE_ONLY | OUTPUT_UDEV_LIST)))
                printf("\n");
 done: