From 1fbffa0aa45560889e29a74c4c6ff16d526de700 Mon Sep 17 00:00:00 2001 From: Jeff Darcy Date: Tue, 4 Mar 2014 16:53:33 +0000 Subject: api: add glfs_get_volfile From the API-header description: > Sometimes it's useful e.g. for scripts to see the volfile, so that > they can parse it and find subvolumes to do things like split-brain > resolution or custom layouts. The API here was specifically intended > to make access e.g. from Python as simple as possible. > > Note that the volume must be started (not necessarily mounted) for > this to work. Change-Id: If3f55ee9611cdf4b77aa53659f0af0d21957817d Signed-off-by: Jeff Darcy Reviewed-on: http://review.gluster.org/7183 Reviewed-by: Anand Avati Tested-by: Gluster Build System --- api/src/glfs.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'api/src/glfs.c') diff --git a/api/src/glfs.c b/api/src/glfs.c index ea10fb55c65..9e9a55ccb65 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -680,3 +680,23 @@ glfs_fini (struct glfs *fs) return ret; } + +ssize_t +glfs_get_volfile (struct glfs *fs, void *buf, size_t len) +{ + ssize_t res; + + glfs_lock(fs); + if (len >= fs->oldvollen) { + gf_log ("glfs", GF_LOG_TRACE, "copying %lu to %p", len, buf); + memcpy(buf,fs->oldvolfile,len); + res = len; + } + else { + res = len - fs->oldvollen; + gf_log ("glfs", GF_LOG_TRACE, "buffer is %ld too short", -res); + } + glfs_unlock(fs); + + return res; +} -- cgit