Eleni Maria Stea
32b94df23e
util: replaced ENODATA with ENOATTR for non-Linux systems
...
On Linux ENODATA is defined but on BSD, and MacOSX ENOATTR is used
instead. Defined ENODATA to be ENOATTR when the system is not Linux.
v2: Replaced ENODATA and ENOATTR with -EFAULT that is exists everywhere
and added a comment (Ian Romanick)
Signed-off-by: Eleni Maria Stea <elene.mst@gmail.com >
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11203 >
2021-06-28 21:12:24 +03:00
Michael Tang
d4a51160ad
util: Make os_read_file use O_BINARY on Windows
...
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9513 >
2021-03-11 23:43:47 +00:00
Michael Tang
ecbb179c57
util: Implement os_read_file for Windows
...
Reviewed-by: Jesse Natalie <jenatali@microsoft.com >
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8043 >
2020-12-22 13:28:21 -08:00
Eric Engestrom
0e5ea7a363
util: introduce os_dupfd_cloexec() helper
...
Adapted from wayland's wl_os_dupfd_cloexec().
Suggested-by: Kristian H. Kristensen <hoegsberg@google.com >
Signed-off-by: Eric Engestrom <eric@engestrom.ch >
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com >
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5369 >
2020-06-18 02:09:56 +00:00
Eric Engestrom
b00e1d9ea7
util/os_file: replace broken windows-detection code with detect_os.h
...
The meson-windows-vs2019 job was going down the `!defined(WIN32)` path,
leading to a broken build once that path contained non-windows code.
Signed-off-by: Eric Engestrom <eric@engestrom.ch >
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com >
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5369 >
2020-06-18 02:09:56 +00:00
Pierre-Eric Pelloux-Prayer
2cb965e5b6
util/os_file: extend os_read_file to return the file size
...
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4181 >
2020-03-24 08:30:34 +01:00
Michel Dänzer
f5a8958910
util: Change os_same_file_description return type from bool to int
...
This allows communicating that it wasn't possible to determine whether
the two file descriptors reference the same file description. When
that's the case, log a warning in the amdgpu winsys.
In turn, remove the corresponding debugging output from the fallback
os_same_file_description implementation. It depends on the caller if
false negatives are problematic or not.
Reviewed-by: Eric Engestrom <eric@engestrom.ch >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3879 >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3879 >
2020-02-21 17:10:48 +01:00
Marek Olšák
f7bfb10c69
util: remove the dependency on kcmp.h
...
Fixes: f76cbc7901 "util: Add os_same_file_description helper"
Acked-by: Eric Engestrom <eric@engestrom.ch >
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com >
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3860 >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3860 >
2020-02-20 00:15:23 +00:00
Michel Dänzer
f76cbc7901
util: Add os_same_file_description helper
...
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3202 >
2020-01-23 17:39:34 +01:00
Eric Engestrom
1667360f7d
util/os_file: fix double-close()
...
Fixes: 955c63d364 ("util/os_file: resize buffer to what was actually needed")
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com >
Reviewed-by: Tapani Pälli <tapani.palli@intel.com >
2019-09-04 00:11:51 +01:00
Eric Engestrom
1b259f1ae7
util: add os_file_create_unique()
...
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com >
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com >
Reviewed-by: Marek Olšák <marek.olsak@amd.com >
2019-06-28 23:37:49 +01:00
Eric Engestrom
955c63d364
util/os_file: resize buffer to what was actually needed
...
Fixes: 316964709e "util: add os_read_file() helper"
Reported-by: Jason Ekstrand <jason@jlekstrand.net >
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com >
Reviewed-by: Tapani Pälli <tapani.palli@intel.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
2019-06-20 21:49:30 +00:00
Eric Engestrom
93349d7118
util/os_file: suppress sign comparison warning
...
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com >
Reviewed-by: Eric Anholt <eric@anholt.net >
2019-06-09 13:14:13 +00:00
Eric Engestrom
fd5c18de88
util/os_file: fix error being sign-cast back and forth
...
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com >
Reviewed-by: Eric Anholt <eric@anholt.net >
2019-06-09 13:14:13 +00:00
Eric Engestrom
341ba406fd
util/os_file: avoid shadowing read() with a local variable
...
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com >
Reviewed-by: Eric Anholt <eric@anholt.net >
2019-06-09 13:14:13 +00:00
Eric Engestrom
7e35f20d44
util/os_file: actually return the error read() gave us
...
Fixes: 316964709e "util: add os_read_file() helper"
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com >
Reviewed-by: Eric Anholt <eric@anholt.net >
2019-06-09 13:14:13 +00:00
Eric Engestrom
22c1657d05
util/os_file: always use the 'grow' mechanism
...
Use fstat() only to pre-allocate a big enough buffer.
This fixes a race where if the file grows between fstat() and read()
we would be missing the end of the file, and if the file slims down
read() would just fail.
Fixes: 316964709e "util: add os_read_file() helper"
Reported-by: Jason Ekstrand <jason@jlekstrand.net >
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
2019-05-16 12:56:25 +01:00
Eric Engestrom
70da00ffd6
util: move #include out of #if linux
...
This #include is needed for `NULL`, which is used on all OSes, not just Linux.
Reported-by: Juan A. Suarez Romero <jasuarez@igalia.com >
Fixes: 316964709e "util: add os_read_file() helper"
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com >
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com >
2019-05-01 15:45:47 +00:00
Eric Engestrom
316964709e
util: add os_read_file() helper
...
readN() taken from igt.
os_read_file() inspired by igt_sysfs_get()
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
2019-04-30 15:40:33 +00:00