From 6900679c2f6d937a5a6ef616869c8887690ad19d Mon Sep 17 00:00:00 2001 From: "Stefan-W. Hahn" Date: Tue, 9 Jan 2007 22:04:12 +0100 Subject: Replacing the system call pread() with lseek()/xread()/lseek() sequence. Using cygwin with cygwin.dll before 1.5.22 the system call pread() is buggy. This patch introduces NO_PREAD. If NO_PREAD is set git uses a sequence of lseek()/xread()/lseek() to emulate pread. Signed-off-by: Stefan-W. Hahn Signed-off-by: Junio C Hamano --- compat/pread.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 compat/pread.c (limited to 'compat') diff --git a/compat/pread.c b/compat/pread.c new file mode 100644 index 0000000000..978cac4ec9 --- /dev/null +++ b/compat/pread.c @@ -0,0 +1,18 @@ +#include "../git-compat-util.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