summaryrefslogtreecommitdiff
path: root/src/partition
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-12-01 15:37:59 +0100
committerLennart Poettering <lennart@poettering.net>2022-12-01 15:43:26 +0100
commit2e3944b872cf57dbccdda14ec66772e8fdd2273b (patch)
tree4f93b44ecaba93b414f01c833a567a00055761cf /src/partition
parentef1f0a14fa2d933d0089fd7e52af21cc78a60493 (diff)
downloadsystemd-2e3944b872cf57dbccdda14ec66772e8fdd2273b.tar.gz
blkid-util: define enum for blkid_do_safeprobe() return values
libblkid really should define an enum for this on its own, but it currently doesn't and returns literal numeric values. Lets make this more readable by adding our own symbolic names via an enum.
Diffstat (limited to 'src/partition')
-rw-r--r--src/partition/repart.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c
index ce65ead62a..46b68c730c 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -4840,12 +4840,14 @@ static int resolve_copy_blocks_auto_candidate(
errno = 0;
r = blkid_do_safeprobe(b);
- if (IN_SET(r, -2, 1)) { /* nothing found or ambiguous result */
+ if (r == _BLKID_SAFEPROBE_ERROR)
+ return log_error_errno(errno_or_else(EIO), "Unable to probe for partition table of '%s': %m", p);
+ if (IN_SET(r, _BLKID_SAFEPROBE_AMBIGUOUS, _BLKID_SAFEPROBE_NOT_FOUND)) {
log_debug("Didn't find partition table on block device '%s'.", p);
return false;
}
- if (r != 0)
- return log_error_errno(errno_or_else(EIO), "Unable to probe for partition table of '%s': %m", p);
+
+ assert(r == _BLKID_SAFEPROBE_FOUND);
(void) blkid_probe_lookup_value(b, "PTTYPE", &pttype, NULL);
if (!streq_ptr(pttype, "gpt")) {
@@ -4857,7 +4859,6 @@ static int resolve_copy_blocks_auto_candidate(
pl = blkid_probe_get_partitions(b);
if (!pl)
return log_error_errno(errno_or_else(EIO), "Unable read partition table of '%s': %m", p);
- errno = 0;
pp = blkid_partlist_devno_to_partition(pl, partition_devno);
if (!pp) {