is_mountpoint() asserts rather than report the error. Normally this isn't a problem, except for atypical selftests. Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> --- 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 ee1f0f54..98b032a3 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -87,18 +87,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; } /** @@ -112,16 +120,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"; } @@ -154,6 +160,7 @@ int igt_debugfs_dir(int device) } debugfs_root = igt_debugfs_mount(); + igt_assert(debugfs_root); idx = minor(st.st_rdev); snprintf(path, sizeof(path), "%s/dri/%d/name", debugfs_root, idx); -- 2.13.3 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx