summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2013-05-23 15:55:35 +0200
committerKarel Zak2013-09-16 16:46:56 +0200
commit9f2809033e72e7a24b5d5169b74afa6efbc63330 (patch)
tree6bb3ce8b24738c3c8dd49b5d21f9fef2cedf7461
parentfdisk: add functions to geometry menu (diff)
downloadkernel-qcow2-util-linux-9f2809033e72e7a24b5d5169b74afa6efbc63330.tar.gz
kernel-qcow2-util-linux-9f2809033e72e7a24b5d5169b74afa6efbc63330.tar.xz
kernel-qcow2-util-linux-9f2809033e72e7a24b5d5169b74afa6efbc63330.zip
fdisk: move sun commands to sun menu callback
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--fdisks/fdisk-menu.c55
-rw-r--r--fdisks/fdisk.c28
-rw-r--r--libfdisk/src/sun.c2
3 files changed, 57 insertions, 28 deletions
diff --git a/fdisks/fdisk-menu.c b/fdisks/fdisk-menu.c
index 369f83fa7..fe65d4622 100644
--- a/fdisks/fdisk-menu.c
+++ b/fdisks/fdisk-menu.c
@@ -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__)),
diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c
index 2ed6bcd17..96cd71958 100644
--- a/fdisks/fdisk.c
+++ b/fdisks/fdisk.c
@@ -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)
diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c
index cd14cccec..baab28b7c 100644
--- a/libfdisk/src/sun.c
+++ b/libfdisk/src/sun.c
@@ -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),