summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fdisks/fdisk-menu.c54
-rw-r--r--fdisks/fdisk.c31
2 files changed, 53 insertions, 32 deletions
diff --git a/fdisks/fdisk-menu.c b/fdisks/fdisk-menu.c
index 20c10e7cd..7820c646a 100644
--- a/fdisks/fdisk-menu.c
+++ b/fdisks/fdisk-menu.c
@@ -49,6 +49,7 @@ struct menu_context {
DECLARE_MENU_CB(gpt_menu_cb);
DECLARE_MENU_CB(sun_menu_cb);
+DECLARE_MENU_CB(sgi_menu_cb);
DECLARE_MENU_CB(geo_menu_cb);
DECLARE_MENU_CB(dos_menu_cb);
DECLARE_MENU_CB(bsd_menu_cb);
@@ -170,13 +171,14 @@ struct menu menu_sun = {
};
struct menu menu_sgi = {
-/* .callback = sgi_menu_cb, */
+ .callback = sgi_menu_cb,
.label = FDISK_DISKLABEL_SGI,
.entries = {
MENU_SEP(N_("SGI")),
MENU_ENT('a', N_("select bootable partition")),
MENU_ENT('b', N_("edit bootfile entry")),
MENU_ENT('c', N_("select sgi swap partition")),
+ MENU_ENT('i', N_("create SGI info")),
{ 0, NULL }
}
};
@@ -548,6 +550,45 @@ static int sun_menu_cb(struct fdisk_context **cxt0,
return rc;
}
+static int sgi_menu_cb(struct fdisk_context **cxt0,
+ const struct menu *menu __attribute__((__unused__)),
+ const struct menu_entry *ent)
+{
+ struct fdisk_context *cxt = *cxt0;
+ int rc = -EINVAL;
+ size_t n = 0;
+
+ DBG(FRONTEND, dbgprint("enter SGI menu"));
+
+ assert(cxt);
+ assert(ent);
+ assert(fdisk_is_disklabel(cxt, SGI));
+
+ if (ent->expert)
+ return rc;
+
+ switch (ent->key) {
+ case 'a':
+ rc = fdisk_ask_partnum(cxt, &n, FALSE);
+ if (!rc)
+ rc = fdisk_partition_toggle_flag(cxt, n, SGI_FLAG_BOOT);
+ break;
+ case 'b':
+ sgi_set_bootfile(cxt);
+ break;
+ case 'c':
+ rc = fdisk_ask_partnum(cxt, &n, FALSE);
+ if (!rc)
+ rc = fdisk_partition_toggle_flag(cxt, n, SGI_FLAG_SWAP);
+ break;
+ case 'i':
+ rc = sgi_create_info(cxt);
+ break;
+ }
+
+ return rc;
+}
+
/*
* This is fdisk frontend for BSD specific libfdisk functions that
* are not expported by generic libfdisk API.
@@ -632,6 +673,17 @@ static int createlabel_menu_cb(struct fdisk_context **cxt0,
assert(cxt);
assert(ent);
+ if (ent->expert) {
+ switch (ent->key) {
+ case 'g':
+ /* Deprecated, use 'G' in main menu, just for backward
+ * compatibility only. */
+ rc = fdisk_create_disklabel(cxt, "sgi");
+ break;
+ }
+ return rc;
+ }
+
switch (ent->key) {
case 'g':
fdisk_create_disklabel(cxt, "gpt");
diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c
index 9fd434852..172e9ce45 100644
--- a/fdisks/fdisk.c
+++ b/fdisks/fdisk.c
@@ -388,11 +388,6 @@ expert_command_prompt(struct fdisk_context *cxt)
case 'd':
print_raw(cxt);
break;
- case 'g':
- /* Deprecated, use 'G' in main menu, just for backward
- * compatibility only. */
- fdisk_create_disklabel(cxt, "sgi");
- break;
case 'p':
list_table(cxt);
break;
@@ -504,36 +499,10 @@ static void 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, SGI) &&
- fdisk_ask_partnum(cxt, &n, FALSE) == 0)
- fdisk_partition_toggle_flag(cxt, n, SGI_FLAG_BOOT);
- else
- unknown_command(c);
- break;
- case 'b':
- if (fdisk_is_disklabel(cxt, SGI))
- sgi_set_bootfile(cxt);
- else
- unknown_command(c);
- break;
- case 'c':
- if (fdisk_is_disklabel(cxt, SGI) &&
- fdisk_ask_partnum(cxt, &n, FALSE) == 0)
- fdisk_partition_toggle_flag(cxt, n, SGI_FLAG_SWAP);
- else
- unknown_command(c);
- break;
case 'd':
if (fdisk_ask_partnum(cxt, &n, FALSE) == 0)
delete_partition(cxt, n);
break;
- case 'i':
- if (fdisk_is_disklabel(cxt, SGI))
- sgi_create_info(cxt);
- else
- unknown_command(c);
- break;
case 'l':
list_partition_types(cxt);
break;