aboutsummaryrefslogtreecommitdiffstats
path: root/src/util/os_file.c
Commit message (Collapse)AuthorAgeFilesLines
* util: introduce os_dupfd_cloexec() helperEric Engestrom2020-06-181-0/+49
| | | | | | | | | | Adapted from wayland's wl_os_dupfd_cloexec(). Suggested-by: Kristian H. Kristensen <[email protected]> Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5369>
* util/os_file: replace broken windows-detection code with detect_os.hEric Engestrom2020-06-181-3/+3
| | | | | | | | | | 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 <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5369>
* util/os_file: extend os_read_file to return the file sizePierre-Eric Pelloux-Prayer2020-03-241-2/+5
| | | | | Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4181>
* util: Change os_same_file_description return type from bool to intMichel Dänzer2020-02-211-7/+11
| | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3879> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3879>
* util: remove the dependency on kcmp.hMarek Olšák2020-02-201-1/+2
| | | | | | | | | Fixes: f76cbc7901f7 "util: Add os_same_file_description helper" Acked-by: Eric Engestrom <[email protected]> Reviewed-by: Michel Dänzer <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3860> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3860>
* util: Add os_same_file_description helperMichel Dänzer2020-01-231-0/+23
| | | | | Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3202>
* util/os_file: fix double-close()Eric Engestrom2019-09-041-1/+0
| | | | | | Fixes: 955c63d3643f30d7db0c ("util/os_file: resize buffer to what was actually needed") Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* util: add os_file_create_unique()Eric Engestrom2019-06-281-0/+23
| | | | | | Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* util/os_file: resize buffer to what was actually neededEric Engestrom2019-06-201-0/+11
| | | | | | | | Fixes: 316964709e21286c2af5 "util: add os_read_file() helper" Reported-by: Jason Ekstrand <[email protected]> Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* util/os_file: suppress sign comparison warningEric Engestrom2019-06-091-1/+1
| | | | | Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* util/os_file: fix error being sign-cast back and forthEric Engestrom2019-06-091-1/+1
| | | | | Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* util/os_file: avoid shadowing read() with a local variableEric Engestrom2019-06-091-5/+5
| | | | | Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* util/os_file: actually return the error read() gave usEric Engestrom2019-06-091-1/+3
| | | | | | Fixes: 316964709e21286c2af5 "util: add os_read_file() helper" Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* util/os_file: always use the 'grow' mechanismEric Engestrom2019-05-161-42/+20
| | | | | | | | | | | | | 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: 316964709e21286c2af5 "util: add os_read_file() helper" Reported-by: Jason Ekstrand <[email protected]> Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* util: move #include out of #if linuxEric Engestrom2019-05-011-1/+1
| | | | | | | | | This #include is needed for `NULL`, which is used on all OSes, not just Linux. Reported-by: Juan A. Suarez Romero <[email protected]> Fixes: 316964709e21286c2af5 "util: add os_read_file() helper" Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Juan A. Suarez <[email protected]>
* util: add os_read_file() helperEric Engestrom2019-04-301-0/+129
readN() taken from igt. os_read_file() inspired by igt_sysfs_get() Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>