diff options
author | Karel Zak | 2015-07-15 15:42:22 +0200 |
---|---|---|
committer | Karel Zak | 2015-07-15 15:42:22 +0200 |
commit | 4bd02cdfdf3a55ce61e8e56e29e9b149b5feaf1c (patch) | |
tree | 27954c3981d64ffd2477ecb15f2e26951dfd0227 | |
parent | libfdisk: (gpt) add missing GUIDs (diff) | |
download | kernel-qcow2-util-linux-4bd02cdfdf3a55ce61e8e56e29e9b149b5feaf1c.tar.gz kernel-qcow2-util-linux-4bd02cdfdf3a55ce61e8e56e29e9b149b5feaf1c.tar.xz kernel-qcow2-util-linux-4bd02cdfdf3a55ce61e8e56e29e9b149b5feaf1c.zip |
libfdisk: fix fdisk_label_parse_parttype() for unknown types
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | disk-utils/fdisk.c | 3 | ||||
-rw-r--r-- | disk-utils/fdisk.h | 1 | ||||
-rw-r--r-- | libfdisk/src/parttype.c | 14 |
3 files changed, 11 insertions, 7 deletions
diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index a4130afb9..2a2ab9adc 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -409,7 +409,7 @@ int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask, return rc; } -struct fdisk_parttype *ask_partition_type(struct fdisk_context *cxt) +static struct fdisk_parttype *ask_partition_type(struct fdisk_context *cxt) { const char *q; struct fdisk_label *lb; @@ -562,6 +562,7 @@ void change_partition_type(struct fdisk_context *cxt) i + 1, old); fdisk_unref_partition(pa); + fdisk_unref_parttype(t); } int print_partition_info(struct fdisk_context *cxt) diff --git a/disk-utils/fdisk.h b/disk-utils/fdisk.h index 6a62c2497..f66404d04 100644 --- a/disk-utils/fdisk.h +++ b/disk-utils/fdisk.h @@ -44,7 +44,6 @@ extern void dump_disklabel(struct fdisk_context *cxt); extern void list_partition_types(struct fdisk_context *cxt); extern void change_partition_type(struct fdisk_context *cxt); -extern struct fdisk_parttype *ask_partition_type(struct fdisk_context *cxt); extern void toggle_dos_compatibility_flag(struct fdisk_context *cxt); diff --git a/libfdisk/src/parttype.c b/libfdisk/src/parttype.c index aedf4e83b..712994efb 100644 --- a/libfdisk/src/parttype.c +++ b/libfdisk/src/parttype.c @@ -302,9 +302,8 @@ struct fdisk_parttype *fdisk_label_parse_parttype( const struct fdisk_label *lb, const char *str) { - struct fdisk_parttype *types, *ret; - unsigned int code = 0; - char *typestr = NULL, *end = NULL; + struct fdisk_parttype *types, *ret = NULL; + char *end = NULL; assert(lb); @@ -316,6 +315,7 @@ struct fdisk_parttype *fdisk_label_parse_parttype( types = lb->parttypes; if (types[0].typestr == NULL && isxdigit(*str)) { + unsigned int code = 0; errno = 0; code = strtol(str, &end, 16); @@ -327,6 +327,8 @@ struct fdisk_parttype *fdisk_label_parse_parttype( ret = fdisk_label_get_parttype_from_code(lb, code); if (ret) goto done; + + ret = fdisk_new_unknown_parttype(code, NULL); } else { int i; @@ -343,11 +345,13 @@ struct fdisk_parttype *fdisk_label_parse_parttype( ret = &types[i - 1]; goto done; } + + ret = fdisk_new_unknown_parttype(0, str); } - ret = fdisk_new_unknown_parttype(code, typestr); done: - DBG(PARTTYPE, ul_debugobj(ret, "returns parsed '%s' partition type", ret->name)); + DBG(PARTTYPE, ul_debugobj(ret, "returns parsed '%s' [%s] partition type", + ret->name, ret->typestr ? : "")); return ret; } |