From 71622b82d95a3d2a4d0db9be1ec57939bebc9cdc Mon Sep 17 00:00:00 2001 From: shishir gowda Date: Fri, 27 Aug 2010 07:22:24 +0000 Subject: volume create should not succeed on invalid export Signed-off-by: shishir gowda Signed-off-by: Vijay Bellur --- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 11fca774a9f..c7eb7d15ad2 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -262,6 +262,15 @@ glusterd_op_stage_create_volume (gd1_mgmt_stage_op_req *req) dict_t *dict = NULL; char *volname = NULL; gf_boolean_t exists = _gf_false; + char *bricks = NULL; + char *brick_list = NULL; + glusterd_brickinfo_t *brick_info = NULL; + int32_t brick_count = 0; + int32_t i = 0; + struct stat st_buf = {0,}; + char *brick = NULL; + char *tmpptr = NULL; + char cmd_str[1024]; GF_ASSERT (req); @@ -292,7 +301,38 @@ glusterd_op_stage_create_volume (gd1_mgmt_stage_op_req *req) } else { ret = 0; } + ret = dict_get_int32 (dict, "count", &brick_count); + if (ret) { + gf_log ("", GF_LOG_ERROR, "Unable to get count"); + goto out; + } + ret = dict_get_str (dict, "bricks", &bricks); + if (ret) { + gf_log ("", GF_LOG_ERROR, "Unable to get bricks"); + goto out; + } + + if (bricks) + brick_list = gf_strdup (bricks); + + while ( i < brick_count) { + i++; + brick= strtok_r (brick_list, " \n", &tmpptr); + brick_list = tmpptr; + ret = glusterd_brickinfo_from_brick (brick, &brick_info); + if (ret) + goto out; + snprintf (cmd_str, 1024, "%s", brick_info->path); + ret = stat (cmd_str, &st_buf); + if (ret == -1) { + gf_log ("glusterd", GF_LOG_ERROR, "Volname %s, brick" + ":%s path %s not present", volname, + brick, brick_info->path); + goto out; + } + brick_list = tmpptr; + } out: gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); -- cgit