From: Karel Zak Date: Tue, 15 Apr 2014 11:09:20 +0000 (+0200) Subject: libblkid: fix return codes from PART_ENTRY_* probing X-Git-Tag: v2.25-rc1~275 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a61618987ab2d7bb5e1954871dc574dbee89a92b;p=thirdparty%2Futil-linux.git libblkid: fix return codes from PART_ENTRY_* probing 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 --- diff --git a/libblkid/src/partitions/partitions.c b/libblkid/src/partitions/partitions.c index 003ca9e4d1..37cc0c2c9f 100644 --- a/libblkid/src/partitions/partitions.c +++ b/libblkid/src/partitions/partitions.c @@ -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; }