changeset 1669:a0dd52443420 HEAD

Added pwrite() compatibility
author Timo Sirainen <tss@iki.fi>
date Wed, 06 Aug 2003 22:46:51 +0300
parents 644268046d59
children cfaef4f27083
files configure.in src/lib/compat.c src/lib/compat.h
diffstat 3 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/configure.in	Wed Aug 06 22:46:27 2003 +0300
+++ b/configure.in	Wed Aug 06 22:46:51 2003 +0300
@@ -225,8 +225,8 @@
 
 dnl * after -lsocket and -lnsl tests, inet_aton() may be in them
 AC_CHECK_FUNCS(fcntl flock inet_aton sigaction getpagesize madvise \
-               strcasecmp stricmp vsnprintf vsyslog writev setrlimit \
-	       setproctitle)
+               strcasecmp stricmp vsnprintf vsyslog writev pwrite \
+	       setrlimit setproctitle)
 
 dnl * poll/select?
 
--- a/src/lib/compat.c	Wed Aug 06 22:46:27 2003 +0300
+++ b/src/lib/compat.c	Wed Aug 06 22:46:51 2003 +0300
@@ -118,3 +118,19 @@
 	return (ssize_t)written;
 }
 #endif
+
+#ifndef HAVE_PWRITE
+ssize_t pread(int fd, void *buf, size_t count, off_t offset)
+{
+	if (lseek(fd, offset, SEEK_SET) < 0)
+		return -1;
+	return read(fd, buf, count);
+}
+
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)
+{
+	if (lseek(fd, offset, SEEK_SET) < 0)
+		return -1;
+	return write(fd, buf, count);
+}
+#endif
--- a/src/lib/compat.h	Wed Aug 06 22:46:27 2003 +0300
+++ b/src/lib/compat.h	Wed Aug 06 22:46:51 2003 +0300
@@ -94,6 +94,11 @@
 ssize_t my_writev(int fd, const struct iovec *iov, int iov_len);
 #endif
 
+#ifndef HAVE_PWRITE
+ssize_t pread(int fd, void *buf, size_t count, off_t offset);
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
+#endif
+
 /* ctype.h isn't safe with signed chars,
    use our own instead if really needed */
 #define i_toupper(x) ((char) toupper((int) (unsigned char) (x)))