summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/context.c
diff options
context:
space:
mode:
authorKarel Zak2013-10-10 12:42:18 +0200
committerKarel Zak2013-10-23 10:45:14 +0200
commitd17c584ac121f61be265c3c16f07edd05a17433e (patch)
treede4e009da5a0c98879643900c7ba3f2ca233bee8 /libfdisk/src/context.c
parenttests: add TERM= to all cal(1) tests (diff)
downloadkernel-qcow2-util-linux-d17c584ac121f61be265c3c16f07edd05a17433e.tar.gz
kernel-qcow2-util-linux-d17c584ac121f61be265c3c16f07edd05a17433e.tar.xz
kernel-qcow2-util-linux-d17c584ac121f61be265c3c16f07edd05a17433e.zip
libfdisk: support nested MBR
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/context.c')
-rw-r--r--libfdisk/src/context.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c
index 9106e29b3..faf03af44 100644
--- a/libfdisk/src/context.c
+++ b/libfdisk/src/context.c
@@ -27,7 +27,6 @@ struct fdisk_context *fdisk_new_context(void)
return cxt;
}
-/* only BSD is supported now */
struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent,
const char *name)
{
@@ -53,14 +52,19 @@ struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent,
cxt->grain = parent->grain;
cxt->first_lba = parent->first_lba;
cxt->total_sectors = parent->total_sectors;
+ cxt->firstsector = parent->firstsector;
cxt->ask_cb = parent->ask_cb;
cxt->ask_data = parent->ask_data;
cxt->geom = parent->geom;
- if (name && strcmp(name, "bsd") == 0)
- lb = cxt->labels[ cxt->nlabels++ ] = fdisk_new_bsd_label(cxt);
+ if (name) {
+ if (strcmp(name, "bsd") == 0)
+ lb = cxt->labels[ cxt->nlabels++ ] = fdisk_new_bsd_label(cxt);
+ else if (strcmp(name, "dos") == 0)
+ lb = cxt->labels[ cxt->nlabels++ ] = fdisk_new_dos_label(cxt);
+ }
if (lb) {
DBG(LABEL, dbgprint("probing for nested %s", lb->name));
@@ -160,7 +164,9 @@ static void reset_context(struct fdisk_context *cxt)
if (!cxt->parent && cxt->dev_fd > -1)
close(cxt->dev_fd);
free(cxt->dev_path);
- free(cxt->firstsector);
+
+ if (cxt->parent == NULL || cxt->parent->firstsector != cxt->firstsector)
+ free(cxt->firstsector);
/* initialize */
cxt->dev_fd = -1;