Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: James Shargo <jshargo@chromium.org>
To: Development mailing list for IGT GPU Tools
	<igt-dev@lists.freedesktop.org>
Subject: [igt-dev] [PATCH i-g-t 2/3] lib/igt_aux: Make "is_mountpoint" public ("igt_is_mountpoint")
Date: Fri, 23 Jun 2023 19:09:53 -0400	[thread overview]
Message-ID: <20230623230954.115437-3-jshargo@chromium.org> (raw)
In-Reply-To: <20230623230954.115437-1-jshargo@chromium.org>

From: Jim Shargo <jshargo@chromium.org>

This change supports the subsequent testing of ConfigFS-based VKMS
features, which require their own mounting.

Signed-off-by: Jim Shargo <jshargo@chromium.org>
---
 lib/igt_aux.c     | 25 +++++++++++++++++++++++++
 lib/igt_aux.h     |  2 ++
 lib/igt_debugfs.c | 29 ++---------------------------
 3 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 386e25783..4ec5fc154 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -1970,6 +1970,31 @@ bool igt_allow_unlimited_files(void)
 	return setrlimit(RLIMIT_NOFILE, &rlim) == 0;
 }
 
+bool igt_is_mountpoint(const char *path)
+{
+	char buf[strlen(path) + 4];
+	struct stat st;
+	dev_t dev;
+
+	igt_assert_lt(snprintf(buf, sizeof(buf), "%s/.", path), sizeof(buf));
+	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));
+	if (stat(buf, &st))
+		return false;
+
+	if (!S_ISDIR(st.st_mode))
+		return false;
+
+	return dev != st.st_dev;
+}
+
 /**
  * vfs_file_max: report maximum number of files
  *
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index fb76b0313..298c610f2 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -311,6 +311,8 @@ double igt_stop_siglatency(struct igt_mean *result);
 
 bool igt_allow_unlimited_files(void);
 
+bool igt_is_mountpoint(const char *path);
+
 int igt_is_process_running(const char *comm);
 int igt_terminate_process(int sig, const char *comm);
 void igt_lsof(const char *dpath);
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index a7b54bae5..63fc6b9e7 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -67,37 +67,12 @@
  * General debugfs helpers
  */
 
-static bool is_mountpoint(const char *path)
-{
-	char buf[strlen(path) + 4];
-	struct stat st;
-	dev_t dev;
-
-	igt_assert_lt(snprintf(buf, sizeof(buf), "%s/.", path), sizeof(buf));
-	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));
-	if (stat(buf, &st))
-		return false;
-
-	if (!S_ISDIR(st.st_mode))
-		return false;
-
-	return dev != st.st_dev;
-}
-
 static const char *__igt_debugfs_mount(void)
 {
-	if (is_mountpoint("/sys/kernel/debug"))
+	if (igt_is_mountpoint("/sys/kernel/debug"))
 		return "/sys/kernel/debug";
 
-	if (is_mountpoint("/debug"))
+	if (igt_is_mountpoint("/debug"))
 		return "/debug";
 
 	if (mount("debug", "/sys/kernel/debug", "debugfs", 0, 0))
-- 
2.41.0.162.gfafddb0af9-goog

  parent reply	other threads:[~2023-06-23 23:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-23 23:09 [igt-dev] [PATCH i-g-t 0/3] Add tests and support for VKMS's new ConfigFS features James Shargo
2023-06-23 23:09 ` [igt-dev] [PATCH i-g-t 1/3] lib/drmtest: Add VKMS as a known driver type James Shargo
2023-06-28 18:50   ` Kamil Konieczny
2023-06-23 23:09 ` James Shargo [this message]
2023-06-28 18:57   ` [igt-dev] [PATCH i-g-t 2/3] lib/igt_aux: Make "is_mountpoint" public ("igt_is_mountpoint") Kamil Konieczny
2023-06-23 23:09 ` [igt-dev] [PATCH i-g-t 3/3] tests/vkms: Adds VKMS tests and library functions to support them James Shargo
2023-06-28 19:27   ` Kamil Konieczny
2023-06-24  0:49 ` [igt-dev] ✗ GitLab.Pipeline: warning for Add tests and support for VKMS's new ConfigFS features Patchwork
2023-06-24  1:23 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-06-24  3:36 ` [igt-dev] ✓ 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=20230623230954.115437-3-jshargo@chromium.org \
    --to=jshargo@chromium.org \
    --cc=igt-dev@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