diff options
author | Jeremy Allison <jra@samba.org> | 2004-01-06 01:22:14 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2004-01-06 01:22:14 +0000 |
commit | 019aaaf0df091c3f67048f591e70d4353a02bb9b (patch) | |
tree | 9b51eb27cc50ecf8ca02d5ee9876cb54d1954f0f /source/lib/system.c | |
parent | 93a5d8079a0291be14517e437f8f0c964c21e91d (diff) | |
download | samba-019aaaf0df091c3f67048f591e70d4353a02bb9b.tar.gz samba-019aaaf0df091c3f67048f591e70d4353a02bb9b.tar.xz samba-019aaaf0df091c3f67048f591e70d4353a02bb9b.zip |
Patch based on work from James Peach <jpeach@sgi.com> to convert over to
using pread/pwrite. Modified a little to ensure fsp->pos is correct.
Fix for #889.
Jeremy.
Diffstat (limited to 'source/lib/system.c')
-rw-r--r-- | source/lib/system.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source/lib/system.c b/source/lib/system.c index 577f0b9a206..16384c8bdf5 100644 --- a/source/lib/system.c +++ b/source/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. ********************************************************************/ |