]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: move sun commands to sun menu callback
authorKarel Zak <kzak@redhat.com>
Thu, 23 May 2013 13:55:35 +0000 (15:55 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 16 Sep 2013 14:46:56 +0000 (16:46 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisks/fdisk-menu.c
fdisks/fdisk.c
libfdisk/src/sun.c

index 369f83fa70e4d89a3deab04911fe05da9628eff2..fe65d46224212ff9c3c70aae31d9011c5e785e30 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "c.h"
 #include "fdisk.h"
+#include "pt-sun.h"
 
 struct menu_entry {
        const char      key;
@@ -44,6 +45,7 @@ struct menu_context {
                     const struct menu_entry *)
 
 DECLARE_MENU_CB(gpt_menu_cb);
+DECLARE_MENU_CB(sun_menu_cb);
 DECLARE_MENU_CB(geo_menu_cb);
 
 /*
@@ -139,7 +141,7 @@ struct menu menu_gpt = {
 };
 
 struct menu menu_sun = {
-/*     .callback = sun_menu_cb, */
+       .callback = sun_menu_cb,
        .label = FDISK_DISKLABEL_SUN,
        .entries = {
                MENU_BSEP(N_("Sun")),
@@ -402,6 +404,57 @@ static int gpt_menu_cb(struct fdisk_context *cxt,
        return rc;
 }
 
+static int sun_menu_cb(struct fdisk_context *cxt,
+                      const struct menu *menu __attribute__((__unused__)),
+                      const struct menu_entry *ent)
+{
+       int rc = 0;
+
+       assert(cxt);
+       assert(ent);
+       assert(fdisk_is_disklabel(cxt, SUN));
+
+       DBG(FRONTEND, dbgprint("enter SUN menu"));
+
+       /* normal mode */
+       if (!ent->expert) {
+               size_t n;
+
+               rc = fdisk_ask_partnum(cxt, &n, FALSE);
+               if (rc)
+                       return rc;
+               switch (ent->key) {
+               case 'a':
+                       rc = fdisk_partition_toggle_flag(cxt, n, SUN_FLAG_RONLY);
+                       break;
+               case 'c':
+                       rc = fdisk_partition_toggle_flag(cxt, n, SUN_FLAG_UNMNT);
+                       break;
+               }
+               return rc;
+       }
+
+       /* expert mode */
+       switch (ent->key) {
+       case 'a':
+               rc = fdisk_sun_set_alt_cyl(cxt);
+               break;
+       case 'e':
+               rc = fdisk_sun_set_xcyl(cxt);
+               break;
+       case 'i':
+               rc = fdisk_sun_set_ilfact(cxt);
+               break;
+       case 'o':
+               rc = fdisk_sun_set_rspeed(cxt);
+               break;
+       case 'y':
+               rc = fdisk_sun_set_pcylcount(cxt);
+               break;
+       }
+       return rc;
+}
+
 /* C/H/S commands */
 static int geo_menu_cb(struct fdisk_context *cxt,
                       const struct menu *menu __attribute__((__unused__)),
index 2ed6bcd179561a5ce2c174d8d258bc6b2e791d62..96cd71958d28edc152e55db6530b508227485237 100644 (file)
@@ -738,10 +738,6 @@ expert_command_prompt(struct fdisk_context *cxt)
                 * are not yet implemented by menu callbacks. Let's
                 * perform the commands here */
                switch (c) {
-               case 'a':
-                       if (fdisk_is_disklabel(cxt, SUN))
-                               fdisk_sun_set_alt_cyl(cxt);
-                       break;
                case 'b':
                        if (fdisk_is_disklabel(cxt, DOS) &&
                            fdisk_ask_partnum(cxt, &n, FALSE) == 0)
@@ -753,10 +749,7 @@ expert_command_prompt(struct fdisk_context *cxt)
                case 'e':
                        if (fdisk_is_disklabel(cxt, SGI))
                                sgi_set_xcyl();
-                       else if (fdisk_is_disklabel(cxt, SUN))
-                               fdisk_sun_set_xcyl(cxt);
-                       else
-                               if (fdisk_is_disklabel(cxt, DOS))
+                       else if (fdisk_is_disklabel(cxt, DOS))
                                        dos_list_table_expert(cxt, 1);
                        break;
                case 'f':
@@ -769,15 +762,9 @@ expert_command_prompt(struct fdisk_context *cxt)
                        fdisk_create_disklabel(cxt, "sgi");
                        break;
                case 'i':
-                       if (fdisk_is_disklabel(cxt, SUN))
-                               fdisk_sun_set_ilfact(cxt);
-                       else if (fdisk_is_disklabel(cxt, DOS))
+                       if (fdisk_is_disklabel(cxt, DOS))
                                dos_set_mbr_id(cxt);
                        break;
-               case 'o':
-                       if (fdisk_is_disklabel(cxt, SUN))
-                               fdisk_sun_set_rspeed(cxt);
-                       break;
                case 'p':
                        list_table(cxt, 1);
                        break;
@@ -792,10 +779,6 @@ expert_command_prompt(struct fdisk_context *cxt)
                case 'w':
                        write_table(cxt);
                        break;
-               case 'y':
-                       if (fdisk_is_disklabel(cxt, SUN))
-                               fdisk_sun_set_pcylcount(cxt);
-                       break;
                }
        }
 }
@@ -917,10 +900,6 @@ static void command_prompt(struct fdisk_context *cxt)
                            fdisk_ask_partnum(cxt, &n, FALSE) == 0)
                                fdisk_partition_toggle_flag(cxt, n, DOS_FLAG_ACTIVE);
 
-                       else if (fdisk_is_disklabel(cxt, SUN) &&
-                                fdisk_ask_partnum(cxt, &n, FALSE) == 0)
-                               fdisk_partition_toggle_flag(cxt, n, SUN_FLAG_UNMNT);
-
                        else if (fdisk_is_disklabel(cxt, SGI) &&
                                 fdisk_ask_partnum(cxt, &n, FALSE) == 0)
                                fdisk_partition_toggle_flag(cxt, n, SGI_FLAG_BOOT);
@@ -944,9 +923,6 @@ static void command_prompt(struct fdisk_context *cxt)
                case 'c':
                        if (fdisk_is_disklabel(cxt, DOS))
                                toggle_dos_compatibility_flag(cxt);
-                       else if (fdisk_is_disklabel(cxt, SUN) &&
-                                fdisk_ask_partnum(cxt, &n, FALSE) == 0)
-                               fdisk_partition_toggle_flag(cxt, n, SUN_FLAG_RONLY);
 
                        else if (fdisk_is_disklabel(cxt, SGI) &&
                                 fdisk_ask_partnum(cxt, &n, FALSE) == 0)
index cd14cccece891471f341d8b2013b8dbbb8b0f544..baab28b7c6aadccb7201863e2bb17a91902842ac 100644 (file)
@@ -687,7 +687,7 @@ static int sun_list_disklabel(struct fdisk_context *cxt)
                _("Label geometry: %d rpm, %d alternate and %d physical cylinders,\n"
                  "                %d extra sects/cyl, interleave %d:1\n"
                  "Label ID: %s\n"
-                 "Volume ID: %s"),
+                 "Volume ID: %s\n"),
                       be16_to_cpu(sunlabel->rpm),
                       be16_to_cpu(sunlabel->acyl),
                       be16_to_cpu(sunlabel->pcyl),