From 53a4d69ddf98a09e7a658afa03ad9b697ad38082 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 3 Feb 2011 12:12:37 +0100 Subject: [PATCH] blkid: don't return PART_ENTRY_* if partition is empty MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- misc-utils/blkid.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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); -- 2.47.3