diff options
author | Krutika Dhananjay <kdhananj@redhat.com> | 2013-09-04 16:07:08 +0530 |
---|---|---|
committer | Krutika Dhananjay <kdhananj@redhat.com> | 2013-09-06 14:57:09 +0530 |
commit | 08c555680d4aa0ec800ce617fdb119e83f9cd1f8 (patch) | |
tree | 9affb88545f8d95bef2ec29cea082b5f103c1f92 /cli/src/cli-cmd-volume.c | |
parent | aa1da9c3207b9b1a1d91d09e5faf92510e7b61d7 (diff) |
glusterd: add quota conf to probe payload
also fix FILE* leak in cli
Original-author: Krishnan Parthasarathi <kparthas@redhat.com>
Change-Id: Icb9b58ef065ce1a150d98b4c26bbcddeeb390e44
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-volume.c')
-rw-r--r-- | cli/src/cli-cmd-volume.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 7dc26144..17663091 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1096,6 +1096,20 @@ print_quota_list_header (void) } int +cli_get_soft_limit (call_frame_t *frame, cli_local_t *local, dict_t *options, + const char **words) +{ + rpc_clnt_procedure_t *proc = NULL; + int ret = -1; + + CLI_LOCAL_INIT (local, words, frame, options); + proc = &cli_rpc_prog->proctable[GLUSTER_CLI_QUOTA]; + ret = proc->fn (frame, THIS, options); + + return ret; +} + +int cli_cmd_quota_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { @@ -1112,6 +1126,7 @@ cli_cmd_quota_cbk (struct cli_state *state, struct cli_cmd_word *word, char *volname = NULL; dict_t *xdata = NULL; char buf[256] = {0}; + FILE *fp = NULL; const char *question = "Disabling quota will delete all the quota " "configuration. Do you want to continue?"; @@ -1152,6 +1167,12 @@ cli_cmd_quota_cbk (struct cli_state *state, struct cli_cmd_word *word, goto out; } if (type == GF_QUOTA_OPTION_TYPE_LIST && wordcount == 4) { + ret = cli_get_soft_limit (frame, local, options, words); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Failed to fetch default " + "soft-limit"); + goto out; + } proc = &cli_quotad_clnt.proctable[GF_AGGREGATOR_GETLIMIT]; xdata = dict_new (); if (!xdata) { @@ -1166,7 +1187,6 @@ cli_cmd_quota_cbk (struct cli_state *state, struct cli_cmd_word *word, //TODO: fix hardcoding sprintf (quota_conf_file, "/var/lib/glusterd/vols/%s/quota.conf", volname); - FILE *fp = NULL; fp = fopen (quota_conf_file, "r"); if (!fp) { gf_log ("cli", GF_LOG_ERROR, "Failed to open quota.conf"); @@ -1197,6 +1217,8 @@ cli_cmd_quota_cbk (struct cli_state *state, struct cli_cmd_word *word, ret = proc->fn (frame, THIS, options); out: + if (fp) + fclose (fp); if (ret) { cli_cmd_sent_status_get (&sent); if (sent == 0 && parse_err == 0) |