From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [igt RFC 1/3] lib/debugfs: Make is_mountpoint() non-fatal
Date: Fri, 13 Oct 2017 15:33:58 +0300 [thread overview]
Message-ID: <20171013123358.GA10981@intel.com> (raw)
In-Reply-To: <20171013120259.28035-1-chris@chris-wilson.co.uk>
On Fri, Oct 13, 2017 at 01:02:57PM +0100, Chris Wilson wrote:
> 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>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> 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
--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-10-13 12:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Ville Syrjälä [this message]
2017-10-13 12:47 ` ✓ Fi.CI.BAT: success for series starting with [RFC,1/3] lib/debugfs: Make is_mountpoint() non-fatal Patchwork
2017-10-13 15:30 ` ✓ Fi.CI.IGT: " Patchwork
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=20171013123358.GA10981@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox