pread.c 311 B

1234567891011121314
  1. #include "file.h"
  2. #ifndef lint
  3. FILE_RCSID("@(#)$File: pread.c,v 1.1 2013/02/18 15:40:59 christos Exp $")
  4. #endif /* lint */
  5. #include <fcntl.h>
  6. #include <unistd.h>
  7. ssize_t
  8. pread(int fd, void *buf, ssize_t len, off_t off) {
  9. if (lseek(fd, off, SEEK_SET) == (off_t)-1)
  10. return -1;
  11. return read(fd, buf, len);
  12. }