diff options
author | Amar Tumballi <amar@gluster.com> | 2010-08-21 01:50:31 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-08-21 05:17:27 -0700 |
commit | daf868e13511d97492ca4ece5fe60a2a4f69a20f (patch) | |
tree | d0a222781b0fd99e2d713fdc8b7dcdc8c2f8631b /xlators/mgmt/glusterd/src/glusterd-handshake.c | |
parent | c429e47ae3925d0bc1ca113e37d903410f3e043a (diff) |
portmapper program added to glusterfsd mgmt rpc
* some bug fixes glusterd-pmap.c
* also renamed 'fetch-spec.c' -> 'glusterfsd-mgmt.c'
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 1314 (portmapper functionality)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1314
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-handshake.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handshake.c | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c index 9f5e03f5306..43a93731790 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handshake.c +++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c @@ -42,13 +42,44 @@ static size_t build_volfile_path (const char *volname, char *path, size_t path_len) { - int32_t ret = -1; - glusterd_conf_t *priv = NULL; + struct stat stbuf = {0,}; + int32_t ret = -1; + glusterd_conf_t *priv = NULL; + char *vol = NULL; + char *dup_volname = NULL; + char *tmp = NULL; + glusterd_volinfo_t *volinfo = NULL; priv = THIS->private; + dup_volname = gf_strdup (volname); + + ret = glusterd_volinfo_find (dup_volname, &volinfo); + if (ret) { + /* Split the volume name */ + vol = strtok_r (dup_volname, "-", &tmp); + if (!vol) + goto out; + vol = strtok_r (NULL, "-", &tmp); + if (!vol) + goto out; + ret = glusterd_volinfo_find (vol, &volinfo); + if (ret) + goto out; + } + ret = snprintf (path, path_len, "%s/vols/%s/%s.vol", + priv->workdir, volinfo->volname, volname); + if (ret == -1) + goto out; + + ret = stat (path, &stbuf); + if ((ret == -1) && (errno == ENOENT)) + ret = snprintf (path, path_len, "%s/vols/%s/%s-tcp.vol", + priv->workdir, volinfo->volname, volname); - ret = snprintf (path, path_len, "%s/vols/%s/%s-tcp.vol", - priv->workdir, volname, volname); + ret = 1; +out: + if (dup_volname) + GF_FREE (dup_volname); return ret; } @@ -139,6 +170,8 @@ fail: if (cookie) rsp.op_errno = cookie; + if (!rsp.spec) + rsp.spec = ""; glusterd_submit_reply (req, &rsp, NULL, 0, NULL, (gd_serialize_t)xdr_serialize_getspec_rsp); |