From 1538c98f5e33e0794830d5153f17a96ff28c9914 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Mon, 27 Feb 2017 18:45:16 -0800 Subject: libglusterfs: accept random volname in glusterfs_graph_prepare() When the call to glfs_new("volname") passes a name for the volume and it does not match the name of the subvolume in the graph, glfs_init() will fail. This is easily reproducible by a gfapi program that loads the volume from a .vol file, and not from a GlusterD server. Change-Id: I33e77fbee7d12eaefe7c384fad6aecfa3582ea5a BUG: 1425623 Signed-off-by: Niels de Vos Reviewed-on: https://review.gluster.org/16796 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Kaleb KEITHLEY Reviewed-by: Prashanth Pai Reviewed-by: Shyamsundar Ranganathan --- tests/basic/gfapi/gfapi-load-volfile.c | 65 ++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tests/basic/gfapi/gfapi-load-volfile.c (limited to 'tests/basic/gfapi/gfapi-load-volfile.c') diff --git a/tests/basic/gfapi/gfapi-load-volfile.c b/tests/basic/gfapi/gfapi-load-volfile.c new file mode 100644 index 00000000000..91d5677bd44 --- /dev/null +++ b/tests/basic/gfapi/gfapi-load-volfile.c @@ -0,0 +1,65 @@ +/* + * Create a glfs instance based on a .vol file + * + * This is used to measure memory leaks by initializing a graph through a .vol + * file and destroying it again. + */ + +#include +#include +#include + +#include + +#define PROGNAME "gfapi-load-volfile" + +void +usage(FILE *output) +{ + fprintf(output, "Usage: " PROGNAME " \n"); +} + +void +main(int argc, char **argv) +{ + int ret = 0; + glfs_t *fs = NULL; + + if (argc != 2) { + usage(stderr); + exit(EXIT_FAILURE); + } + + if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "-h")) { + usage(stdout); + exit(EXIT_SUCCESS); + } + + fs = glfs_new(PROGNAME); + if (!fs) { + perror("glfs_new failed"); + exit(EXIT_FAILURE); + } + + glfs_set_logging(fs, PROGNAME ".log", 9); + + ret = glfs_set_volfile(fs, argv[1]); + if (ret) { + perror("glfs_set_volfile failed"); + ret = EXIT_FAILURE; + goto out; + } + + ret = glfs_init(fs); + if (ret) { + perror("glfs_init failed"); + ret = EXIT_FAILURE; + goto out; + } + + ret = EXIT_SUCCESS; +out: + glfs_fini(fs); + + exit(ret); +} -- cgit