From: Timo Sirainen Date: Wed, 6 Aug 2003 19:46:51 +0000 (+0300) Subject: Added pwrite() compatibility X-Git-Tag: 1.1.alpha1~4437 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b101f5d02f61d39793141b9e4449cc36bb0378a;p=thirdparty%2Fdovecot%2Fcore.git Added pwrite() compatibility --HG-- branch : HEAD --- diff --git a/configure.in b/configure.in index bcebb86db7..8e59543047 100644 --- a/configure.in +++ b/configure.in @@ -225,8 +225,8 @@ fi 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? diff --git a/src/lib/compat.c b/src/lib/compat.c index cc44476e70..38fd4be408 100644 --- a/src/lib/compat.c +++ b/src/lib/compat.c @@ -118,3 +118,19 @@ ssize_t my_writev(int fd, const struct iovec *iov, int iov_len) 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 diff --git a/src/lib/compat.h b/src/lib/compat.h index be531f66cc..7d5800df98 100644 --- a/src/lib/compat.h +++ b/src/lib/compat.h @@ -94,6 +94,11 @@ struct iovec; 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)))