This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [rfc v2][4/6] Readlink as file I/O target operation
- From: Pedro Alves <palves at redhat dot com>
- To: Ulrich Weigand <uweigand at de dot ibm dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 16 Jan 2012 15:17:27 +0000
- Subject: Re: [rfc v2][4/6] Readlink as file I/O target operation
- References: <201201131815.q0DIFCKZ001538@d06av02.portsmouth.uk.ibm.com>
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