diff options
author | Pranith Kumar K <pranithk@gluster.com> | 2010-09-07 05:29:36 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-07 07:46:06 -0700 |
commit | 968fe7420a600fb9f83edd21576ab1b180d65d1c (patch) | |
tree | c61723287e7d623c4c91c4b396eaba668c548110 /xlators | |
parent | 4f64c970ed1e334ba17413178eaf355f454c201f (diff) |
mgmt/glusterd: create store handle in store create brick
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1372 ()
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1372
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index b18693eb2..4c45912c1 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -87,10 +87,10 @@ glusterd_store_create_brick (glusterd_volinfo_t *volinfo, char path[PATH_MAX] = {0,}; char brickpath[PATH_MAX] = {0,}; struct stat stbuf = {0,}; - int fd = -1; char buf[4096] = {0,}; char *tmppath = NULL; char *ptr = NULL; + glusterd_store_handle_t *shandle = NULL; GF_ASSERT (volinfo); GF_ASSERT (brickinfo); @@ -122,10 +122,15 @@ glusterd_store_create_brick (glusterd_volinfo_t *volinfo, path, brickinfo->hostname, tmppath); GF_FREE (tmppath); + ret = glusterd_store_handle_new (brickpath, &brickinfo->shandle); - fd = open (brickpath, O_RDWR | O_CREAT | O_APPEND, 0666); + if (ret) + goto out; - if (fd < 0) { + shandle = brickinfo->shandle; + shandle->fd = open (brickpath, O_RDWR | O_CREAT | O_APPEND, 0666); + + if (shandle->fd < 0) { gf_log ("", GF_LOG_ERROR, "Open failed on %s", brickpath); ret = -1; @@ -134,15 +139,15 @@ glusterd_store_create_brick (glusterd_volinfo_t *volinfo, snprintf (buf, sizeof(buf), "hostname=%s\n", brickinfo->hostname); - ret = write (fd, buf, strlen(buf)); + ret = write (shandle->fd, buf, strlen(buf)); snprintf (buf, sizeof(buf), "path=%s\n", brickinfo->path); - ret = write (fd, buf, strlen(buf)); + ret = write (shandle->fd, buf, strlen(buf)); ret = 0; out: - if (fd > 0) { - close (fd); + if (shandle->fd > 0) { + close (shandle->fd); } gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); return ret; |