summaryrefslogtreecommitdiffstats
path: root/disk-utils
diff options
context:
space:
mode:
authorKarel Zak2014-08-14 12:01:38 +0200
committerKarel Zak2014-08-14 12:01:38 +0200
commit5ab37600712d476156160ba7fe1b5d51e52b33cd (patch)
tree179314c95398b411a7ae3b4fd9ef4cdff3f4988f /disk-utils
parentlibfdisk: (gpt) allow to specify attr bit by API (diff)
downloadkernel-qcow2-util-linux-5ab37600712d476156160ba7fe1b5d51e52b33cd.tar.gz
kernel-qcow2-util-linux-5ab37600712d476156160ba7fe1b5d51e52b33cd.tar.xz
kernel-qcow2-util-linux-5ab37600712d476156160ba7fe1b5d51e52b33cd.zip
libfdisk: move get_parttypes to label API
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils')
-rw-r--r--disk-utils/cfdisk.c14
-rw-r--r--disk-utils/fdisk.c3
2 files changed, 10 insertions, 7 deletions
diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c
index b86b609ef..e38052591 100644
--- a/disk-utils/cfdisk.c
+++ b/disk-utils/cfdisk.c
@@ -1509,25 +1509,27 @@ static struct fdisk_parttype *ui_get_parttype(struct cfdisk *cf,
{
struct cfdisk_menuitem *d, *cm;
size_t i = 0, nitems, idx = 0;
- struct fdisk_parttype *t = NULL;
+ struct fdisk_parttype *types, *t = NULL;
+ struct fdisk_label *lb;
int has_typestr = 0;
DBG(UI, ul_debug("asking for parttype."));
+ lb = fdisk_get_label(cf->cxt, NULL);
+
/* create cfdisk menu according to label types, note that the
* last cm[] item has to be empty -- so nitems + 1 */
- nitems = cf->cxt->label->nparttypes;
- if (!nitems)
+ if (fdisk_label_get_parttypes(lb, &types, &nitems) || !nitems)
return NULL;
+
cm = xcalloc(nitems + 1, sizeof(struct cfdisk_menuitem));
if (!cm)
return NULL;
- has_typestr = cf->cxt->label->parttypes[0].typestr &&
- *cf->cxt->label->parttypes[0].typestr;
+ has_typestr = fdisk_label_is_parttype_string(lb);
for (i = 0; i < nitems; i++) {
- struct fdisk_parttype *x = &cf->cxt->label->parttypes[i];
+ struct fdisk_parttype *x = &types[i];
char *name;
if (!x || !x->name)
diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c
index ed008e703..6883b6c41 100644
--- a/disk-utils/fdisk.c
+++ b/disk-utils/fdisk.c
@@ -354,11 +354,12 @@ int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask,
struct fdisk_parttype *ask_partition_type(struct fdisk_context *cxt)
{
const char *q;
+ struct fdisk_label *lb = fdisk_get_label(cxt, NULL);
if (!cxt || !cxt->label || !cxt->label->nparttypes)
return NULL;
- q = fdisk_is_parttype_string(cxt) ?
+ q = fdisk_label_is_parttype_string(lb) ?
_("Partition type (type L to list all types): ") :
_("Hex code (type L to list all codes): ");
do {