[igt-dev] [PATCH i-g-t 24/29] lib/ioctl_wrappers: Support FreeBSD in igt_require_gem

D Scott Phillips d.scott.phillips at intel.com
Wed Dec 11 00:52:30 UTC 2019


On FreeBSD, fdescfs is mounted at /dev/fd/ and provides equivalent
functionality to Linux's /proc/self/fd.

Signed-off-by: D Scott Phillips <d.scott.phillips at intel.com>
---
 lib/ioctl_wrappers.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 78b92bd2..3b060f56 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1222,7 +1222,7 @@ static void reset_device(int fd)
 
 void igt_require_gem(int fd)
 {
-	char path[256];
+	char path[256] = {0};
 	int err;
 
 	igt_require_intel(fd);
@@ -1232,7 +1232,11 @@ void igt_require_gem(int fd)
 	 * of a wedged device, not for actually waiting on outstanding
 	 * requests! So create a new drm_file for the device that is clean.
 	 */
+#if defined(__linux__)
 	snprintf(path, sizeof(path), "/proc/self/fd/%d", fd);
+#elif defined(__FreeBSD__)
+	snprintf(path, sizeof(path), "/dev/fd/%d", fd);
+#endif
 	fd = open(path, O_RDWR);
 	igt_assert_lte(0, fd);
 
-- 
2.23.0



More information about the igt-dev mailing list