diff options
author | Andrew Burgess <aburgess@redhat.com> | 2024-05-21 15:58:41 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2024-07-18 13:24:20 +0100 |
commit | 6d45af96ea53daffea125ffb9ef5f070a159c674 (patch) | |
tree | 74400fe00fed62354db0690bf80fc4343d07e3ce /gdbserver | |
parent | 3055e3d2f13bb84db90b9c19d427c362053775d2 (diff) | |
download | gdb-6d45af96ea53daffea125ffb9ef5f070a159c674.zip gdb-6d45af96ea53daffea125ffb9ef5f070a159c674.tar.gz gdb-6d45af96ea53daffea125ffb9ef5f070a159c674.tar.bz2 |
gdbserver: add gdbserver support for vFile::stat packet
After the previous two commits, this commit adds support for the
vFile::stat packet to gdbserver. This is pretty similar to the
handling for vFile::fstat, but instead calls 'lstat'.
There's still no users of target_fileio_stat in GDB, that will come in
a later commit.
Diffstat (limited to 'gdbserver')
-rw-r--r-- | gdbserver/hostio.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gdbserver/hostio.cc b/gdbserver/hostio.cc index c5ae35a..cc47d68 100644 --- a/gdbserver/hostio.cc +++ b/gdbserver/hostio.cc @@ -487,6 +487,42 @@ handle_fstat (char *own_buf, int *new_packet_len) } static void +handle_stat (char *own_buf, int *new_packet_len) +{ + int bytes_sent; + char *p; + struct stat st; + struct fio_stat fst; + char filename[HOSTIO_PATH_MAX]; + + p = own_buf + strlen ("vFile:stat:"); + + if (require_filename (&p, filename) + || require_end (p)) + { + hostio_packet_error (own_buf); + return; + } + + if (lstat (filename, &st) == -1) + { + hostio_error (own_buf); + return; + } + + host_to_fileio_stat (&st, &fst); + + bytes_sent = hostio_reply_with_data (own_buf, + (char *) &fst, sizeof (fst), + 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 < sizeof (fst)) + write_enn (own_buf); +} + +static void handle_close (char *own_buf) { int fd, ret; @@ -603,6 +639,8 @@ handle_vFile (char *own_buf, int packet_len, int *new_packet_len) handle_pwrite (own_buf, packet_len); else if (startswith (own_buf, "vFile:fstat:")) handle_fstat (own_buf, new_packet_len); + else if (startswith (own_buf, "vFile:stat:")) + handle_stat (own_buf, new_packet_len); else if (startswith (own_buf, "vFile:close:")) handle_close (own_buf); else if (startswith (own_buf, "vFile:unlink:")) |