summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/context.c
diff options
context:
space:
mode:
authorKarel Zak2015-01-19 12:25:37 +0100
committerKarel Zak2015-01-19 12:25:37 +0100
commit4a79a8f1774c3e081afbed383a425622ef541de8 (patch)
tree892b164acd63ab9b64be6f59623358d1a5bfcf3d /libfdisk/src/context.c
parentlibfdiskL add API to print SIZE field in bytes (diff)
downloadkernel-qcow2-util-linux-4a79a8f1774c3e081afbed383a425622ef541de8.tar.gz
kernel-qcow2-util-linux-4a79a8f1774c3e081afbed383a425622ef541de8.tar.xz
kernel-qcow2-util-linux-4a79a8f1774c3e081afbed383a425622ef541de8.zip
libfdisk: make label names case insensitive
and support 'MBR' as alias to 'DOS'. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/context.c')
-rw-r--r--libfdisk/src/context.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c
index 94a0fb659..ef8b30b04 100644
--- a/libfdisk/src/context.c
+++ b/libfdisk/src/context.c
@@ -143,7 +143,7 @@ struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent,
if (!cxt)
return NULL;
- DBG(CXT, ul_debugobj(parent, "alloc nested [%p]", cxt));
+ DBG(CXT, ul_debugobj(parent, "alloc nested [%p] [name=%s]", cxt, name));
cxt->refcount = 1;
fdisk_ref_context(parent);
@@ -153,9 +153,9 @@ struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent,
return NULL;
if (name) {
- if (strcmp(name, "bsd") == 0)
+ if (strcasecmp(name, "bsd") == 0)
lb = cxt->labels[ cxt->nlabels++ ] = fdisk_new_bsd_label(cxt);
- else if (strcmp(name, "dos") == 0)
+ else if (strcasecmp(name, "dos") == 0 || strcasecmp(name, "mbr") == 0)
lb = cxt->labels[ cxt->nlabels++ ] = fdisk_new_dos_label(cxt);
}
@@ -211,10 +211,12 @@ struct fdisk_label *fdisk_get_label(struct fdisk_context *cxt, const char *name)
if (!name)
return cxt->label;
+ else if (strcasecmp(name, "mbr") == 0)
+ name = "dos";
for (i = 0; i < cxt->nlabels; i++)
if (cxt->labels[i]
- && strcmp(cxt->labels[i]->name, name) == 0)
+ && strcasecmp(cxt->labels[i]->name, name) == 0)
return cxt->labels[i];
DBG(CXT, ul_debugobj(cxt, "failed to found %s label driver", name));