diff options
| author | Jeff Darcy <jdarcy@redhat.com> | 2014-03-04 16:53:33 +0000 | 
|---|---|---|
| committer | Anand Avati <avati@redhat.com> | 2014-03-05 21:29:42 -0800 | 
| commit | 1fbffa0aa45560889e29a74c4c6ff16d526de700 (patch) | |
| tree | e723a7d539ba40812bdb98149ef2435d2ead175e /api/src/glfs.c | |
| parent | d6c1468b2779b6247e44b75276436021a3469a59 (diff) | |
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 <jdarcy@redhat.com>
Reviewed-on: http://review.gluster.org/7183
Reviewed-by: Anand Avati <avati@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'api/src/glfs.c')
| -rw-r--r-- | api/src/glfs.c | 20 | 
1 files changed, 20 insertions, 0 deletions
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; +}  | 
