summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/bugs/glusterd/bug-1318591-skip-non-directories-inside-vols.t31
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c18
2 files changed, 49 insertions, 0 deletions
diff --git a/tests/bugs/glusterd/bug-1318591-skip-non-directories-inside-vols.t b/tests/bugs/glusterd/bug-1318591-skip-non-directories-inside-vols.t
new file mode 100644
index 00000000000..c776b489957
--- /dev/null
+++ b/tests/bugs/glusterd/bug-1318591-skip-non-directories-inside-vols.t
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+. $(dirname $0)/../../env.rc
+. $(dirname $0)/../../snapshot.rc
+
+cleanup;
+
+TEST verify_lvm_version
+TEST glusterd
+TEST pidof glusterd
+
+TEST setup_lvm 1
+
+TEST $CLI volume create $V0 $H0:$L1
+TEST $CLI volume start $V0
+
+TEST $CLI volume status $V0;
+
+TEST touch $GLUSTERD_WORKDIR/vols/file
+
+TEST $CLI snapshot create snap1 $V0 no-timestamp
+
+TEST touch $GLUSTERD_WORKDIR/snaps/snap1/file
+
+TEST killall_gluster
+
+TEST glusterd
+
+cleanup;
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 8b903ba1e48..8cf3b5d38eb 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -3112,6 +3112,8 @@ glusterd_store_retrieve_volumes (xlator_t *this, glusterd_snap_t *snap)
DIR *dir = NULL;
struct dirent *entry = NULL;
glusterd_volinfo_t *volinfo = NULL;
+ struct stat st = {0,};
+ char entry_path[PATH_MAX] = {0,};
GF_ASSERT (this);
priv = this->private;
@@ -3140,6 +3142,22 @@ glusterd_store_retrieve_volumes (xlator_t *this, glusterd_snap_t *snap)
(!strcmp (entry->d_name, "info"))))
goto next;
+ snprintf (entry_path, PATH_MAX, "%s/%s", path, entry->d_name);
+ ret = sys_lstat (entry_path, &st);
+ if (ret == -1) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_INVALID_ENTRY,
+ "Failed to stat entry %s : %s", path,
+ strerror (errno));
+ goto next;
+ }
+
+ if (!S_ISDIR (st.st_mode)) {
+ gf_msg_debug (this->name, 0, "%s is not a vaild volume"
+ , entry->d_name);
+ goto next;
+ }
+
volinfo = glusterd_store_retrieve_volume (entry->d_name, snap);
if (!volinfo) {
gf_msg (this->name, GF_LOG_ERROR, 0,