diff options
author | Harshavardhana <harsha@harshavardhana.net> | 2014-06-24 15:00:59 -0700 |
---|---|---|
committer | Harshavardhana <harsha@harshavardhana.net> | 2014-06-28 11:56:59 -0700 |
commit | 39209965366f9bbc1d485532496fc265874c7527 (patch) | |
tree | 1f39b79632a344db38a0ef4ea127ae2d85bf6d9c /xlators/mgmt/glusterd/src/glusterd-snapshot.c | |
parent | fc1ae37ea4c353286f9a6f3d3e95041feee6ac7d (diff) |
glusterd/snapshot: verify for lvm commands
On non-Linux platforms we need to verify the
run time availability of LVM specific commands
and fail accordingly with a message.
Change-Id: Ie1e3870648f01ee129e390e2240c66e0c6249b90
BUG: 1061685
Signed-off-by: Harshavardhana <harsha@harshavardhana.net>
Reviewed-on: http://review.gluster.org/8165
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Sachin Pandit <spandit@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-snapshot.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot.c | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index f2fb2ba5552..3edbd827dcb 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -3665,7 +3665,7 @@ glusterd_take_lvm_snapshot (glusterd_brickinfo_t *brickinfo, } while (ptr != NULL); runner_end (&runner); - /* Takng the actual snapshot */ + /* Taking the actual snapshot */ runinit (&runner); snprintf (msg, sizeof (msg), "taking snapshot of the brick %s", origin_brick_path); @@ -7104,6 +7104,44 @@ out: return ret; } +/* + Verify availability of lvm commands +*/ + +static gf_boolean_t +glusterd_is_lvm_cmd_available (char *lvm_cmd) +{ + int32_t ret = 0; + struct stat buf = {0,}; + + if (!lvm_cmd) + return _gf_false; + + ret = stat (lvm_cmd, &buf); + if (ret != 0) { + gf_log (THIS->name, GF_LOG_ERROR, + "stat fails on %s, exiting. (errno = %d (%s))", + lvm_cmd, errno, strerror(errno)); + return _gf_false; + } + + if ((!ret) && (!S_ISREG(buf.st_mode))) { + gf_log (THIS->name, GF_LOG_CRITICAL, + "Provided command %s is not a regular file," + "exiting", lvm_cmd); + return _gf_false; + } + + if ((!ret) && (!(buf.st_mode & S_IXUSR))) { + gf_log (THIS->name, GF_LOG_CRITICAL, + "Provided command %s has no exec permissions," + "exiting", lvm_cmd); + return _gf_false; + } + + return _gf_true; +} + int glusterd_handle_snapshot_fn (rpcsvc_request_t *req) { @@ -7176,6 +7214,14 @@ glusterd_handle_snapshot_fn (rpcsvc_request_t *req) goto out; } + if (!glusterd_is_lvm_cmd_available (LVM_CREATE)) { + snprintf (err_str, sizeof (err_str), "LVM commands not found," + " snapshot functionality is disabled"); + gf_log (this->name, GF_LOG_ERROR, "%s", err_str); + ret = -1; + goto out; + } + switch (type) { case GF_SNAP_OPTION_TYPE_CREATE: ret = glusterd_handle_snapshot_create (req, cli_op, dict, |