From b25e466f2e64d6ffbf3fee3847d1db01f5baddfb Mon Sep 17 00:00:00 2001 From: Sonia Sharma Date: Tue, 16 Apr 2019 04:54:33 -0700 Subject: [PATCH] LU-12191 utils: Make "lctl list_param" read exact path under sysfs tree "lctl list_param -R" currently checks for the param_name in the path and reads the sysfs tree under that. But it can give erroneous results in the following example - For path like /sys/fs/lnet/net/o2ib1/ib0, command "lctl list_param -R" doesnt go down the "net" tree because it matches "net" with "lnet" and just stop there. This patch changes how param_name is checked for in the path. Like in the above example, instead of checkign for "net", it should check for "/net/". So, this patch adds this change in param_display() in lustre/utils/lustre_cfg.c Change-Id: Ieb3ad0d1248eee2192246ff5c4d77a71d87dc446 Signed-off-by: Sonia Sharma Reviewed-on: https://review.whamcloud.com/34693 Reviewed-by: James Simmons Tested-by: Jenkins Reviewed-by: Amir Shehata Tested-by: Maloo --- lustre/utils/lustre_cfg.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index ef7d3d6..223ed51 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -997,7 +997,7 @@ param_display(struct param_opts *popt, char *pattern, char *value, for (i = 0; i < paths.gl_pathc; i++) { char *param_name = NULL, *tmp; - char pathname[PATH_MAX]; + char pathname[PATH_MAX], param_dir[PATH_MAX+2]; struct stat st; int rc2, j; @@ -1093,11 +1093,14 @@ param_display(struct param_opts *popt, char *pattern, char *value, } /* Use param_name to grab subdirectory tree from full path */ - tmp = strstr(paths.gl_pathv[i], param_name); + snprintf(param_dir, sizeof(param_dir), "/%s", param_name); + tmp = strstr(paths.gl_pathv[i], param_dir); + tmp++; /* cleanup paramname now that we are done with it */ free(param_name); param_name = NULL; + memset(¶m_dir,'\0', sizeof(param_dir)); /* Shouldn't happen but just in case */ if (tmp == NULL) { -- 1.8.3.1