#include "c.h"
#include "fdisk.h"
+#include "pt-sun.h"
struct menu_entry {
const char key;
const struct menu_entry *)
DECLARE_MENU_CB(gpt_menu_cb);
+DECLARE_MENU_CB(sun_menu_cb);
DECLARE_MENU_CB(geo_menu_cb);
/*
};
struct menu menu_sun = {
-/* .callback = sun_menu_cb, */
+ .callback = sun_menu_cb,
.label = FDISK_DISKLABEL_SUN,
.entries = {
MENU_BSEP(N_("Sun")),
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__)),
* 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)
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':
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;
case 'w':
write_table(cxt);
break;
- case 'y':
- if (fdisk_is_disklabel(cxt, SUN))
- fdisk_sun_set_pcylcount(cxt);
- break;
}
}
}
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);
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)