summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-handler.c
diff options
context:
space:
mode:
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);