diff options
author | Ulrich Weigand <uweigand@de.ibm.com> | 2012-01-20 09:47:32 +0000 |
---|---|---|
committer | Ulrich Weigand <uweigand@de.ibm.com> | 2012-01-20 09:47:32 +0000 |
commit | b9e7b9c3de60f6aef716ac169d82418ea27d4331 (patch) | |
tree | d50dcabd991b1b7fa639b51eba142bd39db2f4b8 /gdb/inf-child.c | |
parent | 7313baad7c73664bed62b87481cbb078d71e84f4 (diff) | |
download | gdb-b9e7b9c3de60f6aef716ac169d82418ea27d4331.zip gdb-b9e7b9c3de60f6aef716ac169d82418ea27d4331.tar.gz gdb-b9e7b9c3de60f6aef716ac169d82418ea27d4331.tar.bz2 |
ChangeLog:
* configure.ac [AC_CHECK_FUNCS]: Check for readlink.
* config.in, configure: Regenerate.
* target.h (struct target_ops): Add to_fileio_readlink.
(target_fileio_readlink): Add prototype.
* target.c (target_fileio_readlink): New function.
* inf-child.c: Conditionally include <sys/param.h>.
(inf_child_fileio_readlink): New function.
(inf_child_target): Install it.
* remote.c (PACKET_vFile_readlink): New enum value.
(remote_hostio_readlink): New function.
(init_remote_ops): Install it.
(_initialize_remote): Handle vFile:readlink packet type.
doc/ChangeLog:
* gdb.texinfo (Remote Configuration): Document
"set remote hostio-readlink-packet" command.
(General Query Packets): Document vFile:readlink packet.
gdbserver/ChangeLog:
* hostio.c (handle_readlink): New function.
(handle_vFile): Call it to handle "vFile:readlink" packets.
Diffstat (limited to 'gdb/inf-child.c')
-rw-r--r-- | gdb/inf-child.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gdb/inf-child.c b/gdb/inf-child.c index 0dda331..2271824 100644 --- a/gdb/inf-child.c +++ b/gdb/inf-child.c @@ -29,6 +29,9 @@ #include "inf-child.h" #include "gdb/fileio.h" +#ifdef HAVE_SYS_PARAM_H +#include <sys/param.h> /* for MAXPATHLEN */ +#endif #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> @@ -299,6 +302,36 @@ inf_child_fileio_unlink (const char *filename, int *target_errno) return ret; } +/* Read value of symbolic link FILENAME on the target. Return a + null-terminated string allocated via xmalloc, or NULL if an error + occurs (and set *TARGET_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_ENOSYS; + return NULL; +#endif +} + struct target_ops * inf_child_target (void) @@ -336,6 +369,7 @@ inf_child_target (void) t->to_fileio_pread = inf_child_fileio_pread; t->to_fileio_close = inf_child_fileio_close; t->to_fileio_unlink = inf_child_fileio_unlink; + t->to_fileio_readlink = inf_child_fileio_readlink; t->to_magic = OPS_MAGIC; return t; } |