Example #1
0
static int init_obj_path(const char *base_path, char *argp)
{
	char *p;
	int len, ret;
	struct sd_md_info mdi;

	if (check_path_len(base_path) < 0)
		return -1;

#define OBJ_PATH "/obj"
	len = strlen(base_path) + strlen(OBJ_PATH) + 1;
	obj_path = xzalloc(len);
	snprintf(obj_path, len, "%s" OBJ_PATH, base_path);

	/* Eat up the first component */
	strtok(argp, ",");
	p = strtok(NULL, ",");
	if (!p) {
		/*
		 * If We have only one path, meta-store and object-store share
		 * it. This is helpful to upgrade old sheep cluster to
		 * the MD-enabled.
		 */
		md_add_disk(obj_path, false);
	} else {
		do {
			if (is_meta_store(p)) {
				sd_err("%s is meta-store, abort", p);
				return -1;
			}
			md_add_disk(p, false);
		} while ((p = strtok(NULL, ",")));
	}

	ret = md_get_info(&mdi);
	if (ret != sizeof(mdi)) {
		sd_err("Can't get md info");
		return -1;
	}

	if (mdi.nr <= 0) {
		sd_err("There isn't any available disk!");
		return -1;
	}

	return xmkdir(obj_path, sd_def_dmode);
}
Example #2
0
void
do_install(void)
{

	msg_display(MSG_installusure);
	process_menu(MENU_noyes, NULL);
	if (!yesno)
		return;

	get_ramsize();

	if (find_disks(msg_string(MSG_install)) < 0)
		return;
	clear();
	refresh();

	if (check_swap(diskdev, 0) > 0) {
		msg_display(MSG_swapactive);
		process_menu(MENU_ok, NULL);
		if (check_swap(diskdev, 1) < 0) {
			msg_display(MSG_swapdelfailed);
			process_menu(MENU_ok, NULL);
			if (!debug)
				return;
		}
	}

	process_menu(MENU_distset, NULL);

	if (!md_get_info()) {
		msg_display(MSG_abort);
		process_menu(MENU_ok, NULL);
		return;
	}

	if (md_make_bsd_partitions() == 0) {
		msg_display(MSG_abort);
		process_menu(MENU_ok, NULL);
		return;
	}

	/* Last chance ... do you really want to do this? */
	clear();
	refresh();
	msg_display(MSG_lastchance, diskdev);
	process_menu(MENU_noyes, NULL);
	if (!yesno)
		return;

	if (md_pre_disklabel() != 0)
		return;

	if (write_disklabel() != 0)
		return;

	if (md_post_disklabel() != 0)
		return;

	if (make_filesystems())
		return;

	if (make_fstab() != 0)
		return;

	if (md_post_newfs() != 0)
		return;

	/* Unpack the distribution. */
	if (get_and_unpack_sets(0, MSG_disksetupdone,
	    MSG_extractcomplete, MSG_abortinst) != 0)
		return;

	if (md_post_extract() != 0)
		return;

	do_configmenu();

	sanity_check();

	md_cleanup_install();

	msg_display(MSG_instcomplete);
	process_menu(MENU_ok, NULL);
}