gdb/gdbserver/hostio-errno.c - gdb

Functions defined

Source code

  1. /* Host file transfer support for gdbserver.
  2.    Copyright (C) 2007-2015 Free Software Foundation, Inc.

  3.    Contributed by CodeSourcery.

  4.    This file is part of GDB.

  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 3 of the License, or
  8.    (at your option) any later version.

  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.

  13.    You should have received a copy of the GNU General Public License
  14.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  15. /* This file implements the hostio_last_error target callback
  16.    on top of errno.  */

  17. #include "server.h"
  18. #include "gdb/fileio.h"

  19. static int
  20. errno_to_fileio_error (int error)
  21. {
  22.   switch (error)
  23.     {
  24.     case EPERM:
  25.       return FILEIO_EPERM;
  26.     case ENOENT:
  27.       return FILEIO_ENOENT;
  28.     case EINTR:
  29.       return FILEIO_EINTR;
  30.     case EIO:
  31.       return FILEIO_EIO;
  32.     case EBADF:
  33.       return FILEIO_EBADF;
  34.     case EACCES:
  35.       return FILEIO_EACCES;
  36.     case EFAULT:
  37.       return FILEIO_EFAULT;
  38.     case EBUSY:
  39.       return FILEIO_EBUSY;
  40.     case EEXIST:
  41.       return FILEIO_EEXIST;
  42.     case ENODEV:
  43.       return FILEIO_ENODEV;
  44.     case ENOTDIR:
  45.       return FILEIO_ENOTDIR;
  46.     case EISDIR:
  47.       return FILEIO_EISDIR;
  48.     case EINVAL:
  49.       return FILEIO_EINVAL;
  50.     case ENFILE:
  51.       return FILEIO_ENFILE;
  52.     case EMFILE:
  53.       return FILEIO_EMFILE;
  54.     case EFBIG:
  55.       return FILEIO_EFBIG;
  56.     case ENOSPC:
  57.       return FILEIO_ENOSPC;
  58.     case ESPIPE:
  59.       return FILEIO_ESPIPE;
  60.     case EROFS:
  61.       return FILEIO_EROFS;
  62.     case ENOSYS:
  63.       return FILEIO_ENOSYS;
  64.     case ENAMETOOLONG:
  65.       return FILEIO_ENAMETOOLONG;
  66.     }

  67.   return FILEIO_EUNKNOWN;
  68. }

  69. void
  70. hostio_last_error_from_errno (char *buf)
  71. {
  72.   int error = errno;
  73.   int fileio_error = errno_to_fileio_error (error);
  74.   sprintf (buf, "F-1,%x", fileio_error);
  75. }