Back to index

glibc  2.9
readlink.c File Reference
#include <unistd.h>
#include <hurd.h>
#include <hurd/paths.h>
#include <fcntl.h>
#include <string.h>

Go to the source code of this file.


ssize_t __readlink (char *file_name, char *buf, size_t len) const

Function Documentation

ssize_t __readlink ( char *  file_name,
char *  buf,
size_t  len 
) const

Definition at line 29 of file readlink.c.

  error_t err;
  file_t file;
  struct stat64 st;

  file = __file_name_lookup (file_name, O_READ | O_NOLINK, 0);
  if (file == MACH_PORT_NULL)
    return -1;

  err = __io_stat (file, &st);
  if (! err)
    if (S_ISLNK (st.st_mode))
       char *rbuf = buf;

       err = __io_read (file, &rbuf, &len, 0, len);
       if (!err && rbuf != buf)
           memcpy (buf, rbuf, len);
           __vm_deallocate (__mach_task_self (), (vm_address_t)rbuf, len);
      err = EINVAL;

  __mach_port_deallocate (__mach_task_self (), file);

  if (err)
    return __hurd_fail (err);
    return len;

Here is the call graph for this function: