diff options
author | Karel Zak | 2013-06-27 10:52:34 +0200 |
---|---|---|
committer | Karel Zak | 2013-09-16 16:47:05 +0200 |
commit | 8a9256f9fcc0a3fa209b3cbb53edc1d9c1ea20f6 (patch) | |
tree | 8ef089a520f1c6fa557fc05d15974379384af8f7 /libfdisk/src/context.c | |
parent | libfdisk: (dos) cosmetic changes (diff) | |
download | kernel-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/context.c')
-rw-r--r-- | libfdisk/src/context.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index f44505a5b..dc79783c4 100644 --- a/libfdisk/src/context.c +++ b/libfdisk/src/context.c @@ -32,9 +32,9 @@ struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent, const char *name) { struct fdisk_context *cxt; + struct fdisk_label *lb = NULL; assert(parent); - assert(name); cxt = calloc(1, sizeof(*cxt)); if (!cxt) @@ -59,8 +59,23 @@ struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent, cxt->geom = parent->geom; - if (strcmp(name, "bsd") == 0) - cxt->label = cxt->labels[ cxt->nlabels++ ] = fdisk_new_bsd_label(cxt); + if (name && strcmp(name, "bsd") == 0) + lb = cxt->labels[ cxt->nlabels++ ] = fdisk_new_bsd_label(cxt); + + if (lb) { + DBG(LABEL, dbgprint("probing for nested %s", lb->name)); + + cxt->label = lb; + + if (lb->op->probe(cxt) == 1) + __fdisk_context_switch_label(cxt, lb); + else { + DBG(LABEL, dbgprint("not found %s label", lb->name)); + if (lb->op->deinit) + lb->op->deinit(lb); + cxt->label = NULL; + } + } return cxt; } |