public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt RFC 1/3] lib/debugfs: Make is_mountpoint() non-fatal
@ 2017-10-13 12:02 Chris Wilson
  2017-10-13 12:02 ` [igt RFC 2/3] lib: Add hooks for enabling ftrace Chris Wilson
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Chris Wilson @ 2017-10-13 12:02 UTC (permalink / raw)
  To: intel-gfx

is_mountpoint() asserts rather than report the error. Normally this
isn't a problem, except for atypical selftests.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/igt_debugfs.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 60b29e3a..2bdcdee1 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -88,18 +88,26 @@
 static bool is_mountpoint(const char *path)
 {
 	char buf[strlen(path) + 4];
-	dev_t dot_dev, dotdot_dev;
 	struct stat st;
+	dev_t dev;
 
 	igt_assert_lt(snprintf(buf, sizeof(buf), "%s/.", path), sizeof(buf));
-	igt_assert_eq(stat(buf, &st), 0);
-	dot_dev = st.st_dev;
+	if (stat(buf, &st))
+		return false;
+
+	if (!S_ISDIR(st.st_mode))
+		return false;
+
+	dev = st.st_dev;
 
 	igt_assert_lt(snprintf(buf, sizeof(buf), "%s/..", path), sizeof(buf));
-	igt_assert_eq(stat(buf, &st), 0);
-	dotdot_dev = st.st_dev;
+	if (stat(buf, &st))
+		return false;
+
+	if (!S_ISDIR(st.st_mode))
+		return false;
 
-	return dot_dev != dotdot_dev;
+	return dev != st.st_dev;
 }
 
 /**
@@ -113,16 +121,14 @@ static bool is_mountpoint(const char *path)
  */
 const char *igt_debugfs_mount(void)
 {
-	struct stat st;
+	if (is_mountpoint("/sys/kernel/debug"))
+		return "/sys/kernel/debug";
 
-	if (stat("/debug/dri", &st) == 0)
+	if (is_mountpoint("/debug"))
 		return "/debug";
 
-	if (stat("/sys/kernel/debug/dri", &st) == 0)
-		return "/sys/kernel/debug";
-
-	igt_assert(is_mountpoint("/sys/kernel/debug") ||
-		   mount("debug", "/sys/kernel/debug", "debugfs", 0, 0) == 0);
+	if (mount("debug", "/sys/kernel/debug", "debugfs", 0, 0))
+		return NULL;
 
 	return "/sys/kernel/debug";
 }
@@ -155,6 +161,7 @@ char *igt_debugfs_path(int device, char *path, int pathlen)
 	}
 
 	debugfs_root = igt_debugfs_mount();
+	igt_assert(debugfs_root);
 
 	idx = minor(st.st_rdev);
 	snprintf(path, pathlen, "%s/dri/%d/name", debugfs_root, idx);
-- 
2.15.0.rc0

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-10-13 15:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-13 12:02 [igt RFC 1/3] lib/debugfs: Make is_mountpoint() non-fatal Chris Wilson
2017-10-13 12:02 ` [igt RFC 2/3] lib: Add hooks for enabling ftrace Chris Wilson
2017-10-13 12:23   ` Chris Wilson
2017-10-13 12:02 ` [igt RFC 3/3] lib: Enable automatic ftrace dumping for suspend failures Chris Wilson
2017-10-13 12:33 ` [igt RFC 1/3] lib/debugfs: Make is_mountpoint() non-fatal Ville Syrjälä
2017-10-13 12:47 ` ✓ Fi.CI.BAT: success for series starting with [RFC,1/3] " Patchwork
2017-10-13 15:30 ` ✓ Fi.CI.IGT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox