diff options
author | Karel Zak | 2013-12-18 10:38:43 +0100 |
---|---|---|
committer | Karel Zak | 2014-03-11 11:35:13 +0100 |
commit | 9f670072f42d7e0e8403385defc69e93b636cb93 (patch) | |
tree | 05a7ba02cbbe607874f09fde3af3f9e53475bc05 /fdisks | |
parent | libfdisk: use fdisk_table to generate output (diff) | |
download | kernel-qcow2-util-linux-9f670072f42d7e0e8403385defc69e93b636cb93.tar.gz kernel-qcow2-util-linux-9f670072f42d7e0e8403385defc69e93b636cb93.tar.xz kernel-qcow2-util-linux-9f670072f42d7e0e8403385defc69e93b636cb93.zip |
libfdisk: remove tt stuff from API
The include/tt.h has to be used only internally by the library (for
example to convert fdisk_table to string).
The fdisk_ask API should not be more used for complex tasks like print
partition table. The application has to use fdisk_get_table() and
fdisk_table_to_string() or something else.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks')
-rw-r--r-- | fdisks/fdisk-ask.c | 4 | ||||
-rw-r--r-- | fdisks/fdisk-menu.c | 8 | ||||
-rw-r--r-- | fdisks/fdisk.c | 20 | ||||
-rw-r--r-- | fdisks/fdisk.h | 1 |
4 files changed, 22 insertions, 11 deletions
diff --git a/fdisks/fdisk-ask.c b/fdisks/fdisk-ask.c index 7de40b435..2fd94b991 100644 --- a/fdisks/fdisk-ask.c +++ b/fdisks/fdisk-ask.c @@ -279,10 +279,6 @@ int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask, fdisk_ask_yesno_set_result(ask, rpmatch(buf)); DBG(ASK, dbgprint("yes-no ask: reply '%s' [rc=%d]", buf, rc)); break; - case FDISK_ASKTYPE_TABLE: - fputc('\n', stdout); - tt_print_table(fdisk_ask_get_table(ask)); - break; case FDISK_ASKTYPE_STRING: { char prmt[BUFSIZ]; diff --git a/fdisks/fdisk-menu.c b/fdisks/fdisk-menu.c index ced819aaf..d7b852deb 100644 --- a/fdisks/fdisk-menu.c +++ b/fdisks/fdisk-menu.c @@ -210,7 +210,6 @@ struct menu menu_dos = { MENU_ENT('c', N_("toggle the dos compatibility flag")), MENU_XENT('b', N_("move beginning of data in a partition")), - MENU_XENT('e', N_("list extended partitions")), MENU_XENT('f', N_("fix partition order")), MENU_XENT('i', N_("change the disk identifier")), @@ -445,7 +444,7 @@ static int generic_menu_cb(struct fdisk_context **cxt0, switch (ent->key) { case 'p': list_disk_geometry(cxt); - rc = fdisk_list_disklabel(cxt); + list_disklabel(cxt); break; case 'w': rc = fdisk_write_disklabel(cxt); @@ -655,9 +654,6 @@ static int dos_menu_cb(struct fdisk_context **cxt0, rc = fdisk_dos_move_begin(cxt, n); break; } - case 'e': - rc = fdisk_dos_list_extended(cxt); - break; case 'f': rc = fdisk_dos_fix_order(cxt); break; @@ -799,7 +795,7 @@ static int bsd_menu_cb(struct fdisk_context **cxt0, org = fdisk_context_display_details(cxt); fdisk_context_enable_details(cxt, 1); - fdisk_list_disklabel(cxt); + list_disklabel(cxt); fdisk_context_enable_details(cxt, org); break; case 'x': diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c index 3e0d75205..19658be9a 100644 --- a/fdisks/fdisk.c +++ b/fdisks/fdisk.c @@ -232,6 +232,24 @@ void list_disk_geometry(struct fdisk_context *cxt) fdisk_colon(cxt, _("Disk identifier: %s"), id); } +void list_disklabel(struct fdisk_context *cxt) +{ + struct fdisk_table *tb = NULL; + char *str; + + /* print label specific stuff by libfdisk FDISK_ASK_INFO API */ + fdisk_list_disklabel(cxt); + + /* print partitions */ + if (fdisk_get_table(cxt, &tb)) + return; + if (fdisk_table_to_string(tb, cxt, NULL, 0, &str) == 0) { + fputc('\n', stdout); + fputs(str, stdout); + } + fdisk_unref_table(tb); +} + static size_t skip_empty(const unsigned char *buf, size_t i, size_t sz) { size_t next; @@ -338,7 +356,7 @@ static void print_device_pt(struct fdisk_context *cxt, char *device) list_disk_geometry(cxt); if (fdisk_dev_has_disklabel(cxt)) - fdisk_list_disklabel(cxt); + list_disklabel(cxt); fputc('\n', stdout); } diff --git a/fdisks/fdisk.h b/fdisks/fdisk.h index 15df8e41d..8d8144a7c 100644 --- a/fdisks/fdisk.h +++ b/fdisks/fdisk.h @@ -27,6 +27,7 @@ extern void dump_disklabel(struct fdisk_context *cxt); extern void list_partition_types(struct fdisk_context *cxt); extern void list_disk_geometry(struct fdisk_context *cxt); +extern void list_disklabel(struct fdisk_context *cxt); extern void change_partition_type(struct fdisk_context *cxt); extern struct fdisk_parttype *ask_partition_type(struct fdisk_context *cxt); |