diff options
author | Kaushal M <kaushal@redhat.com> | 2012-05-08 13:57:31 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-05-08 17:00:21 -0700 |
commit | fc481386d296921d883d1b8678795eb45bb8b8b7 (patch) | |
tree | bff14a5af50a8bd75aeab58f270b7717d44094b4 /glusterfsd | |
parent | 27fb213be6101bca859502ac87dddc4cd0a6f272 (diff) |
glusterfsd: Make sure mountpoint is an absolute path
If the mountpoint path given to glusterfs is not an absolute path, convert it to
an absolute path by concatenating it with the curren working directory.
This prevents cases, where in gluster cannot perform clean unmounts when mount
is done with a relative path.
Change-Id: Ie25add4e1dc59171e522c4244c79a6c148844ab3
BUG: 819466
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.com/3302
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'glusterfsd')
-rw-r--r-- | glusterfsd/src/glusterfsd.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 4ad47ec621a..8fbbb2f8d40 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -206,6 +206,8 @@ create_fuse_mount (glusterfs_ctx_t *ctx) int ret = 0; cmd_args_t *cmd_args = NULL; xlator_t *master = NULL; + char *mount_point = NULL; + char cwd[PATH_MAX] = {0,}; cmd_args = &ctx->cmd_args; @@ -242,8 +244,28 @@ create_fuse_mount (glusterfs_ctx_t *ctx) if (!master->options) goto err; - ret = dict_set_static_ptr (master->options, ZR_MOUNTPOINT_OPT, - cmd_args->mount_point); + /* Check if mount-point is absolute path, + * if not convert to absolute path by concating with CWD + */ + if (cmd_args->mount_point[0] != '/') { + if (getcwd (cwd, PATH_MAX) != NULL) { + ret = gf_asprintf (&mount_point, "%s/%s", cwd, + cmd_args->mount_point); + if (ret == -1) { + gf_log ("glusterfsd", GF_LOG_ERROR, + "Could not create absolute mountpoint " + "path"); + goto err; + } + } else { + gf_log ("glusterfsd", GF_LOG_ERROR, + "Could not get current working directory"); + goto err; + } + } else + mount_point = gf_strdup (cmd_args->mount_point); + + ret = dict_set_dynstr (master->options, ZR_MOUNTPOINT_OPT, mount_point); if (ret < 0) { gf_log ("glusterfsd", GF_LOG_ERROR, "failed to set mount-point to options dictionary"); |