/* * state_format_disk: ask the user if they wish to format the disk they * selected. */ void state_format_disk(struct i_fn_args *a) { switch (dfui_be_present_dialog(a->c, _("How Much Disk?"), _("Use Entire Disk|Use Part of Disk|Return to Select Disk"), _("Select how much of this disk you want to use for %s.\n\n%s"), OPERATING_SYSTEM_NAME, disk_get_desc(storage_get_selected_disk(a->s)))) { case 1: /* Entire Disk */ if (measure_activated_swap_from_disk(a, storage_get_selected_disk(a->s)) > 0) { if (swapoff_all(a) == NULL) { inform(a->c, _("Warning: swap could not be turned off.")); state = state_select_disk; return; } } fn_format_disk(a); if (a->result) state = state_ask_fs; else state = state_format_disk; break; case 2: /* Part of Disk */ state = state_select_slice; break; case 3: /* Return */ state = state_select_disk; break; default: abort_backend(); break; } }
/* * state_install_bootstrap: put boot0 bootblocks on selected disks. */ void state_install_bootstrap(struct i_fn_args *a) { char msg_buf[1][1024]; snprintf(msg_buf[0], sizeof(msg_buf[0]), _("You may now wish to install bootblocks on one or more disks. " "If you already have a boot manager installed, you can skip " "this step (but you may have to configure your boot manager " "separately.) If you installed %s on a disk other " "than your first disk, you will need to put the bootblock " "on at least your first disk and the %s disk."), OPERATING_SYSTEM_NAME, OPERATING_SYSTEM_NAME); a->short_desc = msg_buf[0]; a->cancel_desc = _("Skip this Step"); fn_install_bootblocks(a, disk_get_device_name(storage_get_selected_disk(a->s))); state = state_finish_install; }
/* * Wipes the start of the selected slice. */ void fn_wipe_start_of_slice(struct i_fn_args *a) { struct commands *cmds; a->short_desc = _("If you are having problems formatting a primary partition, " "it may be because of junk that has accumulated in the " "partition's `disklabel'. A cure for this is to wipe out " "everything on the first few sectors of the primary partition. " "However, this is a rather drastic action to take, so it is not " "recommended unless you are otherwise encountering problems."); a->cancel_desc = _("Return to Utilities Menu"); fn_select_slice(a); if (!a->result) return; if (confirm_dangerous_action(a->c, _("WARNING! ALL data in primary partition #%d,\n\n%s\n\non the " "disk\n\n%s\n\n will be IRREVOCABLY ERASED!\n\nAre you " "ABSOLUTELY SURE you wish to take this action? This is " "your LAST CHANCE to cancel!"), slice_get_number(storage_get_selected_slice(a->s)), slice_get_desc(storage_get_selected_slice(a->s)), disk_get_desc(storage_get_selected_disk(a->s)))) { /* XXX check to make sure this slice is not mounted first */ cmds = commands_new(); command_add(cmds, "%s%s if=/dev/zero of=/dev/%s bs=32k count=16", a->os_root, cmd_name(a, "DD"), slice_get_device_name(storage_get_selected_slice(a->s))); if (commands_execute(a, cmds)) { inform(a->c, _("Start of primary partition was successfully wiped.")); } else { inform(a->c, _("Some errors occurred. " "Start of primary partition was not successfully wiped.")); } commands_free(cmds); } }
void state_configure_menu(struct i_fn_args *a) { struct dfui_form *f = NULL; struct dfui_response *r = NULL; struct commands *cmds; int done = 0; char msg_buf[2][1024]; if (storage_get_selected_disk(a->s) == NULL || storage_get_selected_slice(a->s) == NULL) { if (!survey_storage(a)) { inform(a->c, _("Errors occurred while probing " "the system for its storage capabilities.")); } a->short_desc = _("Select the disk containing the installation."); a->cancel_desc = _("Return to Welcome Menu"); fn_select_disk(a); if (!a->result || storage_get_selected_disk(a->s) == NULL) { state = state_welcome; return; } a->short_desc = _("Select the primary partition containing the installation."); a->cancel_desc = _("Return to Welcome Menu"); fn_select_slice(a); if (!a->result || storage_get_selected_slice(a->s) == NULL) { state = state_welcome; return; } } a->cfg_root = "mnt"; if (during_install == 0) { switch (dfui_be_present_dialog(a->c, _("Select file system"), _("HAMMER|UFS|Return to Welcome Menu"), _("Please select the file system installed on the disk.\n\n"))) { case 1: /* HAMMER */ use_hammer = 1; break; case 2: /* UFS */ use_hammer = 0; break; case 3: state = state_welcome; return; /* NOTREACHED */ break; default: abort_backend(); break; } } if (!mount_target_system(a)) { inform(a->c, _("Target system could not be mounted.")); state = state_welcome; return; } snprintf(msg_buf[0], sizeof(msg_buf[0]), _("The options on this menu allow you to configure a " "%s system after it has already been " "installed."), OPERATING_SYSTEM_NAME); while (!done) { f = dfui_form_create( "configure_menu", _("Configure an Installed System"), msg_buf[0], "", "p", "role", "menu", "a", "set_timezone", _("Select timezone"), _("Set the Time Zone of your physical location"), "", "a", "set_datetime", _("Set date and time"), _("Set the Time and Date of your machine"), "", "a", "set_kbdmap", _("Set keyboard map"), _("Set what kind of keyboard layout you have"), "", "a", "root_passwd", _("Set root password"), _("Set the password that the root (superuser) account will use"), "", "a", "add_user", _("Add a user"), _("Add a user to the system"), "", "a", "assign_ip", _("Configure network interfaces"), _("Set up network interfaces (NICs, ethernet, TCP/IP, etc)"), "", "a", "assign_hostname_domain", _("Configure hostname and domain"), _("Configure the hostname and domain for this system"), "", /* "a", "select_services", "Select Services", "Enable/Disable system services (servers, daemons, etc.)", "", */ "a", "set_vidfont", _("Set console font"), _("Set how the characters on your video console look"), "", "a", "set_scrnmap", _("Set screen map"), _("Set how characters are translated before console display"), "", /* "a", "install_pkgs", _("Install extra software packages"), _("Install third-party software packages from the LiveCD"), "", */ "a", "remove_pkgs", _("Remove software packages"), _("Remove third-party software packages from the installed system"), "", "a", "cancel", _("Return to Welcome Menu"), "", "", "p", "accelerator", "ESC", NULL ); if (!dfui_be_present(a->c, f, &r)) abort_backend(); /* XXX set up a */ a->cfg_root = "mnt/"; if (strcmp(dfui_response_get_action_id(r), "root_passwd") == 0) { fn_root_passwd(a); } else if (strcmp(dfui_response_get_action_id(r), "add_user") == 0) { fn_add_user(a); } else if (strcmp(dfui_response_get_action_id(r), "install_pkgs") == 0) { fn_install_packages(a); } else if (strcmp(dfui_response_get_action_id(r), "remove_pkgs") == 0) { fn_remove_packages(a); } else if (strcmp(dfui_response_get_action_id(r), "assign_ip") == 0) { fn_assign_ip(a); } else if (strcmp(dfui_response_get_action_id(r), "assign_hostname_domain") == 0) { fn_assign_hostname_domain(a); } else if (strcmp(dfui_response_get_action_id(r), "select_services") == 0) { fn_select_services(a); } else if (strcmp(dfui_response_get_action_id(r), "set_kbdmap") == 0) { fn_set_kbdmap(a); } else if (strcmp(dfui_response_get_action_id(r), "set_vidfont") == 0) { fn_set_vidfont(a); } else if (strcmp(dfui_response_get_action_id(r), "set_scrnmap") == 0) { fn_set_scrnmap(a); } else if (strcmp(dfui_response_get_action_id(r), "set_timezone") == 0) { fn_set_timezone(a); } else if (strcmp(dfui_response_get_action_id(r), "set_datetime") == 0) { fn_assign_datetime(a); } else if (strcmp(dfui_response_get_action_id(r), "cancel") == 0) { state = state_welcome; done = 1; } dfui_form_free(f); dfui_response_free(r); } /* * Before unmounting the system, write out any changes to rc.conf. */ config_vars_write(rc_conf, CONFIG_TYPE_SH, "%s%setc/rc.conf", a->os_root, a->cfg_root); /* * Clear out configuration variable table in memory. */ config_vars_free(rc_conf); rc_conf = config_vars_new(); /* * Finally, unmount the system we mounted on /mnt and remove mappings. */ cmds = commands_new(); unmount_all_under(a, cmds, "%smnt", a->os_root); commands_execute(a, cmds); commands_free(cmds); if (remove_all_mappings(a) == NULL) inform(a->c, _("Warning: mappings could not be removed.")); }
/* * state_select_slice: ask the user which slice they wish to install * DragonFly on. In order to avoid confusing them, refer to it as * a primary partition, but tell them what BSD has traditionally called * it, too. */ void state_select_slice(struct i_fn_args *a) { char msg_buf[1][1024]; snprintf(msg_buf[0], sizeof(msg_buf[0]), _("Select the existing primary partition (also " "known as a `slice' in the BSD tradition) on " "which to install %s.\n\n" "Note that if you do not have any existing " "primary partitions on this disk, you must " "first create some. This installer does not " "currently have the ability to do this, so " "you will have to exit and run fdisk (in " "DOS or *BSD) or parted (in Linux) to do so."), OPERATING_SYSTEM_NAME); a->short_desc = msg_buf[0]; a->cancel_desc = _("Return to Select Disk"); fn_select_slice(a); if (!a->result || storage_get_selected_slice(a->s) == NULL) { state = state_select_disk; } else { if (measure_activated_swap_from_slice(a, storage_get_selected_disk(a->s), storage_get_selected_slice(a->s)) > 0) { if (swapoff_all(a) == NULL) { inform(a->c, _("Warning: swap could not be turned off.")); state = state_select_slice; return; } } if (slice_get_capacity(storage_get_selected_slice(a->s)) < DISK_MIN) { inform(a->c, _("WARNING: you should have a primary " "partition at least %dM in size, or " "you may encounter problems trying to " "install %s."), DISK_MIN, OPERATING_SYSTEM_NAME); } if (confirm_dangerous_action(a->c, _("WARNING! ALL data in primary partition #%d,\n\n%s\n\non the " "disk\n\n%s\n\n will be IRREVOCABLY ERASED!\n\nAre you " "ABSOLUTELY SURE you wish to take this action? This is " "your LAST CHANCE to cancel!"), slice_get_number(storage_get_selected_slice(a->s)), slice_get_desc(storage_get_selected_slice(a->s)), disk_get_desc(storage_get_selected_disk(a->s)))) { if (!format_slice(a)) { inform(a->c, _("Primary partition #%d was " "not correctly formatted, and may " "now be in an inconsistent state. " "We recommend re-formatting it " "before proceeding."), slice_get_number(storage_get_selected_slice(a->s))); } else { inform(a->c, _("Primary partition #%d was formatted."), slice_get_number(storage_get_selected_slice(a->s))); state = state_ask_fs; } } else { inform(a->c, _("Action cancelled - no primary partitions were formatted.")); state = state_select_slice; } } }
int format_slice(struct i_fn_args *a) { struct commands *cmds; struct command *cmd; int result; int cyl, hd, sec; cmds = commands_new(); /* * The information in a->s NEEDS to be accurate here! * Presumably we just did a survey_storage() recently. * XXX should we do another one here anyway just to be paranoid? */ /* * Set the slice's sysid to 165. */ disk_get_geometry(storage_get_selected_disk(a->s), &cyl, &hd, &sec); command_add(cmds, "%s%s 'g c%d h%d s%d' >%snew.fdisk", a->os_root, cmd_name(a, "ECHO"), cyl, hd, sec, a->tmp); command_add(cmds, "%s%s 'p %d %d %lu %lu' >>%snew.fdisk", a->os_root, cmd_name(a, "ECHO"), slice_get_number(storage_get_selected_slice(a->s)), 165, slice_get_start(storage_get_selected_slice(a->s)), slice_get_size(storage_get_selected_slice(a->s)), a->tmp); if (slice_get_flags(storage_get_selected_slice(a->s)) & 0x80) { command_add(cmds, "%s%s 'a %d' >>%snew.fdisk", a->os_root, cmd_name(a, "ECHO"), slice_get_number(storage_get_selected_slice(a->s)), a->tmp); } command_add(cmds, "%s%s %snew.fdisk", a->os_root, cmd_name(a, "CAT"), a->tmp); temp_file_add(a, "new.fdisk"); /* * Execute the fdisk script. */ cmd = command_add(cmds, "%s%s -v -f %snew.fdisk %s", a->os_root, cmd_name(a, "FDISK"), a->tmp, disk_get_device_name(storage_get_selected_disk(a->s))); if (slice_get_size(storage_get_selected_slice(a->s)) == 0xFFFFFFFFU) command_set_failure_mode(cmd, COMMAND_FAILURE_IGNORE); /* * If there is an old 'virgin' disklabel hanging around * in the temp dir, get rid of it. This won't happen * from a real CD, but might happen with '-o' installs. */ command_add(cmds, "%s%s -f %sinstall.disklabel.%s", a->os_root, cmd_name(a, "RM"), a->tmp, slice_get_device_name(storage_get_selected_slice(a->s))); result = commands_execute(a, cmds); commands_free(cmds); return(result); }
/* * 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; } }
static struct dfui_form * make_create_subpartitions_form(struct i_fn_args *a) { struct dfui_form *f; char msg_buf[1][1024]; snprintf(msg_buf[0], sizeof(msg_buf[0]), _("Subpartitions further divide a primary partition for " "use with %s. Some reasons you may want " "a set of subpartitions are:\n\n" "- you want to restrict how much data can be written " "to certain parts of the primary partition, to quell " "denial-of-service attacks; and\n" "- you want to speed up access to data on the disk." ""), OPERATING_SYSTEM_NAME); f = dfui_form_create( "create_subpartitions", _("Create Subpartitions"), _("Set up the subpartitions (also known as just `partitions' " "in BSD tradition) you want to have on this primary " "partition. In most cases you should be fine with " "the default settings.\n\n" "For Capacity, use 'M' to indicate megabytes, 'G' to " "indicate gigabytes, and so on (up to 'E'.) A single '*' " "indicates 'use the remaining space on the primary partition'."), msg_buf[0], "p", "special", "dfinstaller_create_subpartitions", "p", "minimum_width","64", "f", "mountpoint", _("Mountpoint"), "", "", "f", "capacity", _("Capacity"), "", "", "f", "encrypted", _("Encrypted"), "", "", "p", "control", "checkbox", "a", "ok", _("Accept and Create"), "", "", "a", "cancel", (disk_get_formatted(storage_get_selected_disk(a->s)) ? _("Return to Select Disk") : _("Return to Select Primary Partition")), "", "", "p", "accelerator", "ESC", NULL ); dfui_form_set_multiple(f, 1); dfui_form_set_extensible(f, 1); /* * Remove ATM until HAMMER installer support is better * dfui_form_set_extensible(f, 1); */ #if 0 if (expert) { fi = dfui_form_field_add(f, "softupdates", dfui_info_new(_("Softupdates"), "", "")); dfui_field_property_set(fi, "control", "checkbox"); fi = dfui_form_field_add(f, "tmpfsbacked", dfui_info_new(_("TMPFS"), "", "")); dfui_field_property_set(fi, "control", "checkbox"); fi = dfui_form_field_add(f, "fsize", dfui_info_new(_("Frag Sz"), "", "")); fi = dfui_form_field_add(f, "bsize", dfui_info_new(_("Block Sz"), "", "")); dfui_form_action_add(f, "switch", dfui_info_new(_("Switch to Normal Mode"), "", "")); } else { dfui_form_action_add(f, "switch", dfui_info_new(_("Switch to Expert Mode"), "", "")); } #endif return(f); }