All of lore.kernel.org
 help / color / mirror / Atom feed
From: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [i-g-t PATCH 3/4] lib/igt_debugfs: Add helper to return path to device.
Date: Thu, 20 Apr 2017 11:13:47 +0300	[thread overview]
Message-ID: <1492676028-15372-3-git-send-email-abdiel.janulgue@linux.intel.com> (raw)
In-Reply-To: <1492676028-15372-1-git-send-email-abdiel.janulgue@linux.intel.com>

Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
---
 lib/igt_debugfs.c | 26 ++++++++++++++++++++++++++
 lib/igt_debugfs.h |  1 +
 2 files changed, 27 insertions(+)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 7584be5..b019c3b 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -22,6 +22,9 @@
  *
  */
 
+#ifndef ANDROID
+#define _GNU_SOURCE
+#endif
 #include <inttypes.h>
 #include <sys/stat.h>
 #include <sys/mount.h>
@@ -198,6 +201,29 @@ int igt_debugfs_dir(int device)
 	igt_debug("Opening debugfs directory '%s'\n", path);
 	return open(path, O_RDONLY);
 }
+\
+/**
+ * igt_debugfs_path:
+ * @device: fd of the device
+ *
+ * Returns:
+ * The path to the debugfs directory corresponding to device
+ */
+const char *igt_debugfs_path(int device)
+{
+	char *path = 0;
+
+	if (!path) {
+		char *linkname;
+		int debugfs;
+		igt_assert((debugfs = igt_debugfs_dir(device)) != -1);
+		igt_assert(path = calloc(PATH_MAX, sizeof(char)));
+		igt_assert(asprintf(&linkname, "/proc/self/fd/%d", debugfs) != -1);
+		igt_assert(readlink(linkname, path, PATH_MAX * sizeof(char)) != -1);
+	}
+
+	return path;
+}
 
 /**
  * igt_debugfs_open:
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index 7b846a8..76cf409 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -204,5 +204,6 @@ void igt_enable_prefault(void);
  */
 int igt_get_stable_obj_count(int driver);
 void igt_debugfs_dump(int device, const char *filename);
+const char *igt_debugfs_path(int device);
 
 #endif /* __IGT_DEBUGFS_H__ */
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-04-20  8:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-20  8:13 [i-g-t PATCH 1/4] lib/igt_core: Add igt_exec helpers Abdiel Janulgue
2017-04-20  8:13 ` [i-g-t PATCH 2/4] igt/igt_core: Provide an option to check for the log buffer contents Abdiel Janulgue
2017-04-20  8:13 ` Abdiel Janulgue [this message]
2017-05-09 10:21   ` [i-g-t PATCH 3/4] lib/igt_debugfs: Add helper to return path to device Petri Latvala
2017-04-20  8:13 ` [i-g-t PATCH 4/4] Convert shell script tests to C version Abdiel Janulgue
2017-04-25  9:54   ` [i-g-t PATCH] Convert ddx_intel_after_fbdev to C Abdiel Janulgue
2017-05-09 10:55   ` [i-g-t PATCH 4/4] Convert shell script tests to C version Petri Latvala
2017-05-09 10:18 ` [i-g-t PATCH 1/4] lib/igt_core: Add igt_exec helpers Petri Latvala
2017-05-10 12:10   ` Abdiel Janulgue
2017-05-10 12:14     ` Petri Latvala
2017-05-10 12:30       ` Abdiel Janulgue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1492676028-15372-3-git-send-email-abdiel.janulgue@linux.intel.com \
    --to=abdiel.janulgue@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.