This is the mail archive of the
mailing list for the GDB project.
Re: [RFA/gdbserver] Provide dummy readlink on systems where routine is not available.
> Date: Fri, 3 Feb 2012 16:30:30 +0400
> From: Joel Brobecker <firstname.lastname@example.org>
> Cc: email@example.com
> Another revised version, with 2 small changes:
> - The pre-processor condition used to determine whether we need to
> declare readlink in gdb_readlink.h or not was wrong. Somehow,
> HAVE_ macros and HAVE_DECL_ macros are handled differently.
> - I forgot to update hostio.c's dependency on gdb_readlink.h
> in the Makefile.
> Both issues now fixed, and new patch attached.
If memory serves, Pedro was against this when I suggested it.
> + This function return -1 (error) and sets errno to ENOSYS to indicate
> + that this function is not implemented. The caller should be prepared
> + to recover from that. */
But the function in fact returns EINVAL:
> +readlink(const char *path, char *buf, size_t bufsiz)
> + errno = EINVAL;
> + return -1;
I cannot resist re-iterating my original suggestion: test the file for
existence, return ENOENT if it doesn't exist, and otherwise return
EINVAL, meaning that the file is not a link.
Or just use the readlink module from gnulib, which does exactly that.