]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - disk-utils/fdisk-menu.c
ea12ac74ee2031ed146a0bf94e6366372bd0510d
14 const char key
; /* command key */
15 const char *title
; /* help string */
16 unsigned int normal
: 1, /* normal mode */
17 expert
: 1, /* expert mode */
18 hidden
: 1; /* be sensitive for this key,
19 but don't print it in help */
21 enum fdisk_labeltype label
; /* only for this label */
22 enum fdisk_labeltype exclude
; /* all labels except this */
23 enum fdisk_labeltype parent
; /* for nested PT */
26 #define IS_MENU_SEP(e) ((e)->key == '-')
27 #define IS_MENU_HID(e) ((e)->hidden)
30 enum fdisk_labeltype label
; /* only for this label */
31 enum fdisk_labeltype exclude
; /* all labels except this */
33 unsigned int nonested
: 1; /* don't make this menu active in nested PT */
35 int (*callback
)(struct fdisk_context
**,
37 const struct menu_entry
*);
39 struct menu_entry entries
[]; /* NULL terminated array */
43 size_t menu_idx
; /* the current menu */
44 size_t entry_idx
; /* index with in the current menu */
47 #define MENU_CXT_EMPTY { 0, 0 }
48 #define DECLARE_MENU_CB(x) \
49 static int x(struct fdisk_context **, \
50 const struct menu *, \
51 const struct menu_entry *)
53 DECLARE_MENU_CB(gpt_menu_cb
);
54 DECLARE_MENU_CB(sun_menu_cb
);
55 DECLARE_MENU_CB(sgi_menu_cb
);
56 DECLARE_MENU_CB(geo_menu_cb
);
57 DECLARE_MENU_CB(dos_menu_cb
);
58 DECLARE_MENU_CB(bsd_menu_cb
);
59 DECLARE_MENU_CB(createlabel_menu_cb
);
60 DECLARE_MENU_CB(generic_menu_cb
);
64 * MENU_X* expert mode only
65 * MENU_B* both -- expert + normal mode
67 * *_E exclude this label
69 * *_L only for this label
73 #define MENU_SEP(t) { .title = t, .key = '-', .normal = 1 }
74 #define MENU_XSEP(t) { .title = t, .key = '-', .expert = 1 }
75 #define MENU_BSEP(t) { .title = t, .key = '-', .expert = 1, .normal = 1 }
78 #define MENU_ENT(k, t) { .title = t, .key = k, .normal = 1 }
79 #define MENU_ENT_E(k, t, l) { .title = t, .key = k, .normal = 1, .exclude = l }
80 #define MENU_ENT_L(k, t, l) { .title = t, .key = k, .normal = 1, .label = l }
82 #define MENU_XENT(k, t) { .title = t, .key = k, .expert = 1 }
83 #define MENU_XENT_H(k, t) { .title = t, .key = k, .expert = 1, .hidden = 1 }
85 #define MENU_BENT(k, t) { .title = t, .key = k, .expert = 1, .normal = 1 }
86 #define MENU_BENT_E(k, t, l) { .title = t, .key = k, .expert = 1, .normal = 1, .exclude = l }
88 #define MENU_ENT_NEST(k, t, l, p) { .title = t, .key = k, .normal = 1, .label = l, .parent = p }
89 #define MENU_XENT_NEST(k, t, l, p) { .title = t, .key = k, .expert = 1, .label = l, .parent = p }
92 struct menu menu_generic
= {
93 .callback
= generic_menu_cb
,
95 MENU_BSEP(N_("Generic")),
96 MENU_ENT ('d', N_("delete a partition")),
97 MENU_ENT ('F', N_("list free unpartitioned space")),
98 MENU_ENT ('l', N_("list known partition types")),
99 MENU_ENT ('n', N_("add a new partition")),
100 MENU_BENT ('p', N_("print the partition table")),
101 MENU_ENT ('t', N_("change a partition type")),
102 MENU_BENT_E('v', N_("verify the partition table"), FDISK_DISKLABEL_BSD
),
103 MENU_ENT ('i', N_("print information about a partition")),
105 MENU_XENT('d', N_("print the raw data of the first sector from the device")),
106 MENU_XENT('D', N_("print the raw data of the disklabel from the device")),
107 MENU_XENT('f', N_("fix partitions order")),
109 MENU_SEP(N_("Misc")),
110 MENU_BENT ('m', N_("print this menu")),
111 MENU_ENT_E('u', N_("change display/entry units"), FDISK_DISKLABEL_GPT
),
112 MENU_ENT_E('x', N_("extra functionality (experts only)"), FDISK_DISKLABEL_BSD
),
114 MENU_SEP(N_("Script")),
115 MENU_ENT ('I', N_("load disk layout from sfdisk script file")),
116 MENU_ENT ('O', N_("dump disk layout to sfdisk script file")),
118 MENU_BSEP(N_("Save & Exit")),
119 MENU_ENT_E('w', N_("write table to disk and exit"), FDISK_DISKLABEL_BSD
),
120 MENU_ENT_L('w', N_("write table to disk"), FDISK_DISKLABEL_BSD
),
121 MENU_BENT ('q', N_("quit without saving changes")),
122 MENU_XENT ('r', N_("return to main menu")),
124 MENU_ENT_NEST('r', N_("return from BSD to DOS"), FDISK_DISKLABEL_BSD
, FDISK_DISKLABEL_DOS
),
130 struct menu menu_createlabel
= {
131 .callback
= createlabel_menu_cb
,
132 .exclude
= FDISK_DISKLABEL_BSD
,
135 MENU_SEP(N_("Create a new label")),
136 MENU_ENT('g', N_("create a new empty GPT partition table")),
137 MENU_ENT('G', N_("create a new empty SGI (IRIX) partition table")),
138 MENU_ENT('o', N_("create a new empty DOS partition table")),
139 MENU_ENT('s', N_("create a new empty Sun partition table")),
141 /* backward compatibility -- be sensitive to 'g', but don't
142 * print it in the expert menu */
143 MENU_XENT_H('g', N_("create an IRIX (SGI) partition table")),
148 struct menu menu_geo
= {
149 .callback
= geo_menu_cb
,
150 .exclude
= FDISK_DISKLABEL_GPT
| FDISK_DISKLABEL_BSD
,
152 MENU_XSEP(N_("Geometry")),
153 MENU_XENT('c', N_("change number of cylinders")),
154 MENU_XENT('h', N_("change number of heads")),
155 MENU_XENT('s', N_("change number of sectors/track")),
160 struct menu menu_gpt
= {
161 .callback
= gpt_menu_cb
,
162 .label
= FDISK_DISKLABEL_GPT
,
164 MENU_XSEP(N_("GPT")),
165 MENU_XENT('i', N_("change disk GUID")),
166 MENU_XENT('n', N_("change partition name")),
167 MENU_XENT('u', N_("change partition UUID")),
168 MENU_XENT('M', N_("enter protective/hybrid MBR")),
171 MENU_XENT('A', N_("toggle the legacy BIOS bootable flag")),
172 MENU_XENT('B', N_("toggle the no block IO protocol flag")),
173 MENU_XENT('R', N_("toggle the required partition flag")),
174 MENU_XENT('S', N_("toggle the GUID specific bits")),
180 struct menu menu_sun
= {
181 .callback
= sun_menu_cb
,
182 .label
= FDISK_DISKLABEL_SUN
,
184 MENU_BSEP(N_("Sun")),
185 MENU_ENT('a', N_("toggle the read-only flag")),
186 MENU_ENT('c', N_("toggle the mountable flag")),
188 MENU_XENT('a', N_("change number of alternate cylinders")),
189 MENU_XENT('e', N_("change number of extra sectors per cylinder")),
190 MENU_XENT('i', N_("change interleave factor")),
191 MENU_XENT('o', N_("change rotation speed (rpm)")),
192 MENU_XENT('y', N_("change number of physical cylinders")),
197 struct menu menu_sgi
= {
198 .callback
= sgi_menu_cb
,
199 .label
= FDISK_DISKLABEL_SGI
,
202 MENU_ENT('a', N_("select bootable partition")),
203 MENU_ENT('b', N_("edit bootfile entry")),
204 MENU_ENT('c', N_("select sgi swap partition")),
205 MENU_ENT('i', N_("create SGI info")),
210 struct menu menu_dos
= {
211 .callback
= dos_menu_cb
,
212 .label
= FDISK_DISKLABEL_DOS
,
214 MENU_BSEP(N_("DOS (MBR)")),
215 MENU_ENT('a', N_("toggle a bootable flag")),
216 MENU_ENT('b', N_("edit nested BSD disklabel")),
217 MENU_ENT('c', N_("toggle the dos compatibility flag")),
219 MENU_XENT('b', N_("move beginning of data in a partition")),
220 MENU_XENT('i', N_("change the disk identifier")),
222 MENU_XENT_NEST('M', N_("return from protective/hybrid MBR to GPT"),
223 FDISK_DISKLABEL_DOS
, FDISK_DISKLABEL_GPT
),
228 struct menu menu_bsd
= {
229 .callback
= bsd_menu_cb
,
230 .label
= FDISK_DISKLABEL_BSD
,
233 MENU_ENT('e', N_("edit drive data")),
234 MENU_ENT('i', N_("install bootstrap")),
235 MENU_ENT('s', N_("show complete disklabel")),
236 MENU_ENT('x', N_("link BSD partition to non-BSD partition")),
241 static const struct menu
*menus
[] = {
252 static const struct menu_entry
*next_menu_entry(
253 struct fdisk_context
*cxt
,
254 struct menu_context
*mc
)
256 struct fdisk_label
*lb
= fdisk_get_label(cxt
, NULL
);
257 struct fdisk_context
*parent
= fdisk_get_parent(cxt
);
258 unsigned int type
= 0, pr_type
= 0;
263 type
= fdisk_label_get_type(lb
);
265 pr_type
= fdisk_label_get_type(fdisk_get_label(parent
, NULL
));
267 while (mc
->menu_idx
< ARRAY_SIZE(menus
)) {
268 const struct menu
*m
= menus
[mc
->menu_idx
];
269 const struct menu_entry
*e
= &(m
->entries
[mc
->entry_idx
]);
275 /* no more entries */
276 if (e
->title
== NULL
||
277 /* menu wanted for specified labels only */
278 (m
->label
&& lb
&& !(m
->label
& type
)) ||
279 /* unwanted for nested PT */
280 (m
->nonested
&& parent
) ||
281 /* menu excluded for specified labels */
282 (m
->exclude
&& lb
&& (m
->exclude
& type
))) {
292 /* excluded for the current label */
293 if ((e
->exclude
&& lb
&& e
->exclude
& type
) ||
294 /* entry wanted for specified labels only */
295 (e
->label
&& lb
&& !(e
->label
& type
)) ||
296 /* exclude non-expert entries in expect mode */
297 (e
->expert
== 0 && fdisk_is_details(cxt
)) ||
299 (e
->parent
&& (!parent
|| pr_type
!= e
->parent
)) ||
300 /* exclude non-normal entries in normal mode */
301 (e
->normal
== 0 && !fdisk_is_details(cxt
))) {
312 /* returns @menu and menu entry for then @key */
313 static const struct menu_entry
*get_fdisk_menu_entry(
314 struct fdisk_context
*cxt
,
316 const struct menu
**menu
)
318 struct menu_context mc
= MENU_CXT_EMPTY
;
319 const struct menu_entry
*e
;
321 while ((e
= next_menu_entry(cxt
, &mc
))) {
322 if (IS_MENU_SEP(e
) || e
->key
!= key
)
326 *menu
= menus
[mc
.menu_idx
];
333 static int menu_detect_collisions(struct fdisk_context
*cxt
)
335 struct menu_context mc
= MENU_CXT_EMPTY
;
336 const struct menu_entry
*e
, *r
;
338 while ((e
= next_menu_entry(cxt
, &mc
))) {
342 r
= get_fdisk_menu_entry(cxt
, e
->key
, NULL
);
344 DBG(MENU
, ul_debug("warning: not found "
345 "entry for %c", e
->key
));
349 DBG(MENU
, ul_debug("warning: duplicate key '%c'",
351 DBG(MENU
, ul_debug(" : %s", e
->title
));
352 DBG(MENU
, ul_debug(" : %s", r
->title
));
360 static int print_fdisk_menu(struct fdisk_context
*cxt
)
362 struct menu_context mc
= MENU_CXT_EMPTY
;
363 const struct menu_entry
*e
;
365 ON_DBG(MENU
, menu_detect_collisions(cxt
));
367 if (fdisk_is_details(cxt
))
368 printf(_("\nHelp (expert commands):\n"));
370 printf(_("\nHelp:\n"));
372 while ((e
= next_menu_entry(cxt
, &mc
))) {
374 continue; /* hidden entry */
375 if (IS_MENU_SEP(e
) && (!e
->title
|| !*e
->title
))
377 else if (IS_MENU_SEP(e
)) {
378 color_scheme_enable("help-title", UL_COLOR_BOLD
);
379 printf("\n %s\n", _(e
->title
));
382 printf(" %c %s\n", e
->key
, _(e
->title
));
386 if (fdisk_get_parent(cxt
)) {
387 struct fdisk_label
*l
= fdisk_get_label(cxt
, NULL
),
388 *p
= fdisk_get_label(fdisk_get_parent(cxt
), NULL
);
390 fdisk_info(cxt
, _("You're editing nested '%s' partition table, "
391 "primary partition table is '%s'."),
392 fdisk_label_get_name(l
),
393 fdisk_label_get_name(p
));
399 /* Asks for command, verify the key and perform the command or
400 * returns the command key if no callback for the command is
403 * Note that this function might exchange the context pointer to
404 * switch to another (nested) context.
406 * Returns: <0 on error
407 * 0 on success (the command performed)
408 * >0 if no callback (then returns the key)
410 int process_fdisk_menu(struct fdisk_context
**cxt0
)
412 struct fdisk_context
*cxt
= *cxt0
;
413 const struct menu_entry
*ent
;
414 const struct menu
*menu
;
419 if (fdisk_is_details(cxt
))
420 prompt
= _("Expert command (m for help): ");
422 prompt
= _("Command (m for help): ");
425 rc
= get_user_reply(cxt
, prompt
, buf
, sizeof(buf
));
430 ent
= get_fdisk_menu_entry(cxt
, key
, &menu
);
432 fdisk_warnx(cxt
, _("%c: unknown command"), key
);
437 DBG(MENU
, ul_debug("selected: key=%c, entry='%s'",
440 /* menu has implemented callback, use it */
442 rc
= menu
->callback(cxt0
, menu
, ent
);
444 DBG(MENU
, ul_debug("no callback for key '%c'", key
));
448 DBG(MENU
, ul_debug("process menu done [rc=%d]", rc
));
452 static int script_read(struct fdisk_context
*cxt
)
454 struct fdisk_script
*sc
= NULL
;
455 char *filename
= NULL
;
458 rc
= fdisk_ask_string(cxt
, _("Enter script file name"), &filename
);
463 sc
= fdisk_new_script_from_file(cxt
, filename
);
465 fdisk_warn(cxt
, _("Cannot open %s"), filename
);
467 fdisk_warnx(cxt
, _("Failed to parse script file %s"), filename
);
468 else if (fdisk_apply_script(cxt
, sc
) != 0)
469 fdisk_warnx(cxt
, _("Failed to apply script %s"), filename
);
471 fdisk_info(cxt
, _("Script successfully applied."));
473 fdisk_unref_script(sc
);
478 static int script_write(struct fdisk_context
*cxt
)
480 struct fdisk_script
*sc
= NULL
;
481 char *filename
= NULL
;
485 rc
= fdisk_ask_string(cxt
, _("Enter script file name"), &filename
);
489 sc
= fdisk_new_script(cxt
);
491 fdisk_warn(cxt
, _("Failed to allocate script handler"));
495 rc
= fdisk_script_read_context(sc
, NULL
);
497 fdisk_warnx(cxt
, _("Failed to transform disk layout into script"));
501 f
= fopen(filename
, "w");
503 fdisk_warn(cxt
, _("Cannot open %s"), filename
);
507 rc
= fdisk_script_write_file(sc
, f
);
509 fdisk_warn(cxt
, _("Failed to write script %s"), filename
);
511 fdisk_info(cxt
, _("Script successfully saved."));
515 fdisk_unref_script(sc
);
521 * Basic fdisk actions
523 static int generic_menu_cb(struct fdisk_context
**cxt0
,
524 const struct menu
*menu
__attribute__((__unused__
)),
525 const struct menu_entry
*ent
)
527 struct fdisk_context
*cxt
= *cxt0
;
531 /* actions shared between expert and normal mode */
534 list_disk_geometry(cxt
);
538 if (fdisk_is_readonly(cxt
)) {
539 fdisk_warnx(cxt
, _("Device open in read-only mode."));
542 rc
= fdisk_write_disklabel(cxt
);
544 err(EXIT_FAILURE
, _("failed to write disklabel"));
545 if (fdisk_get_parent(cxt
))
546 break; /* nested PT, don't leave */
547 fdisk_info(cxt
, _("The partition table has been altered."));
548 rc
= fdisk_reread_partition_table(cxt
);
550 rc
= fdisk_deassign_device(cxt
, 0);
553 fdisk_unref_context(cxt
);
555 exit(rc
== 0 ? EXIT_SUCCESS
: EXIT_FAILURE
);
557 rc
= print_fdisk_menu(cxt
);
560 rc
= fdisk_verify_disklabel(cxt
);
563 rc
= print_partition_info(cxt
);
574 dump_firstsector(cxt
);
580 rc
= fdisk_reorder_partitions(cxt
);
583 rc
= fdisk_enable_details(cxt
, 0);
592 rc
= fdisk_ask_partnum(cxt
, &n
, FALSE
);
594 rc
= fdisk_delete_partition(cxt
, n
);
596 fdisk_warnx(cxt
, _("Could not delete partition %zu"), n
+ 1);
598 fdisk_info(cxt
, _("Partition %zu has been deleted."), n
+ 1);
607 list_partition_types(cxt
);
610 rc
= fdisk_add_partition(cxt
, NULL
, NULL
);
613 change_partition_type(cxt
);
617 fdisk_use_cylinders(cxt
) ? "sectors" :
619 if (fdisk_use_cylinders(cxt
))
620 fdisk_info(cxt
, _("Changing display/entry units to cylinders (DEPRECATED!)."));
622 fdisk_info(cxt
, _("Changing display/entry units to sectors."));
625 fdisk_enable_details(cxt
, 1);
628 /* return from nested BSD to DOS */
629 if (fdisk_get_parent(cxt
)) {
630 *cxt0
= fdisk_get_parent(cxt
);
632 fdisk_info(cxt
, _("Leaving nested disklabel."));
633 fdisk_unref_context(cxt
);
644 * This is fdisk frontend for GPT specific libfdisk functions that
645 * are not expported by generic libfdisk API.
647 static int gpt_menu_cb(struct fdisk_context
**cxt0
,
648 const struct menu
*menu
__attribute__((__unused__
)),
649 const struct menu_entry
*ent
)
651 struct fdisk_context
*cxt
= *cxt0
;
652 struct fdisk_context
*mbr
;
653 struct fdisk_partition
*pa
= NULL
;
659 assert(fdisk_is_label(cxt
, GPT
));
661 DBG(MENU
, ul_debug("enter GPT menu"));
666 return fdisk_set_disklabel_id(cxt
);
668 mbr
= fdisk_new_nested_context(cxt
, "dos");
672 fdisk_enable_details(cxt
, 1); /* keep us in expert mode */
673 fdisk_info(cxt
, _("Entering protective/hybrid MBR disklabel."));
677 /* actions where is necessary partnum */
678 rc
= fdisk_ask_partnum(cxt
, &n
, FALSE
);
684 pa
= fdisk_new_partition(); /* new template */
689 rc
= fdisk_ask_string(cxt
, _("New UUID (in 8-4-4-4-12 format)"), &str
);
691 rc
= fdisk_partition_set_uuid(pa
, str
);
693 rc
= fdisk_set_partition(cxt
, n
, pa
);
695 fdisk_unref_partition(pa
);
699 pa
= fdisk_new_partition(); /* new template */
704 rc
= fdisk_ask_string(cxt
, _("New name"), &str
);
706 rc
= fdisk_partition_set_name(pa
, str
);
708 rc
= fdisk_set_partition(cxt
, n
, pa
);
710 fdisk_unref_partition(pa
);
714 rc
= fdisk_toggle_partition_flag(cxt
, n
, GPT_FLAG_LEGACYBOOT
);
717 rc
= fdisk_toggle_partition_flag(cxt
, n
, GPT_FLAG_NOBLOCK
);
720 rc
= fdisk_toggle_partition_flag(cxt
, n
, GPT_FLAG_REQUIRED
);
723 rc
= fdisk_toggle_partition_flag(cxt
, n
, GPT_FLAG_GUIDSPECIFIC
);
733 * This is fdisk frontend for MBR specific libfdisk functions that
734 * are not expported by generic libfdisk API.
736 static int dos_menu_cb(struct fdisk_context
**cxt0
,
737 const struct menu
*menu
__attribute__((__unused__
)),
738 const struct menu_entry
*ent
)
740 struct fdisk_context
*cxt
= *cxt0
;
743 DBG(MENU
, ul_debug("enter DOS menu"));
750 rc
= fdisk_ask_partnum(cxt
, &n
, FALSE
);
752 rc
= fdisk_toggle_partition_flag(cxt
, n
, DOS_FLAG_ACTIVE
);
757 struct fdisk_context
*bsd
758 = fdisk_new_nested_context(cxt
, "bsd");
761 if (!fdisk_has_label(bsd
))
762 rc
= fdisk_create_disklabel(bsd
, "bsd");
764 fdisk_unref_context(bsd
);
767 fdisk_info(cxt
, _("Entering nested BSD disklabel."));
772 toggle_dos_compatibility_flag(cxt
);
783 rc
= fdisk_ask_partnum(cxt
, &n
, FALSE
);
785 rc
= fdisk_dos_move_begin(cxt
, n
);
789 rc
= fdisk_set_disklabel_id(cxt
);
792 /* return from nested MBR to GPT */
793 if (fdisk_get_parent(cxt
)) {
794 *cxt0
= fdisk_get_parent(cxt
);
796 fdisk_info(cxt
, _("Leaving nested disklabel."));
797 fdisk_unref_context(cxt
);
805 static int sun_menu_cb(struct fdisk_context
**cxt0
,
806 const struct menu
*menu
__attribute__((__unused__
)),
807 const struct menu_entry
*ent
)
809 struct fdisk_context
*cxt
= *cxt0
;
812 DBG(MENU
, ul_debug("enter SUN menu"));
816 assert(fdisk_is_label(cxt
, SUN
));
818 DBG(MENU
, ul_debug("enter SUN menu"));
824 rc
= fdisk_ask_partnum(cxt
, &n
, FALSE
);
829 rc
= fdisk_toggle_partition_flag(cxt
, n
, SUN_FLAG_RONLY
);
832 rc
= fdisk_toggle_partition_flag(cxt
, n
, SUN_FLAG_UNMNT
);
841 rc
= fdisk_sun_set_alt_cyl(cxt
);
844 rc
= fdisk_sun_set_xcyl(cxt
);
847 rc
= fdisk_sun_set_ilfact(cxt
);
850 rc
= fdisk_sun_set_rspeed(cxt
);
853 rc
= fdisk_sun_set_pcylcount(cxt
);
859 static int sgi_menu_cb(struct fdisk_context
**cxt0
,
860 const struct menu
*menu
__attribute__((__unused__
)),
861 const struct menu_entry
*ent
)
863 struct fdisk_context
*cxt
= *cxt0
;
867 DBG(MENU
, ul_debug("enter SGI menu"));
871 assert(fdisk_is_label(cxt
, SGI
));
878 rc
= fdisk_ask_partnum(cxt
, &n
, FALSE
);
880 rc
= fdisk_toggle_partition_flag(cxt
, n
, SGI_FLAG_BOOT
);
883 fdisk_sgi_set_bootfile(cxt
);
886 rc
= fdisk_ask_partnum(cxt
, &n
, FALSE
);
888 rc
= fdisk_toggle_partition_flag(cxt
, n
, SGI_FLAG_SWAP
);
891 rc
= fdisk_sgi_create_info(cxt
);
899 * This is fdisk frontend for BSD specific libfdisk functions that
900 * are not expported by generic libfdisk API.
902 static int bsd_menu_cb(struct fdisk_context
**cxt0
,
903 const struct menu
*menu
__attribute__((__unused__
)),
904 const struct menu_entry
*ent
)
906 struct fdisk_context
*cxt
= *cxt0
;
911 assert(fdisk_is_label(cxt
, BSD
));
913 DBG(MENU
, ul_debug("enter BSD menu"));
917 rc
= fdisk_bsd_edit_disklabel(cxt
);
920 rc
= fdisk_bsd_write_bootstrap(cxt
);
923 org
= fdisk_is_details(cxt
);
925 fdisk_enable_details(cxt
, 1);
927 fdisk_enable_details(cxt
, org
);
930 rc
= fdisk_bsd_link_partition(cxt
);
937 static int geo_menu_cb(struct fdisk_context
**cxt0
,
938 const struct menu
*menu
__attribute__((__unused__
)),
939 const struct menu_entry
*ent
)
941 struct fdisk_context
*cxt
= *cxt0
;
943 uintmax_t c
= 0, h
= 0, s
= 0;
945 DBG(MENU
, ul_debug("enter GEO menu"));
952 rc
= fdisk_ask_number(cxt
, 1, fdisk_get_geom_cylinders(cxt
),
953 1048576, _("Number of cylinders"), &c
);
956 rc
= fdisk_ask_number(cxt
, 1, fdisk_get_geom_heads(cxt
),
957 256, _("Number of heads"), &h
);
960 rc
= fdisk_ask_number(cxt
, 1, fdisk_get_geom_sectors(cxt
),
961 63, _("Number of sectors"), &s
);
966 fdisk_override_geometry(cxt
, c
, h
, s
);
970 static int createlabel_menu_cb(struct fdisk_context
**cxt0
,
971 const struct menu
*menu
__attribute__((__unused__
)),
972 const struct menu_entry
*ent
)
974 struct fdisk_context
*cxt
= *cxt0
;
977 DBG(MENU
, ul_debug("enter Create label menu"));
985 /* Deprecated, use 'G' in main menu, just for backward
986 * compatibility only. */
987 rc
= fdisk_create_disklabel(cxt
, "sgi");
995 fdisk_create_disklabel(cxt
, "gpt");
998 fdisk_create_disklabel(cxt
, "sgi");
1001 fdisk_create_disklabel(cxt
, "dos");
1004 fdisk_create_disklabel(cxt
, "sun");