summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2019-07-22 12:09:38 +0200
committerKarel Zak2019-07-22 12:09:38 +0200
commit10c39f03a1e70cf2a4b8e0301784174ac5730251 (patch)
tree0541c00495b64f81813d8d17df92aa6b0981c572
parentlibblkid: (drbd) fix comment formatting (diff)
downloadkernel-qcow2-util-linux-10c39f03a1e70cf2a4b8e0301784174ac5730251.tar.gz
kernel-qcow2-util-linux-10c39f03a1e70cf2a4b8e0301784174ac5730251.tar.xz
kernel-qcow2-util-linux-10c39f03a1e70cf2a4b8e0301784174ac5730251.zip
libfdisk: improve partition copy on resize
It seems pretty fragile to copy also reference counting and reference to table list. Addresses: https://github.com/karelzak/util-linux/pull/822 Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--libfdisk/src/partition.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libfdisk/src/partition.c b/libfdisk/src/partition.c
index 55ce1ca5c..80a43ffde 100644
--- a/libfdisk/src/partition.c
+++ b/libfdisk/src/partition.c
@@ -85,7 +85,13 @@ static struct fdisk_partition *__copy_partition(struct fdisk_partition *o)
if (!n)
return NULL;
+
memcpy(n, o, sizeof(*n));
+
+ /* do not copy reference to lists, etc.*/
+ n->refcount = 1;
+ INIT_LIST_HEAD(&n->parts);
+
if (n->type)
fdisk_ref_parttype(n->type);
if (o->name)