diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-09-16 11:43:30 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-09-16 11:46:58 +0100 |
commit | 5cbb714fbf3669f23a8238ada8b45b584961566b (patch) | |
tree | 3feafff42c14b4420392bad755035f3ff6fae40d /lib | |
parent | c79f47310e835ee031c1e8e50db1697c45113347 (diff) |
lib: Export igt_debugfs_mount()
Not everything we want from debugfs is under debugfs/dri. But we do want
to share the code to find the debugfs mount point (and mount it if is
not found).
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/igt_debugfs.c | 17 | ||||
-rw-r--r-- | lib/igt_debugfs.h | 2 |
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index afb83617..cd70ea1d 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -87,7 +87,17 @@ typedef struct { char dri_path[128]; } igt_debugfs_t; -static const char *__debugfs_mount(void) + +/** + * igt_debugfs_mount: + * + * This attempts to locate where debugfs is mounted on the filesystem, + * and if not found, will then try to mount debugfs at /sys/kernel/debug. + * + * Returns: + * The path to the debugfs mount point (e.g. /sys/kernel/debug) + */ +const char *igt_debugfs_mount(void) { struct stat st; @@ -107,7 +117,7 @@ static bool __igt_debugfs_init(igt_debugfs_t *debugfs) struct stat st; int n; - strcpy(debugfs->root, __debugfs_mount()); + strcpy(debugfs->root, igt_debugfs_mount()); for (n = 0; n < 16; n++) { int len = sprintf(debugfs->dri_path, "%s/dri/%d", debugfs->root, n); sprintf(debugfs->dri_path + len, "/i915_error_state"); @@ -800,7 +810,8 @@ int igt_debugfs_dir(int device) if (fstat(device, &st) || !S_ISCHR(st.st_mode)) return -1; - sprintf(path, "%s/dri/%d", __debugfs_mount(), (int)(st.st_rdev & 0xff)); + sprintf(path, "%s/dri/%d", + igt_debugfs_mount(), (int)(st.st_rdev & 0xff)); igt_debug("Opening debugfs dir %s\n", path); return open(path, O_RDONLY); } diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h index 1a757b84..988025f9 100644 --- a/lib/igt_debugfs.h +++ b/lib/igt_debugfs.h @@ -31,6 +31,8 @@ enum pipe; +const char *igt_debugfs_mount(void); + int igt_debugfs_open(const char *filename, int mode); FILE *igt_debugfs_fopen(const char *filename, const char *mode); |