4f294c247f
This patch mainly copies and modifies files existing in the current libc implementing minix specific functions. To keep consisten with the NetBSD libc, we remove namespace stubs and we use "namespace.h" and weak links.
37 lines
555 B
C
37 lines
555 B
C
#include <sys/cdefs.h>
|
|
#include "namespace.h"
|
|
#include <lib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#ifdef __weak_alias
|
|
__weak_alias(pread, _pread)
|
|
#endif
|
|
|
|
#include <lib.h>
|
|
#include <unistd.h>
|
|
|
|
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;
|
|
}
|
|
|