]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
blkid: don't return PART_ENTRY_* if partition is empty
authorKarel Zak <kzak@redhat.com>
Thu, 3 Feb 2011 11:12:37 +0000 (12:12 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 3 Feb 2011 11:12:37 +0000 (12:12 +0100)
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 <thomas@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/blkid.c

index 11eee2e7fb5c7dc1bd00b1d197c2751297b6a32c..4c846e93d143ab330cbe01f048af34045bc52967 100644 (file)
@@ -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);