minix/lib/libc/sys-minix/pread.c
Lionel Sambuc d3b0a89bab include/unistd.h: merged
Also removing lseek64, pread64, pwrite64.

Those functions have lost their "raison d'être", when off_t switched to
64bits.

Change-Id: I5aea35f01d6d10e3d6578a70323da7be5eca315a
2014-03-03 20:47:02 +01:00

34 lines
519 B
C

#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <unistd.h>
#ifdef __weak_alias
__weak_alias(pread, _pread)
#endif
ssize_t pread(int fd, void *buffer, size_t nbytes, off_t where)
{
off_t here;
ssize_t r;
if((here = lseek(fd, 0, SEEK_CUR)) < 0)
return -1;
if(lseek(fd, where, SEEK_SET) < 0)
return -1;
if((r=read(fd, buffer, nbytes)) < 0) {
int e = errno;
lseek(fd, here, SEEK_SET);
errno = e;
return -1;
}
if(lseek(fd, here, SEEK_SET) < 0)
return -1;
return r;
}