[PATCH i-g-t 02/39] lib/igt_debugfs: Move is_mountpoint() to igt_aux
José Expósito
jose.exposito89 at gmail.com
Tue Feb 18 16:49:34 UTC 2025
Rename is_mountpoint() to igt_is_mountpoint() and make it available in
igt_aux.h/c.
Refactor, no functional change.
Co-developed-by: Jim Shargo <jshargo at chromium.org>
Signed-off-by: Jim Shargo <jshargo at chromium.org>
Co-developed-by: Marius Vlad <marius.vlad at collabora.com>
Signed-off-by: Marius Vlad <marius.vlad at collabora.com>
Signed-off-by: José Expósito <jose.exposito89 at gmail.com>
---
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 f5bf48da6..d8f1f6982 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -1374,6 +1374,31 @@ static bool get_process_ids(struct igt_process *prcs)
return prcs->tid != 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;
+}
+
/**
* igt_is_process_running:
* @comm: Name of process in the form found in /proc/pid/comm (limited to 15
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index bfd83adca..e8a1788b2 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -314,6 +314,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 8ac215a76..210a9cea0 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.48.1
More information about the igt-dev
mailing list