GDBserver
|
00001 /* Host file transfer support for gdbserver. 00002 Copyright (C) 2007-2013 Free Software Foundation, Inc. 00003 00004 Contributed by CodeSourcery. 00005 00006 This file is part of GDB. 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00020 00021 /* This file implements the hostio_last_error target callback 00022 on top of errno. */ 00023 00024 #include <errno.h> 00025 #include "server.h" 00026 #include "gdb/fileio.h" 00027 00028 static int 00029 errno_to_fileio_error (int error) 00030 { 00031 switch (error) 00032 { 00033 case EPERM: 00034 return FILEIO_EPERM; 00035 case ENOENT: 00036 return FILEIO_ENOENT; 00037 case EINTR: 00038 return FILEIO_EINTR; 00039 case EIO: 00040 return FILEIO_EIO; 00041 case EBADF: 00042 return FILEIO_EBADF; 00043 case EACCES: 00044 return FILEIO_EACCES; 00045 case EFAULT: 00046 return FILEIO_EFAULT; 00047 case EBUSY: 00048 return FILEIO_EBUSY; 00049 case EEXIST: 00050 return FILEIO_EEXIST; 00051 case ENODEV: 00052 return FILEIO_ENODEV; 00053 case ENOTDIR: 00054 return FILEIO_ENOTDIR; 00055 case EISDIR: 00056 return FILEIO_EISDIR; 00057 case EINVAL: 00058 return FILEIO_EINVAL; 00059 case ENFILE: 00060 return FILEIO_ENFILE; 00061 case EMFILE: 00062 return FILEIO_EMFILE; 00063 case EFBIG: 00064 return FILEIO_EFBIG; 00065 case ENOSPC: 00066 return FILEIO_ENOSPC; 00067 case ESPIPE: 00068 return FILEIO_ESPIPE; 00069 case EROFS: 00070 return FILEIO_EROFS; 00071 case ENOSYS: 00072 return FILEIO_ENOSYS; 00073 case ENAMETOOLONG: 00074 return FILEIO_ENAMETOOLONG; 00075 } 00076 00077 return FILEIO_EUNKNOWN; 00078 } 00079 00080 void 00081 hostio_last_error_from_errno (char *buf) 00082 { 00083 int error = errno; 00084 int fileio_error = errno_to_fileio_error (error); 00085 sprintf (buf, "F-1,%x", fileio_error); 00086 }