Whamcloud - gitweb
LU-1415 utils: Process all {get,set}_param arguments
authorAndreas Dilger <adilger@whamcloud.com>
Fri, 29 Jun 2012 09:04:27 +0000 (03:04 -0600)
committerOleg Drokin <green@whamcloud.com>
Wed, 11 Jul 2012 23:59:53 +0000 (19:59 -0400)
Process all arguments to get_param and set_param before returning an
error, to allow accessing one of multiple parameters that have changed
during code reorganization.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Li Wei <liwei@whamcloud.com>
Change-Id: Icb3019c8bd6ed83ffbfeae1fa54084f34df00c1e
Reviewed-on: http://review.whamcloud.com/3245
Tested-by: Hudson
Reviewed-by: Yu Jian <yujian@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
lustre/utils/lustre_cfg.c

index 93adfb3..b409656 100644 (file)
@@ -900,22 +900,24 @@ int jt_lcfg_getparam(int argc, char **argv)
         if (rc < 0 || rc >= argc)
                 return CMD_HELP;
 
         if (rc < 0 || rc >= argc)
                 return CMD_HELP;
 
-        for (i = rc; i < argc; i++) {
-                path = argv[i];
+       for (i = rc, rc = 0; i < argc; i++) {
+               int rc2;
 
 
-                clean_path(path);
+               path = argv[i];
 
 
-                lprocfs_param_pattern(argv[0], path, pattern, sizeof(pattern));
+               clean_path(path);
 
 
-                if (popt.only_path)
-                        rc = listparam_display(&popt, pattern);
-                else
-                        rc = getparam_display(&popt, pattern);
-                if (rc < 0)
-                        return rc;
-        }
+               lprocfs_param_pattern(argv[0], path, pattern, sizeof(pattern));
 
 
-        return 0;
+               if (popt.only_path)
+                       rc2 = listparam_display(&popt, pattern);
+               else
+                       rc2 = getparam_display(&popt, pattern);
+               if (rc2 < 0 && rc == 0)
+                       rc = rc2;
+       }
+
+       return rc;
 }
 
 static int setparam_cmdline(int argc, char **argv, struct param_opts *popt)
 }
 
 static int setparam_cmdline(int argc, char **argv, struct param_opts *popt)
@@ -994,7 +996,9 @@ int jt_lcfg_setparam(int argc, char **argv)
         if (rc < 0 || rc >= argc)
                 return CMD_HELP;
 
         if (rc < 0 || rc >= argc)
                 return CMD_HELP;
 
-        for (i = rc; i < argc; i++) {
+       for (i = rc, rc = 0; i < argc; i++) {
+               int rc2;
+
                 if ((value = strchr(argv[i], '=')) != NULL) {
                         /* format: set_param a=b */
                         *value = '\0';
                 if ((value = strchr(argv[i], '=')) != NULL) {
                         /* format: set_param a=b */
                         *value = '\0';
@@ -1014,13 +1018,13 @@ int jt_lcfg_setparam(int argc, char **argv)
 
                 lprocfs_param_pattern(argv[0], path, pattern, sizeof(pattern));
 
 
                 lprocfs_param_pattern(argv[0], path, pattern, sizeof(pattern));
 
-                rc = setparam_display(&popt, pattern, value);
+                rc2 = setparam_display(&popt, pattern, value);
                 path = NULL;
                 value = NULL;
                 path = NULL;
                 value = NULL;
-                if (rc < 0)
-                        return rc;
-        }
+               if (rc2 < 0 && rc == 0)
+                       rc = rc2;
+       }
 
 
-        return 0;
+       return rc;
 }
 
 }