summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-handler.c
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-09-02 04:02:52 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-02 03:28:42 -0700
commitfabe6417986dedd92adc2ac5d8d71cfd4dd918da (patch)
tree4c515d2c449fc6f5535033ac18047f0c66d7ff49 /xlators/mgmt/glusterd/src/glusterd-handler.c
parentea86a09143c5c59349ca82ddcbc2178a84cccde7 (diff)
mgmt/glusterd: support for GET_NEXT volume info
Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1255 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1255
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-handler.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c45
1 files changed, 39 insertions, 6 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 1c0d1ee6fb6..c55de40b101 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -2832,6 +2832,7 @@ glusterd_get_volumes (rpcsvc_request_t *req, dict_t *dict, int32_t flags)
int32_t count = 0;
dict_t *volumes = NULL;
gf1_cli_get_vol_rsp rsp = {0,};
+ char *volname = NULL;
priv = THIS->private;
GF_ASSERT (priv);
@@ -2848,21 +2849,53 @@ glusterd_get_volumes (rpcsvc_request_t *req, dict_t *dict, int32_t flags)
}
if (flags == GF_CLI_GET_VOLUME_ALL) {
- list_for_each_entry (entry, &priv->volumes, vol_list) {
- count++;
- ret = glusterd_add_volume_detail_to_dict (entry,
- volumes, count);
- if (ret)
- goto out;
+ list_for_each_entry (entry, &priv->volumes, vol_list) {
+ count++;
+ ret = glusterd_add_volume_detail_to_dict (entry,
+ volumes, count);
+ if (ret)
+ goto out;
+
+ }
+
+ ret = dict_set_int32 (volumes, "count", count);
+
+ if (ret)
+ goto out;
+ } else if (flags == GF_CLI_GET_NEXT_VOLUME) {
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ if (priv->volumes.next) {
+ entry = list_entry (priv->volumes.next,
+ typeof (*entry),
+ vol_list);
}
+ } else {
+ ret = glusterd_volinfo_find (volname, &entry);
+ if (ret)
+ goto out;
+ entry = list_entry (entry->vol_list.next, typeof (*entry),
+ vol_list);
+ }
+ if (&entry->vol_list == &priv->volumes) {
ret = dict_set_int32 (volumes, "count", count);
+ } else {
+ count++;
+ ret = glusterd_add_volume_detail_to_dict (entry,
+ volumes, count);
+ if (ret)
+ goto out;
+ ret = dict_set_int32 (volumes, "count", count);
if (ret)
goto out;
+
+ }
}
+
ret = dict_allocate_and_serialize (volumes, &rsp.volumes.volumes_val,
(size_t *)&rsp.volumes.volumes_len);