Back to index

glibc  2.9
pread64.c File Reference
#include <errno.h>
#include <unistd.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


ssize_t __libc_pread64 (int fd, void *buf, size_t nbyte, off64_t offset)

Function Documentation

ssize_t __libc_pread64 ( int  fd,
void *  buf,
size_t  nbyte,
off64_t  offset 

Definition at line 28 of file pread64.c.

  /* Since we must not change the file pointer preserve the value so that
     we can restore it later.  */
  int save_errno;
  ssize_t result;
  off64_t old_offset = __libc_lseek64 (fd, 0, SEEK_CUR);
  if (old_offset == (off64_t) -1)
    return -1;

  /* Set to wanted position.  */
  if (__libc_lseek64 (fd, offset, SEEK_SET) == (off64_t) -1)
    return -1;

  /* Write out the data.  */
  result = __libc_read (fd, buf, nbyte);

  /* Now we have to restore the position.  If this fails we have to
     return this as an error.  But if the writing also failed we
     return this error.  */
  save_errno = errno;
  if (__libc_lseek64 (fd, old_offset, SEEK_SET) == (off64_t) -1)
      if (result == -1)
       __set_errno (save_errno);
      return -1;
  __set_errno (save_errno);

  return result;

Here is the call graph for this function: