static void save_subpartition_selections(struct dfui_response *r, struct i_fn_args *a) { struct dfui_dataset *ds; const char *mountpoint, *capstring; long capacity; int valid = 1; subpartitions_free(storage_get_selected_slice(a->s)); for (ds = dfui_response_dataset_get_first(r); valid && ds != NULL; ds = dfui_dataset_get_next(ds)) { mountpoint = dfui_dataset_get_value(ds, "mountpoint"); capstring = dfui_dataset_get_value(ds, "capacity"); if (string_to_capacity(capstring, &capacity)) { subpartition_new_hammer(storage_get_selected_slice(a->s), mountpoint, capacity, strcasecmp(dfui_dataset_get_value(ds, "encrypted"), "Y") == 0); } } }
void fn_memtest(struct i_fn_args *a) { struct dfui_form *f; struct dfui_response *r; struct dfui_dataset *ds, *new_ds; struct commands *cmds; struct command *cmd; const char *memtestsize; f = dfui_form_create( "memtest", _("Memory test"), _("Memory test - Enter the size in values such as 400M, 1G."), "", "f", "memtestsize", _("Memory test size"), _("Enter the amount of memory you would like to check:"), "", "a", "ok", _("OK"), "", "", "a", "cancel", _("Cancel Memory Test"), "", "", "p", "accelerator", "ESC", NULL ); ds = dfui_dataset_new(); dfui_dataset_celldata_add(ds, "memtestsize", ""); dfui_form_dataset_add(f, ds); if (!dfui_be_present(a->c, f, &r)) abort_backend(); if (strcmp(dfui_response_get_action_id(r), "ok") == 0) { new_ds = dfui_response_dataset_get_first(r); memtestsize = dfui_dataset_get_value(new_ds, "memtestsize"); cmds = commands_new(); cmd = command_add(cmds, "cd %s && %s%s %s 1 --log", a->tmp, a->os_root, cmd_name(a, "MEMTEST"), memtestsize); command_set_log_mode(cmd, COMMAND_LOG_QUIET); cmd = command_add(cmds, "%s%s -E -v '^Unable to malloc' %smemtest.log > %smemtest.log.new", a->os_root, cmd_name(a, "GREP"), a->tmp, a->tmp); cmd = command_add(cmds, "%s%s %smemtest.log.new %smemtest.log", a->os_root, cmd_name(a, "MV"), a->tmp, a->tmp); cmd = command_add(cmds, "%s%s -E -v '^Allocated.*failed' %smemtest.log > %smemtest.log.new", a->os_root, cmd_name(a, "GREP"), a->tmp, a->tmp); cmd = command_add(cmds, "%s%s %smemtest.log.new %smemtest.log", a->os_root, cmd_name(a, "MV"), a->tmp, a->tmp); if (commands_execute(a, cmds)) { commands_free(cmds); view_memtest_log(a); cmds = commands_new(); cmd = command_add(cmds, "%s%s -f %smemtest.log", a->os_root, cmd_name(a, "RM"), a->tmp); commands_execute(a, cmds); } else { inform(a->c, _("Memory test could not be run.")); } commands_free(cmds); } dfui_form_free(f); dfui_response_free(r); }
void fn_install_bootblocks(struct i_fn_args *a, const char *device) { struct dfui_form *f; struct dfui_response *r; struct dfui_dataset *ds; struct disk *d; struct commands *cmds; struct command *cmd; char disk[64], boot0cfg[32], packet[32]; char msg_buf[1][1024]; snprintf(msg_buf[0], sizeof(msg_buf[0]), "'Packet Mode' refers to using newer BIOS calls to boot " "from a partition of the disk. It is generally not " "required unless:\n\n" "- your BIOS does not support legacy mode; or\n" "- your %s primary partition resides on a " "cylinder of the disk beyond cylinder 1024; or\n" "- you just can't get it to boot without it.", OPERATING_SYSTEM_NAME); f = dfui_form_create( "install_bootstrap", _("Install Bootblock(s)"), a->short_desc, msg_buf[0], "p", "special", "dfinstaller_install_bootstrap", "f", "disk", _("Disk Drive"), _("The disk on which you wish to install a bootblock"), "", "p", "editable", "false", "f", "boot0cfg", _("Install Bootblock?"), _("Install a bootblock on this disk"), "", "p", "control", "checkbox", "f", "packet", _("Packet Mode?"), _("Select this to use 'packet mode' to boot the disk"), "", "p", "control", "checkbox", "a", "ok", _("Accept and Install Bootblocks"), "", "", "a", "cancel", a->cancel_desc, "", "", "p", "accelerator", "ESC", NULL ); dfui_form_set_multiple(f, 1); if (device != NULL) { ds = dfui_dataset_new(); dfui_dataset_celldata_add(ds, "disk", device); dfui_dataset_celldata_add(ds, "boot0cfg", "Y"); dfui_dataset_celldata_add(ds, "packet", "Y"); dfui_form_dataset_add(f, ds); } else { for (d = storage_disk_first(a->s); d != NULL; d = disk_next(d)) { ds = dfui_dataset_new(); dfui_dataset_celldata_add(ds, "disk", disk_get_device_name(d)); dfui_dataset_celldata_add(ds, "boot0cfg", "Y"); dfui_dataset_celldata_add(ds, "packet", "Y"); dfui_form_dataset_add(f, ds); } } if (!dfui_be_present(a->c, f, &r)) abort_backend(); a->result = 0; if (strcmp(dfui_response_get_action_id(r), "ok") == 0) { cmds = commands_new(); for (ds = dfui_response_dataset_get_first(r); ds != NULL; ds = dfui_dataset_get_next(ds)) { strlcpy(disk, dfui_dataset_get_value(ds, "disk"), 64); strlcpy(boot0cfg, dfui_dataset_get_value(ds, "boot0cfg"), 32); strlcpy(packet, dfui_dataset_get_value(ds, "packet"), 32); if (strcasecmp(boot0cfg, "Y") == 0) { cmd = command_add(cmds, "%s%s -B -o %spacket %s", a->os_root, cmd_name(a, "BOOT0CFG"), strcasecmp(packet, "Y") == 0 ? "" : "no", disk); command_set_failure_mode(cmd, COMMAND_FAILURE_WARN); command_set_tag(cmd, "%s", disk); cmd = command_add(cmds, "%s%s -v %s", a->os_root, cmd_name(a, "BOOT0CFG"), disk); command_set_failure_mode(cmd, COMMAND_FAILURE_WARN); command_set_tag(cmd, "%s", disk); } } if (!commands_execute(a, cmds)) { ask_to_wipe_boot_sector(a, cmds); } else { inform(a->c, _("Bootblocks were successfully installed!")); a->result = 1; } commands_free(cmds); } dfui_form_free(f); dfui_response_free(r); }
static int check_subpartition_selections(struct dfui_response *r, struct i_fn_args *a) { struct dfui_dataset *ds; struct dfui_dataset *star_ds = NULL; struct aura_dict *d; const char *mountpoint, *capstring; long capacity = 0; int found_root = 0; int valid = 1; d = aura_dict_new(1, AURA_DICT_LIST); if ((ds = dfui_response_dataset_get_first(r)) == NULL) { inform(a->c, _("Please set up at least one subpartition.")); valid = 0; } for (ds = dfui_response_dataset_get_first(r); valid && ds != NULL; ds = dfui_dataset_get_next(ds)) { #ifdef DEBUG dfui_dataset_dump(ds); #endif mountpoint = dfui_dataset_get_value(ds, "mountpoint"); capstring = dfui_dataset_get_value(ds, "capacity"); if (aura_dict_exists(d, mountpoint, strlen(mountpoint) + 1)) { inform(a->c, _("The same mount point cannot be specified " "for two different subpartitions.")); valid = 0; } if (strcmp(mountpoint, "/") == 0) found_root = 1; if (strcmp(capstring, "*") == 0) { if (star_ds != NULL) { inform(a->c, _("You cannot have more than one subpartition " "with a '*' capacity (meaning 'use the remainder " "of the primary partition'.)")); valid = 0; } else { star_ds = ds; } } if (!(!strcasecmp(mountpoint, "swap") || mountpoint[0] == '/')) { inform(a->c, _("Mount point must be either 'swap', or it must " "start with a '/'.")); valid = 0; } if (strpbrk(mountpoint, " \\\"'`") != NULL) { inform(a->c, _("Mount point may not contain the following " "characters: blank space, backslash, or " "single, double, or back quotes.")); valid = 0; } if (strlen(capstring) == 0) { inform(a->c, _("A capacity must be specified.")); valid = 0; } if (!string_to_capacity(capstring, &capacity)) { inform(a->c, _("Capacity must be either a '*' symbol " "to indicate 'use the rest of the primary " "partition', or it must be a series of decimal " "digits ending with an 'M' (indicating " "megabytes), a 'G' (indicating gigabytes) and " "so on (up to 'E'.)")); valid = 0; } /* * Maybe remove this limit entirely? */ if ((strcasecmp(mountpoint, "swap") == 0) && (capacity > SWAP_MAX)) { inform(a->c, _("Swap capacity is limited to %dG."), SWAP_MAX / 1024); valid = 0; } /* * If we made it through that obstacle course, all is well. */ if (valid) aura_dict_store(d, mountpoint, strlen(mountpoint) + 1, "", 1); } if (!found_root) { inform(a->c, _("You must include a / (root) subpartition.")); valid = 0; } if (aura_dict_size(d) > 16) { inform(a->c, _("You cannot have more than 16 subpartitions " "on a single primary partition. Remove some " "and try again.")); valid = 0; } aura_dict_free(d); return(valid); }