Back to index

glibc  2.9
fd-read.c File Reference
#include <errno.h>
#include <unistd.h>
#include <hurd.h>
#include <hurd/fd.h>
#include <string.h>

Go to the source code of this file.


error_t _hurd_fd_read (struct hurd_fd *fd, void *buf, size_t *nbytes, loff_t offset)

Function Documentation

error_t _hurd_fd_read ( struct hurd_fd fd,
void *  buf,
size_t nbytes,
loff_t  offset 

Definition at line 26 of file fd-read.c.

  error_t err;
  char *data;
  mach_msg_type_number_t nread;

  error_t readfd (io_t port)
      return __io_read (port, &data, &nread, offset, *nbytes);

  data = buf;
  nread = *nbytes;
  if (err = HURD_FD_PORT_USE (fd, _hurd_ctty_input (port, ctty, readfd)))
    return err;

  if (data != buf)
      if (nread > *nbytes)  /* Sanity check for bogus server.  */
         __vm_deallocate (__mach_task_self (), (vm_address_t) data, nread);
         return EGRATUITOUS;
      memcpy (buf, data, nread);
      __vm_deallocate (__mach_task_self (), (vm_address_t) data, nread);

  *nbytes = nread;
  return 0;

Here is the call graph for this function:

Here is the caller graph for this function: