Automatic date update in version.in
[binutils-gdb.git] / gdbserver / hostio.cc
index 8af4fbf4087aa8866c21990529492ea3bbac002a..2d17b6d1a7059c83597288e81227f0bbd76cb4fa 100644 (file)
@@ -1,5 +1,5 @@
 /* Host file transfer support for gdbserver.
-   Copyright (C) 2007-2020 Free Software Foundation, Inc.
+   Copyright (C) 2007-2022 Free Software Foundation, Inc.
 
    Contributed by CodeSourcery.
 
@@ -191,12 +191,14 @@ require_valid_fd (int fd)
   return -1;
 }
 
-/* Fill in own_buf with the last hostio error packet, however it
-   suitable for the target.  */
+/* Fill BUF with an hostio error packet representing the last hostio
+   error, from errno.  */
+
 static void
 hostio_error (char *own_buf)
 {
-  the_target->hostio_last_error (own_buf);
+  int fileio_error = host_to_fileio_error (errno);
+  sprintf (own_buf, "F-1,%x", fileio_error);
 }
 
 static void
@@ -272,9 +274,7 @@ handle_setfs (char *own_buf)
      then there's no point in GDB sending "vFile:setfs:" packets.  We
      reply with an empty packet (i.e. we pretend we don't understand
      "vFile:setfs:") and that should stop GDB sending any more.  */
-  if (the_target->multifs_open == NULL
-      && the_target->multifs_unlink == NULL
-      && the_target->multifs_readlink == NULL)
+  if (!the_target->supports_multifs ())
     {
       own_buf[0] = '\0';
       return;
@@ -321,9 +321,8 @@ handle_open (char *own_buf)
 
   /* We do not need to convert MODE, since the fileio protocol
      uses the standard values.  */
-  if (hostio_fs_pid != 0 && the_target->multifs_open != NULL)
-    fd = the_target->multifs_open (hostio_fs_pid, filename,
-                                  flags, mode);
+  if (hostio_fs_pid != 0)
+    fd = the_target->multifs_open (hostio_fs_pid, filename, flags, mode);
   else
     fd = open (filename, flags, mode);
 
@@ -541,7 +540,7 @@ handle_unlink (char *own_buf)
       return;
     }
 
-  if (hostio_fs_pid != 0 && the_target->multifs_unlink != NULL)
+  if (hostio_fs_pid != 0)
     ret = the_target->multifs_unlink (hostio_fs_pid, filename);
   else
     ret = unlink (filename);
@@ -571,7 +570,7 @@ handle_readlink (char *own_buf, int *new_packet_len)
       return;
     }
 
-  if (hostio_fs_pid != 0 && the_target->multifs_readlink != NULL)
+  if (hostio_fs_pid != 0)
     ret = the_target->multifs_readlink (hostio_fs_pid, filename,
                                        linkname,
                                        sizeof (linkname) - 1);