diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2022-08-31 08:15:29 -0500 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2023-05-16 04:31:22 +0000 |
commit | e0c3324695cd0232ef08df0394ba8922766bef3d (patch) | |
tree | e661d63d6a28f7238ab0cb19670ac0a05f878415 | |
parent | 730834aa6b3794128dac0daea4b1eb1212a6b163 (diff) | |
download | mesa-e0c3324695cd0232ef08df0394ba8922766bef3d.tar.gz |
drm-shim: Use anonymous file for file override
Using a pipe might mean that either the read or write call can block,
most likely deadlocking the calling process. Instead, write the contents
in an anonymous file when the file is opened to be read back.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18341>
-rw-r--r-- | src/drm-shim/drm_shim.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/drm-shim/drm_shim.c b/src/drm-shim/drm_shim.c index dec8e69a219..a0487356dd5 100644 --- a/src/drm-shim/drm_shim.c +++ b/src/drm-shim/drm_shim.c @@ -48,6 +48,7 @@ #include <c11/threads.h> #include <drm-uapi/drm.h> +#include "util/anon_file.h" #include "util/set.h" #include "util/u_debug.h" #include "drm_shim.h" @@ -297,12 +298,11 @@ static int file_override_open(const char *path) { for (int i = 0; i < file_overrides_count; i++) { if (strcmp(file_overrides[i].path, path) == 0) { - int fds[2]; - pipe(fds); - write(fds[1], file_overrides[i].contents, + int fd = os_create_anonymous_file(0, "shim file"); + write(fd, file_overrides[i].contents, strlen(file_overrides[i].contents)); - close(fds[1]); - return fds[0]; + lseek(fd, 0, SEEK_SET); + return fd; } } |