]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: remove tt stuff from API
authorKarel Zak <kzak@redhat.com>
Wed, 18 Dec 2013 09:38:43 +0000 (10:38 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 11 Mar 2014 10:35:13 +0000 (11:35 +0100)
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>
fdisks/fdisk-ask.c
fdisks/fdisk-menu.c
fdisks/fdisk.c
fdisks/fdisk.h
libfdisk/src/ask.c
libfdisk/src/fdiskP.h
libfdisk/src/libfdisk.h

index 7de40b435c525091cc6113de899fb86c46d3039a..2fd94b99166d0fe60be0826cf125947883ca2920 100644 (file)
@@ -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];
index ced819aaf716febb194829b1c59a0bcbc6dac8c0..d7b852deb7216dd17d3d8ec203a3ce21765272d7 100644 (file)
@@ -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':
index 3e0d752058a17a9fe33f7efc3e86954753f4583f..19658be9a218a2b5f76e76443f481f812e2e7dd1 100644 (file)
@@ -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);
 }
 
index 15df8e41d6a3d7a717ee9f4e56018e870b43d41c..8d8144a7cd5a8c5a8a28aa954135204cda8b0799 100644 (file)
@@ -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);
 
index 872c8da387a3a5248b7f2526965137d79a711d45..23e6263c6fba6056a2957ba9f8624226bad1bfa2 100644 (file)
@@ -490,34 +490,6 @@ int fdisk_ask_yesno_set_result(struct fdisk_ask *ask, uint64_t result)
        return 0;
 }
 
-struct tt *fdisk_ask_get_table(struct fdisk_ask *ask)
-{
-       assert(ask);
-       assert(fdisk_is_ask(ask, TABLE));
-       return ask->data.table;
-}
-
-int fdisk_print_table(struct fdisk_context *cxt, struct tt *tb)
-{
-       struct fdisk_ask *ask;
-       int rc;
-
-       assert(cxt);
-       assert(tb);
-
-       ask = fdisk_new_ask();
-       if (!ask)
-               return -ENOMEM;
-
-       fdisk_ask_set_type(ask, FDISK_ASKTYPE_TABLE);
-       ask->data.table = tb;
-
-       rc = fdisk_do_ask(cxt, ask);
-
-       fdisk_free_ask(ask);
-       return rc;
-}
-
 #define is_print_ask(a) (fdisk_is_ask(a, WARN) || fdisk_is_ask(a, WARNX) || fdisk_is_ask(a, INFO))
 
 int fdisk_ask_print_get_errno(struct fdisk_ask *ask)
index 1cd8b48742b41c39cfb741961ad65e81906f9345..ec61230832906126b736915ce3fc4e25eb6f5ed1 100644 (file)
@@ -21,8 +21,8 @@
 #include "libfdisk.h"
 
 #include "nls.h"               /* temporary before dialog API will be implamented */
-#include "tt.h"
 #include "list.h"
+#include "tt.h"
 
 /* features */
 #define CONFIG_LIBFDISK_ASSERT
@@ -355,8 +355,6 @@ struct fdisk_ask {
                struct ask_string {
                        char            *result;        /* allocated */
                } str;
-               /* FDISK_ASKTYPE_TABLE, see include/tt.h  */
-               struct tt *table;
        } data;
 };
 
@@ -455,9 +453,6 @@ extern const struct fdisk_column *fdisk_label_get_column(
 /* ask.c */
 extern int fdisk_ask_partnum(struct fdisk_context *cxt, size_t *partnum, int wantnew);
 
-extern struct tt *fdisk_ask_get_table(struct fdisk_ask *ask);
-extern int fdisk_print_table(struct fdisk_context *cxt, struct tt *tb);
-
 extern int fdisk_info_new_partition(
                        struct fdisk_context *cxt,
                        int num, sector_t start, sector_t stop,
index 8d03990a06550eeff4d2f8532e06c77248f3fc2c..c093fa8e4af71ca4e79abf52ed754b7b24f8a5ad 100644 (file)
@@ -55,7 +55,6 @@ enum {
        FDISK_ASKTYPE_WARNX,
        FDISK_ASKTYPE_INFO,
        FDISK_ASKTYPE_YESNO,
-       FDISK_ASKTYPE_TABLE,
        FDISK_ASKTYPE_STRING
 };