From 4dbdc42d9e7c3968ff7f690d00680419c9b8cb0f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 9 Apr 2024 15:34:27 +0200 Subject: Adding upstream version 1:2.43.0. Signed-off-by: Daniel Baumann --- compat/pread.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 compat/pread.c (limited to 'compat/pread.c') diff --git a/compat/pread.c b/compat/pread.c new file mode 100644 index 0000000..484e6d4 --- /dev/null +++ b/compat/pread.c @@ -0,0 +1,19 @@ +#include "../git-compat-util.h" +#include "../wrapper.h" + +ssize_t git_pread(int fd, void *buf, size_t count, off_t offset) +{ + off_t current_offset; + ssize_t rc; + + current_offset = lseek(fd, 0, SEEK_CUR); + + if (lseek(fd, offset, SEEK_SET) < 0) + return -1; + + rc = read_in_full(fd, buf, count); + + if (current_offset != lseek(fd, current_offset, SEEK_SET)) + return -1; + return rc; +} -- cgit v1.2.3