From acb691f8908049e651fc12ff1cf01e9cf4ddde65 Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Sat, 24 Dec 2011 13:49:52 +0530 Subject: cli, glusterd : Added support for clear-locks command. Change-Id: I8e7cd51d6e3dd968cced1ec4115b6811f2ab5c1b BUG: 789858 Signed-off-by: Krishnan Parthasarathi Reviewed-on: http://review.gluster.com/2552 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- cli/src/cli-cmd-parser.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'cli/src/cli-cmd-parser.c') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 090a72469..b4c86bf1a 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -2032,3 +2032,67 @@ out: gf_log ("cli", GF_LOG_ERROR, "Error parsing dumpoptions"); return ret; } + +int +cli_cmd_volume_clrlks_opts_parse (const char **words, int wordcount, + dict_t **options) +{ + int ret = -1; + int i = 0; + dict_t *dict = NULL; + char *kind_opts[4] = {"blocked", "granted", "all", NULL}; + char *types[4] = {"inode", "entry", "posix", NULL}; + char *free_ptr = NULL; + + dict = dict_new (); + if (!dict) + goto out; + + if (strcmp (words[4], "kind")) + goto out; + + for (i = 0; kind_opts[i]; i++) { + if (!strcmp (words[5], kind_opts[i])) { + free_ptr = gf_strdup (words[5]); + ret = dict_set_dynstr (dict, "kind", free_ptr); + if (ret) + goto out; + free_ptr = NULL; + break; + } + } + if (i == 3) + goto out; + + ret = -1; + for (i = 0; types[i]; i++) { + if (!strcmp (words[6], types[i])) { + free_ptr = gf_strdup (words[6]); + ret = dict_set_dynstr (dict, "type", free_ptr); + if (ret) + goto out; + free_ptr = NULL; + break; + } + } + if (i == 3) + goto out; + + if (wordcount == 8) { + free_ptr = gf_strdup (words[7]); + ret = dict_set_dynstr (dict, "opts", free_ptr); + if (ret) + goto out; + free_ptr = NULL; + } + + ret = 0; + *options = dict; +out: + if (ret) { + GF_FREE (free_ptr); + dict_unref (dict); + } + + return ret; +} -- cgit