summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/label.c
diff options
context:
space:
mode:
authorKarel Zak2013-06-27 10:52:34 +0200
committerKarel Zak2013-09-16 16:47:05 +0200
commit8a9256f9fcc0a3fa209b3cbb53edc1d9c1ea20f6 (patch)
tree8ef089a520f1c6fa557fc05d15974379384af8f7 /libfdisk/src/label.c
parentlibfdisk: (dos) cosmetic changes (diff)
downloadkernel-qcow2-util-linux-8a9256f9fcc0a3fa209b3cbb53edc1d9c1ea20f6.tar.gz
kernel-qcow2-util-linux-8a9256f9fcc0a3fa209b3cbb53edc1d9c1ea20f6.tar.xz
kernel-qcow2-util-linux-8a9256f9fcc0a3fa209b3cbb53edc1d9c1ea20f6.zip
libfdisk: improve nested context initialization
- all label prober() function in fdisk_new_nested_context() - don't reset device properties for nested contexts Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/label.c')
-rw-r--r--libfdisk/src/label.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/libfdisk/src/label.c b/libfdisk/src/label.c
index bae968480..147918e03 100644
--- a/libfdisk/src/label.c
+++ b/libfdisk/src/label.c
@@ -212,6 +212,7 @@ int fdisk_delete_partition(struct fdisk_context *cxt, size_t partnum)
int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name)
{
int haslabel = 0;
+ struct fdisk_label *lb;
if (!cxt)
return -EINVAL;
@@ -229,16 +230,18 @@ int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name)
haslabel = 1;
}
- cxt->label = fdisk_context_get_label(cxt, name);
- if (!cxt->label)
+ lb = fdisk_context_get_label(cxt, name);
+ if (!lb)
return -EINVAL;
-
- DBG(LABEL, dbgprint("changing to %s label\n", cxt->label->name));
- if (!cxt->label->op->create)
+ if (!lb->op->create)
return -ENOSYS;
- if (haslabel)
+ __fdisk_context_switch_label(cxt, lb);
+
+ if (haslabel && !cxt->parent)
fdisk_reset_device_properties(cxt);
+
+ DBG(LABEL, dbgprint("create a new %s label", lb->name));
return cxt->label->op->create(cxt);
}