summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-volgen.c
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kp@gluster.com>2011-05-03 05:04:57 +0000
committerAnand Avati <avati@gluster.com>2011-05-04 05:00:11 -0700
commite3571d4aab9b727715f0e51d12e6e0596f0111ce (patch)
tree2c9871da15306ad8c4fdb028cbf4ff37daa3976d /xlators/mgmt/glusterd/src/glusterd-volgen.c
parentf5708f4d0696529faf1fb0ad108123a76c816d78 (diff)
glusterd: Checked brick path length in 'staging'.
Added checks for brick path length in 'staging' of add/replace brick and create_volume subcommands. Signed-off-by: Krishnan Parthasarathi <kp@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2847 (volume creation fails if brick path is long) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2847
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-volgen.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index f7f3ddd11a5..4c7d066f42a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -36,6 +36,7 @@
#include "cli1.h"
#include "glusterd-volgen.h"
#include "glusterd-op-sm.h"
+#include "glusterd-utils.h"
/* dispatch table for VOLUME SET
@@ -1867,6 +1868,39 @@ get_brick_filepath (char *filename, glusterd_volinfo_t *volinfo,
brick);
}
+gf_boolean_t
+glusterd_is_valid_volfpath (char *volname, char *brick)
+{
+ char volfpath[PATH_MAX] = {0,};
+ glusterd_brickinfo_t *brickinfo = NULL;
+ glusterd_volinfo_t *volinfo = NULL;
+ int32_t ret = 0;
+
+ ret = glusterd_brickinfo_from_brick (brick, &brickinfo);
+ if (ret) {
+ gf_log ("", GF_LOG_WARNING, "brick path validation failed");
+ ret = 0;
+ goto out;
+ }
+ ret = glusterd_volinfo_new (&volinfo);
+ if (ret) {
+ gf_log ("", GF_LOG_WARNING, "brick path validation failed");
+ ret = 0;
+ goto out;
+ }
+ strncpy (volinfo->volname, volname, sizeof (volinfo->volname));
+ get_brick_filepath (volfpath, volinfo, brickinfo);
+
+ ret = (strlen (volfpath) < _POSIX_PATH_MAX);
+
+out:
+ if (brickinfo)
+ glusterd_brickinfo_delete (brickinfo);
+ if (volinfo)
+ glusterd_volinfo_delete (volinfo);
+ return ret;
+}
+
static int
glusterd_generate_brick_volfile (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *brickinfo)