summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-01-06 01:21:59 +0000
committerJeremy Allison <jra@samba.org>2004-01-06 01:21:59 +0000
commit827c68deb89b5bd14324c57db14274b36a0790d7 (patch)
tree018ea2e604f64a73899744fced6a41086c90e512 /source3/lib
parent35f843a1be9a703328eee3241bc24416cca945e0 (diff)
downloadsamba-827c68deb89b5bd14324c57db14274b36a0790d7.tar.gz
samba-827c68deb89b5bd14324c57db14274b36a0790d7.tar.bz2
samba-827c68deb89b5bd14324c57db14274b36a0790d7.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. (This used to be commit 3a24dc868d95c9bcc2ac3a0dbd50e6e226ac0841)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/system.c41
1 files changed, 41 insertions, 0 deletions
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.
********************************************************************/