Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 1/2] lib/igt_debugfs: Add function to check if file exists in debugfs
@ 2018-04-10 13:52 Piotr Piórkowski
  2018-04-10 13:52 ` [igt-dev] [PATCH i-g-t 2/2] tests/debugfs_test: Add subtest guc_log_relay Piotr Piórkowski
                   ` (8 more replies)
  0 siblings, 9 replies; 17+ messages in thread
From: Piotr Piórkowski @ 2018-04-10 13:52 UTC (permalink / raw)
  To: igt-dev

We doesn't have simple to use function to check if file exists
in debugfs.
Let's add function which takes as arguments the file descriptor of the
device and file name in the debugfs of this device, and return true if
file exists, otherwise false.

Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Cc: Sagar Arun Kamble <sagar.a.kamble@intel.com>
Cc: Lukasz Fiedorowicz <lukasz.fiedorowicz@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
---
 lib/igt_debugfs.c | 28 ++++++++++++++++++++++++++++
 lib/igt_debugfs.h |  1 +
 2 files changed, 29 insertions(+)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 8adc02e9..a0aa357a 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -214,6 +214,34 @@ char *igt_debugfs_path(int device, char *path, int pathlen)
 	return path;
 }
 
+/**
+ * igt_debugfs_is_file_exists:
+ * @device: fd of the device
+ * @filename: name of the debugfs node to open
+ *
+ * This checks if the file exists in debugfs. The filename should be
+ * relative to the drm device's root, i.e. without "drm/$minor".
+ *
+ * Returns:
+ * The true if the file exists, otherwise false.
+ */
+bool igt_debugfs_is_file_exists(int device, const char *filename)
+{
+	struct stat buffer;
+	char path[256];
+	bool exists = false;
+
+	if (!igt_debugfs_path(device, path, sizeof(path)))
+		return false;
+
+	sprintf(path, "%s/%s", path, filename);
+
+	exists = stat(path, &buffer) == 0;
+	igt_debug("File %s %s exists\n", path, exists ? "is" : "is not");
+
+	return exists;
+}
+
 /**
  * igt_debugfs_dir:
  * @device: fd of the device
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index 8d25abfe..ec91800e 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -33,6 +33,7 @@ enum pipe;
 
 const char *igt_debugfs_mount(void);
 char *igt_debugfs_path(int device, char *path, int pathlen);
+bool igt_debugfs_is_file_exists(int device, const char *filename);
 
 int igt_debugfs_dir(int device);
 
-- 
2.14.3

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

end of thread, other threads:[~2018-05-21 15:08 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-10 13:52 [igt-dev] [PATCH i-g-t 1/2] lib/igt_debugfs: Add function to check if file exists in debugfs Piotr Piórkowski
2018-04-10 13:52 ` [igt-dev] [PATCH i-g-t 2/2] tests/debugfs_test: Add subtest guc_log_relay Piotr Piórkowski
2018-04-10 14:06   ` Chris Wilson
2018-04-10 14:02 ` [igt-dev] [PATCH i-g-t 1/2] lib/igt_debugfs: Add function to check if file exists in debugfs Chris Wilson
2018-04-10 14:46 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] " Patchwork
2018-04-10 16:57 ` [igt-dev] ✗ Fi.CI.IGT: warning " Patchwork
2018-04-24  7:50 ` [igt-dev] [PATCH v2 1/2] " Piotr Piorkowski
2018-04-24  8:27   ` Chris Wilson
2018-05-15 15:29   ` [igt-dev] [PATCH v3 " Piotr Piorkowski
2018-05-21 12:55   ` Piotr Piorkowski
2018-05-21 12:55   ` [igt-dev] [PATCH v3 2/2] tests/debugfs_test: Add subtest guc_log_relay Piotr Piorkowski
2018-04-24  7:50 ` [igt-dev] [PATCH v2 " Piotr Piorkowski
2018-04-24  8:34   ` Chris Wilson
2018-04-24 13:24     ` Piorkowski, Piotr
2018-04-24  8:52 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [v2,1/2] lib/igt_debugfs: Add function to check if file exists in debugfs (rev2) Patchwork
2018-05-15 15:57 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [v3,1/2] lib/igt_debugfs: Add function to check if file exists in debugfs (rev3) Patchwork
2018-05-21 15:08 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [v3,2/2] tests/debugfs_test: Add subtest guc_log_relay (rev5) Patchwork

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