From 489a7a10fe2e00d00d86f0304145a4910bb94070 Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Wed, 1 Feb 2012 14:44:07 +0530 Subject: cli: Fix for statedump crashing gluster processes 1. Fixes the bug in statedump causing the gluster process to crash when an unknown option was given in the 'glusterdump.*.options' file. 2. Also fixes cli, making it send full statedump option strings even when only partial option strings are given in 'volume statedump' command. 3. Minor change to order of operations during statedump to allow option parsing errors to be written to the dump file. Change-Id: Ic878cbca4dbf46b83fba0fd88fcb3c03f05ae46d BUG: 772586 Signed-off-by: Kaushal M Reviewed-on: http://review.gluster.com/2706 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- cli/src/cli-cmd-parser.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index b169b77c6..090a72469 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -1976,18 +1976,19 @@ cli_cmd_volume_status_parse (const char **words, int wordcount, } gf_boolean_t -cli_cmd_validate_dumpoption (const char *option) +cli_cmd_validate_dumpoption (const char *arg, char **option) { char *opwords[] = {"all", "nfs", "mem", "iobuf", "callpool", "priv", - "fd", "inode", NULL}; + "fd", "inode", NULL}; char *w = NULL; - w = str_getunamb (option, opwords); + w = str_getunamb (arg, opwords); if (!w) { gf_log ("cli", GF_LOG_DEBUG, "Unknown statedump option %s", - option); + arg); return _gf_false; } + *option = w; return _gf_true; } @@ -1999,14 +2000,15 @@ cli_cmd_volume_statedump_options_parse (const char **words, int wordcount, int i = 0; dict_t *dict = NULL; int option_cnt = 0; + char *option = NULL; char option_str[100] = {0,}; for (i = 3; i < wordcount; i++, option_cnt++) { - if (!cli_cmd_validate_dumpoption (words[i])) { + if (!cli_cmd_validate_dumpoption (words[i], &option)) { ret = -1; goto out; } - strncat (option_str, words[i], sizeof (words [i])); + strncat (option_str, option, strlen (option)); strncat (option_str, " ", 1); } @@ -2014,7 +2016,7 @@ cli_cmd_volume_statedump_options_parse (const char **words, int wordcount, if (!dict) goto out; - ret = dict_set_str (dict, "options", gf_strdup (option_str)); + ret = dict_set_dynstr (dict, "options", gf_strdup (option_str)); if (ret) goto out; -- cgit