diff options
author | Karel Zak | 2017-02-14 14:23:45 +0100 |
---|---|---|
committer | Karel Zak | 2017-02-14 14:23:45 +0100 |
commit | 0cec78a3c467dfbda06bb846f3a8d861f313ccc3 (patch) | |
tree | 7f206d2e82cea6bc7ae62782f43b9b1703596308 /libfdisk/src/wipe.c | |
parent | libfdisk: check for collisions when create new label (diff) | |
download | kernel-qcow2-util-linux-0cec78a3c467dfbda06bb846f3a8d861f313ccc3.tar.gz kernel-qcow2-util-linux-0cec78a3c467dfbda06bb846f3a8d861f313ccc3.tar.xz kernel-qcow2-util-linux-0cec78a3c467dfbda06bb846f3a8d861f313ccc3.zip |
libfdisk: classify collision type
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/wipe.c')
-rw-r--r-- | libfdisk/src/wipe.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libfdisk/src/wipe.c b/libfdisk/src/wipe.c index c58015d0e..617383024 100644 --- a/libfdisk/src/wipe.c +++ b/libfdisk/src/wipe.c @@ -168,6 +168,10 @@ int fdisk_check_collisions(struct fdisk_context *cxt) if (rc) return rc; + cxt->pt_collision = 0; + free(cxt->collision); + cxt->collision = NULL; + blkid_probe_enable_superblocks(pr, 1); blkid_probe_set_superblocks_flags(pr, BLKID_SUBLKS_TYPE); blkid_probe_enable_partitions(pr, 1); @@ -178,12 +182,15 @@ int fdisk_check_collisions(struct fdisk_context *cxt) if (rc == 0) { const char *name = NULL; - if (blkid_probe_lookup_value(pr, "TYPE", &name, 0) == 0 || - blkid_probe_lookup_value(pr, "PTTYPE", &name, 0) == 0) { + if (blkid_probe_lookup_value(pr, "TYPE", &name, 0) == 0) + cxt->collision = strdup(name); + else if (blkid_probe_lookup_value(pr, "PTTYPE", &name, 0) == 0) { cxt->collision = strdup(name); - if (!cxt->collision) - rc = -ENOMEM; + cxt->pt_collision = 1; } + + if (name && !cxt->collision) + rc = -ENOMEM; } blkid_free_probe(pr); |