/* * Ask the user which physical disk they want. * Changes ss->selected_disk if successful. */ void fn_select_disk(struct i_fn_args *a) { struct dfui_form *f; struct dfui_action *k; struct dfui_response *r; struct disk *d; f = dfui_form_create( "select_disk", _("Select Disk"), a->short_desc, "", "p", "role", "menu", "p", "special", "dfinstaller_select_disk", NULL ); for (d = storage_disk_first(a->s); d != NULL; d = disk_next(d)) { dfui_form_action_add(f, disk_get_device_name(d), dfui_info_new(disk_get_desc(d), "", "")); } k = dfui_form_action_add(f, "cancel", dfui_info_new(a->cancel_desc, "", "")); dfui_action_property_set(k, "accelerator", "ESC"); if (!dfui_be_present(a->c, f, &r)) abort_backend(); if (strcmp(dfui_response_get_action_id(r), "cancel") == 0) { a->result = 0; } else { d = disk_find(a->s, dfui_response_get_action_id(r)); if (d == NULL) { inform(a->c, _("Internal error - response from frontend " "should be a valid device name.")); a->result = 0; } else { storage_set_selected_disk(a->s, d); a->result = 1; } } dfui_form_free(f); dfui_response_free(r); }
void state_diskutil_menu(struct i_fn_args *a) { struct dfui_form *f; struct dfui_action *k; struct dfui_response *r; int done = 0; while (!done) { f = dfui_form_create( "utilities_menu", _("Disk Utilities Menu"), _("These functions let you manipulate the storage devices " "attached to this computer."), "", "p", "role", "menu", "a", "format_hdd", _("Format a hard disk drive"), "", "", "a", "wipe_start_of_disk", _("Wipe out the start of a disk"), "", "", "a", "wipe_start_of_slice", _("Wipe out the start of a primary partition"), "", "", "a", "install_bootblocks", _("Install bootblocks on disks"), "", "", "a", "format_msdos_floppy", _("Format an MSDOS floppy"), "", "", NULL ); if (is_file("%sboot/cdboot.flp.bz2", a->os_root)) { dfui_form_action_add(f, "create_cdboot_floppy", dfui_info_new(_("Create a CDBoot floppy"), "", "")); } k = dfui_form_action_add(f, "cancel", dfui_info_new(_("Return to Utilities Menu"), "", "")); dfui_action_property_set(k, "accelerator", "ESC"); if (!dfui_be_present(a->c, f, &r)) abort_backend(); /* XXX set up a */ if (strcmp(dfui_response_get_action_id(r), "format_hdd") == 0) { storage_set_selected_disk(a->s, NULL); storage_set_selected_slice(a->s, NULL); fn_format_disk(a); } else if (strcmp(dfui_response_get_action_id(r), "wipe_start_of_disk") == 0) { fn_wipe_start_of_disk(a); } else if (strcmp(dfui_response_get_action_id(r), "wipe_start_of_slice") == 0) { fn_wipe_start_of_slice(a); } else if (strcmp(dfui_response_get_action_id(r), "install_bootblocks") == 0) { a->short_desc = _("Select the disks on which " "you wish to install bootblocks."); a->cancel_desc = _("Return to Utilities Menu"); fn_install_bootblocks(a, NULL); } else if (strcmp(dfui_response_get_action_id(r), "format_msdos_floppy") == 0) { fn_format_msdos_floppy(a); } else if (strcmp(dfui_response_get_action_id(r), "create_cdboot_floppy") == 0) { fn_create_cdboot_floppy(a); } else if (strcmp(dfui_response_get_action_id(r), "cancel") == 0) { state = state_utilities_menu; done = 1; } dfui_form_free(f); dfui_response_free(r); } }
/* * state_welcome_livecd: the start state of the installer state machine, * when run from the Live CD. Briefly describe DragonFly to the user, * and present them with a set of reasonable options of how to proceed. */ void state_welcome(struct i_fn_args *a) { struct dfui_form *f; struct dfui_action *k; struct dfui_response *r; char msg_buf[2][1024]; snprintf(msg_buf[0], sizeof(msg_buf[0]), _("Welcome to %s"), OPERATING_SYSTEM_NAME); snprintf(msg_buf[1], sizeof(msg_buf[1]), _("Welcome to the %s Live CD." "\n\n" "%s is an efficient and elegant BSD " "Unix-derived operating system. For more information, see %s" "\n\n" "From this CD, you can boot into %s ``live'' " "(without installing it) to evaluate it, to install it " "manually, or to troubleshoot problems with an " "existing installation, using either a command prompt " "or menu-driven utilities." "\n\n" "Also, you can use this automated application to assist " "you in installing %s on this computer and " "configuring it once it is installed." ""), OPERATING_SYSTEM_NAME, OPERATING_SYSTEM_NAME, OPERATING_SYSTEM_URL, OPERATING_SYSTEM_NAME, OPERATING_SYSTEM_NAME); if (!a->booted_from_livecd) { state = state_welcome_system; return; } f = dfui_form_create( "welcome", msg_buf[0], msg_buf[1], "", "p", "special", "dfinstaller_welcome", NULL ); if (a->upgrade_menu_toggle) { snprintf(msg_buf[0], sizeof(msg_buf[0]), _("Upgrade a FreeBSD 4.X system to %s"), OPERATING_SYSTEM_NAME); dfui_form_action_add(f, "upgrade", dfui_info_new(_("Upgrade"), msg_buf[0], "")); } else { snprintf(msg_buf[0], sizeof(msg_buf[0]), _("Install %s"), OPERATING_SYSTEM_NAME); snprintf(msg_buf[1], sizeof(msg_buf[1]), _("Install %s on a HDD or HDD partition on this computer"), OPERATING_SYSTEM_NAME); dfui_form_action_add(f, "install", dfui_info_new(msg_buf[0], msg_buf[1], "")); } snprintf(msg_buf[0], sizeof(msg_buf[0]), _("Configure a %s system once it has been installed on HDD"), OPERATING_SYSTEM_NAME); dfui_form_action_add(f, "configure", dfui_info_new(_("Configure an Installed System"), msg_buf[0], "")); dfui_form_action_add(f, "utilities", dfui_info_new(_("Live CD Utilities"), _("Utilities to work with disks, diagnostics, and the LiveCD Environment"), "")); k = dfui_form_action_add(f, "exit", dfui_info_new(_("Exit to Live CD"), _("Exit this program to a login prompt with access to the LiveCD"), "")); dfui_form_action_add(f, "reboot", dfui_info_new(_("Reboot this Computer"), _("Reboot this computer (e.g. to boot into a newly installed system)"), "")); dfui_form_action_add(f, "configure_netboot", dfui_info_new(_("Setup NetBoot Install Services"), _("Setup machine as remote installation server"), "")); if (!dfui_be_present(a->c, f, &r)) abort_backend(); if (strcmp(dfui_response_get_action_id(r), "install") == 0) { state = state_begin_install; } else if (strcmp(dfui_response_get_action_id(r), "upgrade") == 0) { state = state_begin_upgrade; } else if (strcmp(dfui_response_get_action_id(r), "configure") == 0) { storage_set_selected_disk(a->s, NULL); storage_set_selected_slice(a->s, NULL); state = state_configure_menu; } else if (strcmp(dfui_response_get_action_id(r), "utilities") == 0) { state = state_utilities_menu; } else if (strcmp(dfui_response_get_action_id(r), "exit") == 0) { state = NULL; } else if (strcmp(dfui_response_get_action_id(r), "configure_netboot") == 0) { state = state_setup_remote_installation_server; } else if (strcmp(dfui_response_get_action_id(r), "reboot") == 0) { state = state_reboot; } dfui_form_free(f); dfui_response_free(r); }
/* * If ss->selected_disk == NULL, user will be asked for which disk. * Returns 1 if disk was formatted, 0 if it wasn't. * If it was, ss->selected_disk and ss->selected_slice are set to it. */ void fn_format_disk(struct i_fn_args *a) { struct commands *cmds; char *selected_disk_string; if (storage_get_selected_disk(a->s) == NULL) { a->short_desc = _("Select a disk to format."); a->cancel_desc = _("Return to Utilities Menu"); fn_select_disk(a); if (!a->result || storage_get_selected_disk(a->s) == NULL) { a->result = 0; return; } } if (confirm_dangerous_action(a->c, _("WARNING! ALL data in ALL partitions on the disk\n\n" "%s\n\nwill be IRREVOCABLY ERASED!\n\nAre you ABSOLUTELY " "SURE you wish to take this action? This is your " "LAST CHANCE to cancel!"), disk_get_desc(storage_get_selected_disk(a->s)))) { cmds = commands_new(); command_add(cmds, "%s%s -BI %s", a->os_root, cmd_name(a, "FDISK"), disk_get_device_name(storage_get_selected_disk(a->s))); if (!commands_execute(a, cmds)) { inform(a->c, _("The disk\n\n%s\n\nwas " "not correctly formatted, and may " "now be in an inconsistent state. " "We recommend re-formatting it " "before attempting to install " "%s on it."), disk_get_desc(storage_get_selected_disk(a->s)), OPERATING_SYSTEM_NAME); commands_free(cmds); a->result = 0; return; } commands_free(cmds); /* * Since one of the disks has now changed, we must * refresh our view of them and re-select the disk * since the selected_disk pointer will be invalidated. */ selected_disk_string = aura_strdup( disk_get_device_name(storage_get_selected_disk(a->s))); if (!survey_storage(a)) { inform(a->c, _("Errors occurred while probing " "the system for its storage capabilities.")); } storage_set_selected_disk(a->s, disk_find(a->s, selected_disk_string)); free(selected_disk_string); /* * Note that we formatted this disk and that we want * to use the first (and only) slice of it. */ disk_set_formatted(storage_get_selected_disk(a->s), 1); storage_set_selected_slice(a->s, disk_slice_first(storage_get_selected_disk(a->s))); if (!format_slice(a)) { inform(a->c, _("The sole primary partition of " "the disk\n\n%s\n\nwas " "not correctly formatted, and may " "now be in an inconsistent state. " "We recommend re-formatting the " "disk before attempting to install " "%s on it."), disk_get_desc(storage_get_selected_disk(a->s)), OPERATING_SYSTEM_NAME); a->result = 0; return; } inform(a->c, _("The disk\n\n%s\n\nwas formatted."), disk_get_desc(storage_get_selected_disk(a->s))); a->result = 1; } else { inform(a->c, _("Action cancelled - no disks were formatted.")); a->result = 0; } }