]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: fix return codes from PART_ENTRY_* probing
authorKarel Zak <kzak@redhat.com>
Tue, 15 Apr 2014 11:09:20 +0000 (13:09 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 15 Apr 2014 11:09:20 +0000 (13:09 +0200)
The partitions prober does two step:

1) probe the assigned device for partition table

2) probe whole-disk device for partition table if the assigned device is a
   partition (this generates PART_ENTRY_* results for blkid -p -o udev))

The step 2) is optional and the return code from this probing should
not override success (rc=0) from the step 1) -- except situations when
the step 2) ends with I/O error or when the step 1) found nothing, but
2) was successful.

Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/partitions/partitions.c

index 003ca9e4d1b391028bb2b8592e3b8c135bb42f5f..37cc0c2c9f3be779e8a3c3fe21178a492ce992f4 100644 (file)
@@ -638,10 +638,17 @@ details_only:
            (blkid_partitions_get_flags(pr) & BLKID_PARTS_ENTRY_DETAILS)) {
 
                int xrc = blkid_partitions_probe_partition(pr);
+
+               /* partition entry probing is optional, and "not-found" from
+                * this sub-probing must not to overwrite previous success. */
                if (xrc < 0)
-                       rc = xrc;       /* optional, care about errors only */
+                       rc = xrc;                       /* always propagate errors */
+               else if (rc == BLKID_PROBE_NONE)
+                       rc = xrc;
        }
 
+
+       DBG(LOWPROBE, ul_debug("partitions probe done [rc=%d]", rc));
        return rc;
 }
 
@@ -714,6 +721,8 @@ static int blkid_partitions_probe_partition(blkid_probe pr)
        blkid_partition par;
        dev_t devno;
 
+       DBG(LOWPROBE, ul_debug("parts: start probing for partition entry"));
+
        devno = blkid_probe_get_devno(pr);
        if (!devno)
                goto nothing;
@@ -776,6 +785,7 @@ static int blkid_partitions_probe_partition(blkid_probe pr)
        }
        rc = BLKID_PROBE_OK;
 nothing:
+       DBG(LOWPROBE, ul_debug("parts: end probing for partition entry [rc=%d]", rc));
        return rc;
 }