Commit | Line | Data |
---|---|---|
59a016f0 | 1 | /* Host file transfer support for gdbserver. |
ecd75fc8 | 2 | Copyright (C) 2007-2014 Free Software Foundation, Inc. |
59a016f0 PA |
3 | |
4 | Contributed by CodeSourcery. | |
5 | ||
6 | This file is part of GDB. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
32de4b9d | 10 | the Free Software Foundation; either version 3 of the License, or |
59a016f0 PA |
11 | (at your option) any later version. |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
32de4b9d | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
59a016f0 PA |
20 | |
21 | /* This file implements the hostio_last_error target callback | |
22 | on top of errno. */ | |
23 | ||
24 | #include <errno.h> | |
25 | #include "server.h" | |
26 | #include "gdb/fileio.h" | |
27 | ||
28 | static int | |
29 | errno_to_fileio_error (int error) | |
30 | { | |
31 | switch (error) | |
32 | { | |
33 | case EPERM: | |
34 | return FILEIO_EPERM; | |
35 | case ENOENT: | |
36 | return FILEIO_ENOENT; | |
37 | case EINTR: | |
38 | return FILEIO_EINTR; | |
39 | case EIO: | |
40 | return FILEIO_EIO; | |
41 | case EBADF: | |
42 | return FILEIO_EBADF; | |
43 | case EACCES: | |
44 | return FILEIO_EACCES; | |
45 | case EFAULT: | |
46 | return FILEIO_EFAULT; | |
47 | case EBUSY: | |
48 | return FILEIO_EBUSY; | |
49 | case EEXIST: | |
50 | return FILEIO_EEXIST; | |
51 | case ENODEV: | |
52 | return FILEIO_ENODEV; | |
53 | case ENOTDIR: | |
54 | return FILEIO_ENOTDIR; | |
55 | case EISDIR: | |
56 | return FILEIO_EISDIR; | |
57 | case EINVAL: | |
58 | return FILEIO_EINVAL; | |
59 | case ENFILE: | |
60 | return FILEIO_ENFILE; | |
61 | case EMFILE: | |
62 | return FILEIO_EMFILE; | |
63 | case EFBIG: | |
64 | return FILEIO_EFBIG; | |
65 | case ENOSPC: | |
66 | return FILEIO_ENOSPC; | |
67 | case ESPIPE: | |
68 | return FILEIO_ESPIPE; | |
69 | case EROFS: | |
70 | return FILEIO_EROFS; | |
71 | case ENOSYS: | |
72 | return FILEIO_ENOSYS; | |
73 | case ENAMETOOLONG: | |
74 | return FILEIO_ENAMETOOLONG; | |
75 | } | |
76 | ||
77 | return FILEIO_EUNKNOWN; | |
78 | } | |
79 | ||
80 | void | |
81 | hostio_last_error_from_errno (char *buf) | |
82 | { | |
83 | int error = errno; | |
84 | int fileio_error = errno_to_fileio_error (error); | |
85 | sprintf (buf, "F-1,%x", fileio_error); | |
86 | } |