summaryrefslogtreecommitdiff
path: root/gdb/gdbserver/hostio.c
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2012-01-20 09:47:32 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2012-01-20 09:47:32 +0000
commitb9e7b9c3de60f6aef716ac169d82418ea27d4331 (patch)
treed50dcabd991b1b7fa639b51eba142bd39db2f4b8 /gdb/gdbserver/hostio.c
parent7313baad7c73664bed62b87481cbb078d71e84f4 (diff)
downloadbinutils-gdb-b9e7b9c3de60f6aef716ac169d82418ea27d4331.tar.gz
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/gdbserver/hostio.c')
-rw-r--r--gdb/gdbserver/hostio.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c
index b1508ec3bab..34e4fa8e09e 100644
--- a/gdb/gdbserver/hostio.c
+++ b/gdb/gdbserver/hostio.c
@@ -456,6 +456,37 @@ handle_unlink (char *own_buf)
hostio_reply (own_buf, ret);
}
+static void
+handle_readlink (char *own_buf, int *new_packet_len)
+{
+ char filename[PATH_MAX], linkname[PATH_MAX];
+ char *p;
+ int ret, bytes_sent;
+
+ p = own_buf + strlen ("vFile:readlink:");
+
+ if (require_filename (&p, filename)
+ || require_end (p))
+ {
+ hostio_packet_error (own_buf);
+ return;
+ }
+
+ ret = readlink (filename, linkname, sizeof linkname);
+ if (ret == -1)
+ {
+ hostio_error (own_buf);
+ return;
+ }
+
+ bytes_sent = hostio_reply_with_data (own_buf, linkname, ret, new_packet_len);
+
+ /* If the response does not fit into a single packet, do not attempt
+ to return a partial response, but simply fail. */
+ if (bytes_sent < ret)
+ sprintf (own_buf, "F-1,%x", FILEIO_ENAMETOOLONG);
+}
+
/* Handle all the 'F' file transfer packets. */
int
@@ -471,6 +502,8 @@ handle_vFile (char *own_buf, int packet_len, int *new_packet_len)
handle_close (own_buf);
else if (strncmp (own_buf, "vFile:unlink:", 13) == 0)
handle_unlink (own_buf);
+ else if (strncmp (own_buf, "vFile:readlink:", 15) == 0)
+ handle_readlink (own_buf, new_packet_len);
else
return 0;