コード例 #1
0
ファイル: store.c プロジェクト: zplambert/sheepdog
static int init_obj_path(const char *base_path, char *argp)
{
	char *p;
	int len;

	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);
	} else {
		do {
			if (is_meta_store(p)) {
				sd_eprintf("%s is meta-store, abort", p);
				return -1;
			}
			md_add_disk(p);
		} while ((p = strtok(NULL, ",")));
	}
	return xmkdir(obj_path, sd_def_dmode);
}
コード例 #2
0
ファイル: store.c プロジェクト: Taejun/sheepdog
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);
}