gdbserver: 64-bit kernel / 32-inferior, syscall restarting
[deliverable/binutils-gdb.git] / gdb / gdbserver / hostio-errno.c
1 /* Host file transfer support for gdbserver.
2 Copyright (C) 2007-2015 Free Software Foundation, Inc.
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
10 the Free Software Foundation; either version 3 of the License, or
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
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21 /* This file implements the hostio_last_error target callback
22 on top of errno. */
23
24 #include "server.h"
25 #include "gdb/fileio.h"
26
27 static int
28 errno_to_fileio_error (int error)
29 {
30 switch (error)
31 {
32 case EPERM:
33 return FILEIO_EPERM;
34 case ENOENT:
35 return FILEIO_ENOENT;
36 case EINTR:
37 return FILEIO_EINTR;
38 case EIO:
39 return FILEIO_EIO;
40 case EBADF:
41 return FILEIO_EBADF;
42 case EACCES:
43 return FILEIO_EACCES;
44 case EFAULT:
45 return FILEIO_EFAULT;
46 case EBUSY:
47 return FILEIO_EBUSY;
48 case EEXIST:
49 return FILEIO_EEXIST;
50 case ENODEV:
51 return FILEIO_ENODEV;
52 case ENOTDIR:
53 return FILEIO_ENOTDIR;
54 case EISDIR:
55 return FILEIO_EISDIR;
56 case EINVAL:
57 return FILEIO_EINVAL;
58 case ENFILE:
59 return FILEIO_ENFILE;
60 case EMFILE:
61 return FILEIO_EMFILE;
62 case EFBIG:
63 return FILEIO_EFBIG;
64 case ENOSPC:
65 return FILEIO_ENOSPC;
66 case ESPIPE:
67 return FILEIO_ESPIPE;
68 case EROFS:
69 return FILEIO_EROFS;
70 case ENOSYS:
71 return FILEIO_ENOSYS;
72 case ENAMETOOLONG:
73 return FILEIO_ENAMETOOLONG;
74 }
75
76 return FILEIO_EUNKNOWN;
77 }
78
79 void
80 hostio_last_error_from_errno (char *buf)
81 {
82 int error = errno;
83 int fileio_error = errno_to_fileio_error (error);
84 sprintf (buf, "F-1,%x", fileio_error);
85 }
This page took 0.15431 seconds and 4 git commands to generate.