diff options
Diffstat (limited to 'lib/igt_debugfs.c')
-rw-r--r-- | lib/igt_debugfs.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index 4a119985..09d42ea0 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -110,6 +110,20 @@ static bool is_mountpoint(const char *path) return dev != st.st_dev; } +static const char *__igt_debugfs_mount(void) +{ + if (is_mountpoint("/sys/kernel/debug")) + return "/sys/kernel/debug"; + + if (is_mountpoint("/debug")) + return "/debug"; + + if (mount("debug", "/sys/kernel/debug", "debugfs", 0, 0)) + return NULL; + + return "/sys/kernel/debug"; +} + /** * igt_debugfs_mount: * @@ -121,16 +135,12 @@ static bool is_mountpoint(const char *path) */ const char *igt_debugfs_mount(void) { - if (is_mountpoint("/sys/kernel/debug")) - return "/sys/kernel/debug"; + static const char *path; - if (is_mountpoint("/debug")) - return "/debug"; + if (!path) + path = __igt_debugfs_mount(); - if (mount("debug", "/sys/kernel/debug", "debugfs", 0, 0)) - return NULL; - - return "/sys/kernel/debug"; + return path; } /** |