This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [rfc v2][4/6] Readlink as file I/O target operation


Hi,

On 01/13/2012 06:15 PM, Ulrich Weigand wrote:
> +/* Read value of symbolic link FILENAME on the remote target.  Return
> +   a null-terminated string allocated via xmalloc, or NULL if an error
> +   occurs (and set *REMOTE_ERRNO).  */
> +static char *
> +inf_child_fileio_readlink (const char *filename, int *target_errno)
> +{
> +  /* We support readlink only on systems that also provide a compile-time
> +     maximum path length (MAXPATHLEN), at least for now.  */
> +#if defined (HAVE_READLINK) && defined (MAXPATHLEN)
> +  char buf[MAXPATHLEN];
> +  int len;
> +  char *ret;
> +
> +  len = readlink (filename, buf, sizeof buf);
> +  if (len < 0)
> +    {
> +      *target_errno = inf_child_errno_to_fileio_error (errno);
> +      return NULL;
> +    }
> +
> +  ret = xmalloc (len + 1);
> +  memcpy (ret, buf, len);
> +  ret[len] = '\0';
> +  return ret;
> +#else
> +  *target_errno = FILEIO_EUNKNOWN;

Should this be FILEIO_ENOSYS ?

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]