[dovecot-cvs] dovecot/src/lib compat.c,1.13,1.14
cras at procontrol.fi
cras at procontrol.fi
Sun Oct 5 22:02:00 EEST 2003
Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv27219
Modified Files:
compat.c
Log Message:
pread/pwrite doesn't move file offset. make our compat functions restore it
Index: compat.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/compat.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- compat.c 3 Oct 2003 14:50:48 -0000 1.13
+++ compat.c 5 Oct 2003 18:01:57 -0000 1.14
@@ -99,15 +99,33 @@
#ifndef HAVE_PWRITE
ssize_t my_pread(int fd, void *buf, size_t count, off_t offset)
{
+ ssize_t ret;
+
if (lseek(fd, offset, SEEK_SET) < 0)
return -1;
- return read(fd, buf, count);
+
+ ret = read(fd, buf, count);
+ if (ret < 0)
+ return -1;
+
+ if (lseek(fd, offset, SEEK_SET) < 0)
+ return -1;
+ return ret;
}
ssize_t my_pwrite(int fd, const void *buf, size_t count, off_t offset)
{
+ ssize_t ret;
+
if (lseek(fd, offset, SEEK_SET) < 0)
return -1;
- return write(fd, buf, count);
+
+ ret = write(fd, buf, count);
+ if (ret < 0)
+ return -1;
+
+ if (lseek(fd, offset, SEEK_SET) < 0)
+ return -1;
+ return ret;
}
#endif
More information about the dovecot-cvs
mailing list