[rfc v2][4/6] Readlink as file I/O target operation
Pedro Alves
palves@redhat.com
Mon Jan 16 15:37:00 GMT 2012
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
More information about the Gdb-patches
mailing list