Whamcloud - gitweb
LU-10444 utils: Don't remount debugfs every time 75/30675/3
authorOleg Drokin <oleg.drokin@intel.com>
Sat, 30 Dec 2017 03:16:30 +0000 (22:16 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 14 Jan 2018 02:36:50 +0000 (02:36 +0000)
Check if debugfs is mounted at /sys/kernel/debug and only
mount if it is not.

Change-Id: Ib31bd8f7c5c93ab942c6708ed3a4d17a11159e95
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
Reviewed-on: https://review.whamcloud.com/30675
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
libcfs/libcfs/util/param.c

index 74a3726..9facce6 100644 (file)
@@ -38,6 +38,8 @@
 #include <unistd.h>
 #include <linux/limits.h>
 #include <libcfs/util/string.h>
+#include <sys/vfs.h>
+#include <linux/magic.h>
 
 /**
  * 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)