Beispiel #1
0
/*
 * 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);
}
Beispiel #2
0
/*
 * state_select_disk: ask the user on which physical disk they wish
 * to install DragonFly.
 */
void
state_select_disk(struct i_fn_args *a)
{
	struct disk *d;
	int num_disks = 0;
	char msg_buf[1][1024];

	for (d = storage_disk_first(a->s); d != NULL; d = disk_next(d))
		num_disks++;

	if (num_disks == 0) {
		inform(a->c, _("The installer could not find any disks suitable "
		    "for installation (IDE or SCSI) attached to this "
		    "computer.  If you wish to install %s"
		    " on an unorthodox storage device, you will have to "
		    "exit to a LiveCD command prompt and install it "
		    "manually, using the file /README as a guide."),
		    OPERATING_SYSTEM_NAME);
		state = state_welcome;
		return;
	}

	snprintf(msg_buf[0], sizeof(msg_buf[0]),
	    _("Select a disk on which to install %s"),
	    OPERATING_SYSTEM_NAME);
	a->short_desc = msg_buf[0];
	a->cancel_desc = _("Return to Begin Installation");
	fn_select_disk(a);
	if (!a->result || storage_get_selected_disk(a->s) == NULL) {
		state = state_begin_install;
	} else {
#if 0
		if (disk_get_capacity(storage_get_selected_disk(a->s)) < DISK_MIN) {
			inform(a->c, _("WARNING: you should have a disk "
			    "at least %dM in size, or "
			    "you may encounter problems trying to "
			    "install %s."), DISK_MIN, OPERATING_SYSTEM_NAME);
		}
#endif
		state = state_format_disk;
	}
}
Beispiel #3
0
static	void	page_out(VMHEAD	HUGE *h)
{
	FNAME(page_out);

	if (!(h->type &	MT_MEMORY))
		error(fun, "not MT_MEMORY");
	if (h->type & MT_FREEZE)
		error(fun, "can't page out frozen memory");
	if (h->type & MT_DIRTY)	 {
		if (h->diskadd == -1L)
			h->diskadd = disk_next((long) h->size, h->mem);
		else  {
			if (-1L	== lseek(DMhandle, h->diskadd, SEEK_SET))
				error(fun, "lseek");
			if (h->size != longwrite(DMhandle, h->mem, (long) h->size))
				error(fun, "write");
		}
	}
	rmfree((RMHEAD_PTR) h->mem, h->size);
	h->type	= MT_DISK;
	VMlive--;
	VMdisk++;
	VM_newadd = 1;
}
Beispiel #4
0
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);
}