From 827c68deb89b5bd14324c57db14274b36a0790d7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 6 Jan 2004 01:21:59 +0000 Subject: Patch based on work from James Peach to convert over to using pread/pwrite. Modified a little to ensure fsp->pos is correct. Fix for #889. Jeremy. (This used to be commit 3a24dc868d95c9bcc2ac3a0dbd50e6e226ac0841) --- source3/lib/system.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/system.c b/source3/lib/system.c index 577f0b9a20..16384c8bdf 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -100,6 +100,47 @@ ssize_t sys_write(int fd, const void *buf, size_t count) return ret; } + +/******************************************************************* +A pread wrapper that will deal with EINTR and 64-bit file offsets. +********************************************************************/ + +#if defined(HAVE_PREAD) || defined(HAVE_PREAD64) +ssize_t sys_pread(int fd, void *buf, size_t count, SMB_OFF_T off) +{ + ssize_t ret; + + do { +#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_PREAD64) + ret = pread64(fd, buf, count, off); +#else + ret = pread(fd, buf, count, off); +#endif + } while (ret == -1 && errno == EINTR); + return ret; +} +#endif + +/******************************************************************* +A write wrapper that will deal with EINTR and 64-bit file offsets. +********************************************************************/ + +#if defined(HAVE_PWRITE) || defined(HAVE_PWRITE64) +ssize_t sys_pwrite(int fd, const void *buf, size_t count, SMB_OFF_T off) +{ + ssize_t ret; + + do { +#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_PWRITE64) + ret = pwrite64(fd, buf, count, off); +#else + ret = pwrite(fd, buf, count, off); +#endif + } while (ret == -1 && errno == EINTR); + return ret; +} +#endif + /******************************************************************* A send wrapper that will deal with EINTR. ********************************************************************/ -- cgit