From: Karel Zak Date: Thu, 3 Feb 2011 11:12:37 +0000 (+0100) Subject: blkid: don't return PART_ENTRY_* if partition is empty X-Git-Tag: v2.19~44 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=53a4d69ddf98a09e7a658afa03ad9b697ad38082;p=thirdparty%2Futil-linux.git blkid: don't return PART_ENTRY_* if partition is empty The PART_ENTRY_* has nothing to do with the _contents_ of the block device. So if the device is empty these values should not be printed and blkid(8) has to return 2. The PART_ENTRY_* for empty devices should be printed for "-o udev" output only. Reported-by: Thomas Bächler Signed-off-by: Karel Zak --- diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c index 11eee2e7fb..4c846e93d1 100644 --- a/misc-utils/blkid.c +++ b/misc-utils/blkid.c @@ -516,6 +516,20 @@ static int lowprobe_device(blkid_probe pr, const char *devname, if (!rc) nvals = blkid_probe_numof_values(pr); + if (nvals && + !(output & OUTPUT_UDEV_LIST) && + !blkid_probe_has_value(pr, "TYPE") && + !blkid_probe_has_value(pr, "PTTYPE")) + /* + * Ignore probing result if there is not any filesystem or + * partition table on the device and udev output is not + * requested. + * + * The udev db stores information about partitions, so + * PART_ENTRY_* values are alway important. + */ + nvals = 0; + if (nvals && !first && output & (OUTPUT_UDEV_LIST | OUTPUT_EXPORT_LIST)) /* add extra line between output from devices */ fputc('\n', stdout);