Whamcloud - gitweb
LU-3243 utils: print value in lctl set_param error
authorAndreas Dilger <andreas.dilger@intel.com>
Mon, 29 Apr 2013 21:46:56 +0000 (15:46 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 6 Jun 2013 01:47:32 +0000 (21:47 -0400)
Print out the invalid value that was trying to be set via
"lctl set_param parameter=value", so that it is more clear
what is going wrong when this is being called from a script.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: Iebd0ae70dc9dbd378775339ccba2ab90a97d1093
Reviewed-on: http://review.whamcloud.com/6205
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Emoly Liu <emoly.liu@intel.com>
Reviewed-by: John Hammond <johnlockwoodhammond@gmail.com>
Reviewed-by: Prakash Surya <surya1@llnl.gov>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/lustre_cfg.c

index 51793f1..9988dab 100644 (file)
@@ -955,34 +955,34 @@ static int setparam_display(struct param_opts *popt, char *pattern, char *value)
                         pattern, globerrstr(rc));
                 return -ESRCH;
         }
                         pattern, globerrstr(rc));
                 return -ESRCH;
         }
-        for (i = 0; i  < glob_info.gl_pathc; i++) {
-                char *valuename = NULL;
-
-                if (popt->show_path) {
-                        strcpy(filename, glob_info.gl_pathv[i]);
-                        valuename = display_name(filename, 0);
-                        if (valuename)
-                                printf("%s=%s\n", valuename, value);
-                }
-                /* Write the new value to the file */
-                fd = open(glob_info.gl_pathv[i], O_WRONLY);
-                if (fd > 0) {
-                        rc = write(fd, value, strlen(value));
-                        if (rc < 0)
-                                fprintf(stderr, "error: set_param: "
-                                        "writing to file %s: %s\n",
-                                        glob_info.gl_pathv[i], strerror(errno));
-                        else
-                                rc = 0;
-                        close(fd);
-                } else {
-                        fprintf(stderr, "error: set_param: %s opening %s\n",
-                                strerror(rc = errno), glob_info.gl_pathv[i]);
-                }
-        }
+       for (i = 0; i  < glob_info.gl_pathc; i++) {
+               char *valuename = NULL;
+
+               if (popt->show_path) {
+                       strcpy(filename, glob_info.gl_pathv[i]);
+                       valuename = display_name(filename, 0);
+                       if (valuename)
+                               printf("%s=%s\n", valuename, value);
+               }
+               /* Write the new value to the file */
+               fd = open(glob_info.gl_pathv[i], O_WRONLY);
+               if (fd > 0) {
+                       rc = write(fd, value, strlen(value));
+                       if (rc < 0)
+                               fprintf(stderr, "error: set_param: setting "
+                                       "%s=%s: %s\n", glob_info.gl_pathv[i],
+                                       value, strerror(errno));
+                       else
+                               rc = 0;
+                       close(fd);
+               } else {
+                       fprintf(stderr, "error: set_param: %s opening %s\n",
+                               strerror(rc = errno), glob_info.gl_pathv[i]);
+               }
+       }
 
 
-        globfree(&glob_info);
-        return rc;
+       globfree(&glob_info);
+       return rc;
 }
 
 int jt_lcfg_setparam(int argc, char **argv)
 }
 
 int jt_lcfg_setparam(int argc, char **argv)