Add xReadfile wrapper for reading small to medium size files

Inspired by proposed Linux syscall

Avoid file descriptor leaks like 4af8c63f
This commit is contained in:
Christian Göttsche
2020-11-25 12:42:36 +01:00
committed by BenBE
parent 1d8192c10b
commit f7a8952933
5 changed files with 85 additions and 134 deletions

View File

@ -14,6 +14,7 @@ in the source distribution for its full text.
#include <stdlib.h> // IWYU pragma: keep
#include <string.h> // IWYU pragma: keep
#include "Compat.h"
#include "Macros.h"
@ -63,4 +64,7 @@ char* xStrdup(const char* str) ATTR_NONNULL;
char* xStrndup(const char* str, size_t len) ATTR_NONNULL;
ssize_t xReadfile(const char* pathname, void* buffer, size_t count);
ssize_t xReadfileat(openat_arg_t dirfd, const char* pathname, void* buffer, size_t count);
#endif