From 767f03b161ae44bd9d33dae7e03e71e73852813f Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Fri, 29 Dec 2017 22:16:30 -0500 Subject: [PATCH] LU-10444 utils: Don't remount debugfs every time Check if debugfs is mounted at /sys/kernel/debug and only mount if it is not. Change-Id: Ib31bd8f7c5c93ab942c6708ed3a4d17a11159e95 Signed-off-by: Oleg Drokin Reviewed-on: https://review.whamcloud.com/30675 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Bob Glossman Reviewed-by: James Simmons --- libcfs/libcfs/util/param.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libcfs/libcfs/util/param.c b/libcfs/libcfs/util/param.c index 74a3726..9facce6 100644 --- a/libcfs/libcfs/util/param.c +++ b/libcfs/libcfs/util/param.c @@ -38,6 +38,8 @@ #include #include #include +#include +#include /** * Get parameter path matching the pattern @@ -67,13 +69,19 @@ cfs_get_param_paths(glob_t *paths, const char *pattern, ...) static bool test_mounted = false; size_t len = strlen(path); char buf[PATH_MAX]; + struct statfs statfsbuf; va_list args; int rc; + if (test_mounted) goto skip_mounting; test_mounted = true; + rc = statfs("/sys/kernel/debug/", &statfsbuf); + if (rc == 0 && statfsbuf.f_type == DEBUGFS_MAGIC) + goto skip_mounting; + if (mount("none", "/sys/kernel/debug", "debugfs", 0, "") == -1) { /* Already mounted or don't have permission to mount is okay */ if (errno != EPERM && errno != EBUSY) -- 1.8.3.1