]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: use new menus
authorKarel Zak <kzak@redhat.com>
Fri, 17 May 2013 13:11:11 +0000 (15:11 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 16 Sep 2013 14:46:55 +0000 (16:46 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisks/fdisk-menu.c
fdisks/fdisk.c
fdisks/fdisk.h
fdisks/fdiskbsdlabel.c

index e6b38703fa2953783cee7690c2d26084b091ddc2..17ecdbab10a8606fafaaa481315545f3d29c9749 100644 (file)
@@ -276,7 +276,7 @@ static int menu_detect_collisions(struct fdisk_context *cxt)
        return 0;
 }
 
-static int print_fdisk_menu(struct fdisk_context *cxt)
+int print_fdisk_menu(struct fdisk_context *cxt)
 {
        struct menu_context mc = MENU_CXT_EMPTY;
        const struct menu_entry *e;
@@ -284,9 +284,9 @@ static int print_fdisk_menu(struct fdisk_context *cxt)
        ON_DBG(CONTEXT, menu_detect_collisions(cxt));
 
        if (fdisk_context_display_details(cxt))
-               printf(_("\nExpert commands:\n"));
+               printf(_("\nHelp (expert commands):\n"));
        else
-               printf(_("\nCommands:\n"));
+               printf(_("\nHelp:\n"));
 
        while ((e = next_menu_entry(cxt, &mc))) {
                if (IS_MENU_HID(e))
index d53af1c596632e343726839c1a8a92b613c6f13d..0034b5240bdc91fb02c0d9f929869e315136e22e 100644 (file)
 #include <linux/blkpg.h>
 #endif
 
-/* menu list description */
-
-struct menulist_descr {
-       char command;                           /* command key */
-       char *description;                      /* command description */
-       enum fdisk_labeltype label[2];          /* disklabel types associated with main and expert menu */
-};
-
-static const struct menulist_descr menulist[] = {
-       {'a', N_("change number of alternate cylinders"), {0, FDISK_DISKLABEL_SUN}},
-       {'a', N_("select bootable partition"), {FDISK_DISKLABEL_SGI, 0}},
-       {'a', N_("toggle a bootable flag"), {FDISK_DISKLABEL_DOS, 0}},
-       {'a', N_("toggle a read only flag"), {FDISK_DISKLABEL_SUN, 0}},
-       {'b', N_("edit bootfile entry"), {FDISK_DISKLABEL_SGI, 0}},
-       {'b', N_("edit bsd disklabel"), {FDISK_DISKLABEL_DOS, 0}},
-       {'b', N_("move beginning of data in a partition"), {0, FDISK_DISKLABEL_DOS}},
-       {'c', N_("change number of cylinders"), {0, FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN}},
-       {'c', N_("select sgi swap partition"), {FDISK_DISKLABEL_SGI, 0}},
-       {'c', N_("toggle the dos compatibility flag"), {FDISK_DISKLABEL_DOS, 0}},
-       {'c', N_("toggle the mountable flag"), {FDISK_DISKLABEL_SUN, 0}},
-       {'d', N_("delete a partition"), {FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI | FDISK_DISKLABEL_OSF | FDISK_DISKLABEL_GPT, 0}},
-       {'d', N_("print the raw data of the first sector"), {0, FDISK_DISKLABEL_ANY}},
-       {'e', N_("change number of extra sectors per cylinder"), {0, FDISK_DISKLABEL_SUN}},
-       {'e', N_("edit drive data"), {FDISK_DISKLABEL_OSF, 0}},
-       {'e', N_("list extended partitions"), {0, FDISK_DISKLABEL_DOS}},
-       {'f', N_("fix partition order"), {0, FDISK_DISKLABEL_DOS}},
-       {'g', N_("create a new empty GPT partition table"), {~FDISK_DISKLABEL_OSF, 0}},
-       {'g', N_("create an IRIX (SGI) partition table"), {0, FDISK_DISKLABEL_ANY}}, /* for backward compatibility only */
-       {'h', N_("change number of heads"), {0, FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN}},
-       {'i', N_("change interleave factor"), {0, FDISK_DISKLABEL_SUN}},
-       {'i', N_("change the disk identifier"), {0, FDISK_DISKLABEL_DOS}},
-       {'i', N_("install bootstrap"), {FDISK_DISKLABEL_OSF, 0}},
-       {'l', N_("list known partition types"), {FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI | FDISK_DISKLABEL_OSF  | FDISK_DISKLABEL_GPT, 0}},
-       {'m', N_("print this menu"), {FDISK_DISKLABEL_ANY, FDISK_DISKLABEL_ANY}},
-       {'n', N_("add a new partition"), {FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI | FDISK_DISKLABEL_OSF | FDISK_DISKLABEL_GPT, 0}},
-       {'o', N_("change rotation speed (rpm)"), {0, FDISK_DISKLABEL_SUN}},
-       {'o', N_("create a new empty DOS partition table"), {~FDISK_DISKLABEL_OSF, 0}},
-       {'p', N_("print the partition table"), { FDISK_DISKLABEL_ANY, FDISK_DISKLABEL_ANY }},
-       {'q', N_("quit without saving changes"), {FDISK_DISKLABEL_ANY, FDISK_DISKLABEL_ANY}},
-       {'r', N_("return to main menu"), {FDISK_DISKLABEL_OSF, FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI | FDISK_DISKLABEL_OSF}},
-       {'s', N_("change number of sectors/track"), {0, FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN}},
-       {'s', N_("create a new empty Sun disklabel"), {~FDISK_DISKLABEL_OSF, 0}},
-       {'s', N_("show complete disklabel"), {FDISK_DISKLABEL_OSF, 0}},
-       {'t', N_("change a partition's system id"), {FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI | FDISK_DISKLABEL_OSF | FDISK_DISKLABEL_GPT, 0}},
-       {'u', N_("change display/entry units"), {FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI | FDISK_DISKLABEL_OSF, 0}},
-       {'u', N_("change partition UUID"), {0, FDISK_DISKLABEL_GPT}},
-       {'v', N_("verify the partition table"), {FDISK_DISKLABEL_GPT | FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI, FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI}},
-       {'w', N_("write disklabel to disk"), {FDISK_DISKLABEL_OSF, 0}},
-       {'w', N_("write table to disk and exit"), {FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI  | FDISK_DISKLABEL_GPT, FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI}},
-       {'x', N_("extra functionality (experts only)"), {FDISK_DISKLABEL_GPT | FDISK_DISKLABEL_DOS | FDISK_DISKLABEL_SUN | FDISK_DISKLABEL_SGI, 0}},
-#if !defined (__alpha__)
-       {'x', N_("link BSD partition to non-BSD partition"), {FDISK_DISKLABEL_OSF, 0}},
-#endif
-       {'y', N_("change number of physical cylinders"), {0, FDISK_DISKLABEL_SUN}},
-};
-
-
 
 sector_t get_nr_sects(struct partition *p) {
        return read4_little_endian(p->size4);
@@ -175,20 +118,6 @@ get_part_table(int i) {
        return ptes[i].part_table;
 }
 
-void print_menu(struct fdisk_context *cxt, enum menutype menu)
-{
-       size_t i;
-       int id;
-
-       puts(_("Command action"));
-
-       id = cxt && cxt->label ?  cxt->label->id : FDISK_DISKLABEL_ANY;
-
-       for (i = 0; i < ARRAY_SIZE(menulist); i++)
-               if (menulist[i].label[menu] & id)
-                       printf("   %c   %s\n", menulist[i].command, menulist[i].description);
-}
-
 void list_partition_types(struct fdisk_context *cxt)
 {
        struct fdisk_parttype *types;
@@ -886,7 +815,8 @@ expert_command_prompt(struct fdisk_context *cxt)
                                fdisk_sun_set_pcylcount(cxt);
                        break;
                default:
-                       print_menu(cxt, EXPERT_MENU);
+                       print_fdisk_menu(cxt);
+                       break;
                }
        }
 }
@@ -1058,7 +988,7 @@ static void command_prompt(struct fdisk_context *cxt)
                        list_partition_types(cxt);
                        break;
                case 'm':
-                       print_menu(cxt, MAIN_MENU);
+                       print_fdisk_menu(cxt);
                        break;
                case 'n':
                        new_partition(cxt);
@@ -1091,7 +1021,7 @@ static void command_prompt(struct fdisk_context *cxt)
                        break;
                default:
                        unknown_command(c);
-                       print_menu(cxt, MAIN_MENU);
+                       print_fdisk_menu(cxt);
                }
        }
 }
index 45d86c94a1fdc0d0d0036b5233dd87fb1bdf7651..c44dd768fad1dd3fdc9bcb890d93ea2802f7e534 100644 (file)
@@ -67,6 +67,8 @@ enum failure {
 };
 
 
+extern int print_fdisk_menu(struct fdisk_context *cxt);
+
 extern int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask,
                    void *data __attribute__((__unused__)));
 
index baee4ef2c8daf90c846107e8172b5f6ae2fb8251..eaf96dbeba552ebc042901eea502c313ad60ed05 100644 (file)
@@ -333,7 +333,7 @@ bsd_command_prompt (struct fdisk_context *cxt)
        break;
 #endif
       default:
-       print_menu(cxt, MAIN_MENU);
+       print_fdisk_menu(cxt);
        break;
     }
   }