From: Karel Zak Date: Thu, 15 Apr 2010 11:15:35 +0000 (+0200) Subject: blkid: add \n to the "-o udev" output when probe more devices X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9eb44c28f8b847ffe149fd5725e49d4d22c5a390;p=util-linux blkid: add \n to the "-o udev" output when probe more devices 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 Signed-off-by: Karel Zak --- diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c index 651deb3d..08df09e1 100644 --- a/misc-utils/blkid.c +++ b/misc-utils/blkid.c @@ -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: