From: Andreas Dilger Date: Mon, 29 Apr 2013 21:46:56 +0000 (-0600) Subject: LU-3243 utils: print value in lctl set_param error X-Git-Tag: 2.4.51~52 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=614665d3201b4de385e3fab6d7d99e1468fde0d4 LU-3243 utils: print value in lctl set_param error 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 Change-Id: Iebd0ae70dc9dbd378775339ccba2ab90a97d1093 Reviewed-on: http://review.whamcloud.com/6205 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Emoly Liu Reviewed-by: John Hammond Reviewed-by: Prakash Surya Reviewed-by: Oleg Drokin --- diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index 51793f1..9988dab 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -955,34 +955,34 @@ static int setparam_display(struct param_opts *popt, char *pattern, char *value) 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)