summaryrefslogtreecommitdiffstats
path: root/fdisks/fdisk.c
diff options
context:
space:
mode:
authorKarel Zak2013-07-12 11:31:12 +0200
committerKarel Zak2013-09-16 16:47:08 +0200
commit27ddd4f1587b8d122f3d0f8e8a77ced5edf6cc6a (patch)
tree97ea052cb654c96bbf46ed572b4e853eace34af6 /fdisks/fdisk.c
parentfdisk: move expect actions to menu callback (diff)
downloadkernel-qcow2-util-linux-27ddd4f1587b8d122f3d0f8e8a77ced5edf6cc6a.tar.gz
kernel-qcow2-util-linux-27ddd4f1587b8d122f3d0f8e8a77ced5edf6cc6a.tar.xz
kernel-qcow2-util-linux-27ddd4f1587b8d122f3d0f8e8a77ced5edf6cc6a.zip
fdisk: move remaining actions to menu callbacks
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks/fdisk.c')
-rw-r--r--fdisks/fdisk.c81
1 files changed, 3 insertions, 78 deletions
diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c
index 451ad6f51..9427d2fd6 100644
--- a/fdisks/fdisk.c
+++ b/fdisks/fdisk.c
@@ -156,7 +156,7 @@ void toggle_dos_compatibility_flag(struct fdisk_context *cxt)
fdisk_reset_alignment(cxt);
}
-static void change_partition_type(struct fdisk_context *cxt)
+void change_partition_type(struct fdisk_context *cxt)
{
size_t i;
struct fdisk_parttype *t, *org_t;
@@ -378,82 +378,6 @@ print_all_partition_table_from_option(struct fdisk_context *cxt)
fclose(procpt);
}
-static void command_prompt(struct fdisk_context *cxt)
-{
- int c, rc = -EINVAL;
- size_t n;
-
- assert(cxt);
-
- while (1) {
- assert(cxt->label);
-
- c = process_fdisk_menu(&cxt);
- if (c <= 0)
- continue;
-
- /* well, process_fdisk_menu() returns commands that
- * are not yet implemented by menu callbacks. Let's
- * perform the commands here */
- switch (c) {
- case 'd':
- rc = fdisk_ask_partnum(cxt, &n, FALSE);
- if (!rc)
- rc = fdisk_delete_partition(cxt, n);
- if (rc)
- fdisk_warnx(cxt, _("Could not delete partition %d"), n + 1);
- else
- fdisk_info(cxt, _("Partition %d is deleted"), n + 1);
- break;
- case 'l':
- list_partition_types(cxt);
- break;
- case 'n':
- rc = fdisk_add_partition(cxt, NULL);
- break;
- case 'p':
- list_disk_geometry(cxt);
- fdisk_list_disklabel(cxt);
- break;
- case 'q':
- fdisk_free_context(cxt);
- printf("\n");
- exit(EXIT_SUCCESS);
- case 't':
- change_partition_type(cxt);
- break;
- case 'u':
- fdisk_context_set_unit(cxt,
- fdisk_context_use_cylinders(cxt) ? "sectors" :
- "cylinders");
- if (fdisk_context_use_cylinders(cxt))
- fdisk_info(cxt, _("Changing display/entry units to cylinders (DEPRECATED!)."));
- else
- fdisk_info(cxt, _("Changing display/entry units to sectors."));
- break;
- case 'v':
- fdisk_verify_disklabel(cxt);
- break;
- case 'w':
- write_table(cxt);
- break;
- case 'x':
- fdisk_context_enable_details(cxt, 1);
- break;
- case 'r':
- if (cxt->parent) {
- struct fdisk_context *tmp = cxt->parent;
-
- fdisk_free_context(cxt);
- cxt = tmp;
- }
- break;
- default:
- printf(_("%c: unknown command\n"), c);
- }
- }
-}
-
static sector_t get_dev_blocks(char *dev)
{
int fd;
@@ -605,7 +529,8 @@ int main(int argc, char **argv)
fdisk_create_disklabel(cxt, NULL);
}
- command_prompt(cxt);
+ while (1)
+ process_fdisk_menu(&cxt);
fdisk_free_context(cxt);
return 0;