summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/label.c
diff options
context:
space:
mode:
authorKarel Zak2017-02-14 13:07:54 +0100
committerKarel Zak2017-02-14 13:07:54 +0100
commit37204dc60c048be91794e349fc41217aea7363b7 (patch)
treeed290a88c6876a99cd3149d39781922e1ab99b3b /libfdisk/src/label.c
parentlib/randutils: glibc 2.25 has getrandom(2) declaration (diff)
downloadkernel-qcow2-util-linux-37204dc60c048be91794e349fc41217aea7363b7.tar.gz
kernel-qcow2-util-linux-37204dc60c048be91794e349fc41217aea7363b7.tar.xz
kernel-qcow2-util-linux-37204dc60c048be91794e349fc41217aea7363b7.zip
libfdisk: check for collisions when create new label
We need to be sure that when create a new disklabel than the old label will be removed. Addresses: https://github.com/karelzak/util-linux/issues/410 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/label.c')
-rw-r--r--libfdisk/src/label.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libfdisk/src/label.c b/libfdisk/src/label.c
index 52f9ec5ea..1319284b0 100644
--- a/libfdisk/src/label.c
+++ b/libfdisk/src/label.c
@@ -367,6 +367,10 @@ int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name)
lb = fdisk_get_label(cxt, name);
if (!lb || lb->disabled)
return -EINVAL;
+
+ if (!haslabel || (lb && cxt->label != lb))
+ fdisk_check_collisions(cxt);
+
if (!lb->op->create)
return -ENOSYS;