F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
error.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Os/Posix/error.cpp
3 // \brief implementation for posix errno conversion
4 // ======================================================================
5 #include <cerrno>
6 #include "Os/Posix/error.hpp"
7 
8 namespace Os {
9 namespace Posix {
10 
13  switch (errno_input) {
14  case 0:
15  status = File::Status::OP_OK;
16  break;
17  // Fallthrough intended
18  case ENOSPC:
19  case EFBIG:
20  status = File::Status::NO_SPACE;
21  break;
22  case ENOENT:
23  status = File::Status::DOESNT_EXIST;
24  break;
25  // Fallthrough intended
26  case EPERM:
27  case EACCES:
28  status = File::Status::NO_PERMISSION;
29  break;
30  case EEXIST:
31  status = File::Status::FILE_EXISTS;
32  break;
33  case EBADF:
34  status = File::Status::NOT_OPENED;
35  break;
36  // Fallthrough intended
37  case ENOSYS:
38  case EOPNOTSUPP:
39  status = File::Status::NOT_SUPPORTED;
40  break;
41  case EINVAL:
42  status = File::Status::INVALID_ARGUMENT;
43  break;
44  default:
46  break;
47  }
48  return status;
49 }
50 
53  switch (errno_input) {
54  case 0:
56  break;
57  // All fall through are intended to fallback on OTHER_ERROR
58  case EACCES:
59  status = FileSystem::Status::NO_PERMISSION;
60  break;
61  case EPERM:
62  case EROFS:
63  case EFAULT:
64  status = FileSystem::Status::NO_PERMISSION;
65  break;
66  case EEXIST:
67  status = FileSystem::Status::ALREADY_EXISTS;
68  break;
69  case ELOOP:
70  case ENOENT:
71  status = FileSystem::Status::DOESNT_EXIST;
72  break;
73  case ENAMETOOLONG:
74  status = FileSystem::Status::INVALID_PATH;
75  break;
76  case ENOTDIR:
77  status = FileSystem::Status::NOT_DIR;
78  break;
79  case EDQUOT:
81  break;
82  case EMLINK:
83  status = FileSystem::Status::FILE_LIMIT;
84  break;
85  case ENOSPC:
86  case EFBIG:
88  break;
89  case ENOSYS:
90  case EOPNOTSUPP:
91  status = FileSystem::Status::NOT_SUPPORTED;
92  break;
93  case ERANGE:
94  status = FileSystem::Status::BUFFER_TOO_SMALL;
95  break;
96  case EXDEV:
97  status = FileSystem::Status::EXDEV_ERROR;
98  break;
99  default:
101  break;
102  }
103  return status;
104 }
105 
108  switch (errno_input) {
109  case 0:
110  status = Directory::Status::OP_OK;
111  break;
112  case ENOENT:
113  status = Directory::Status::DOESNT_EXIST;
114  break;
115  case EACCES:
116  status = Directory::Status::NO_PERMISSION;
117  break;
118  case ENOTDIR:
119  status = Directory::Status::NOT_DIR;
120  break;
121  case EEXIST:
122  status = Directory::Status::ALREADY_EXISTS;
123  break;
124  default:
126  break;
127  }
128  return status;
129 }
130 
133  switch (errno_input) {
134  case 0:
135  status = RawTime::Status::OP_OK;
136  break;
137  case EINVAL:
138  status = RawTime::Status::INVALID_PARAMS;
139  break;
140  default:
142  break;
143  }
144  return status;
145 }
146 
149  switch (posix_status) {
150  case 0:
151  status = Task::Status::OP_OK;
152  break;
153  case EINVAL:
154  status = Task::Status::INVALID_PARAMS;
155  break;
156  case EPERM:
157  status = Task::Status::ERROR_PERMISSION;
158  break;
159  case EAGAIN:
160  status = Task::Status::ERROR_RESOURCES;
161  break;
162  default:
163  status = Task::Status::UNKNOWN_ERROR;
164  break;
165  }
166  return status;
167 }
168 
170  Mutex::Status status = Mutex::Status::ERROR_OTHER;
171  switch (posix_status) {
172  case 0:
173  status = Mutex::Status::OP_OK;
174  break;
175  case EBUSY:
176  status = Mutex::Status::ERROR_BUSY;
177  break;
178  case EDEADLK:
179  status = Mutex::Status::ERROR_DEADLOCK;
180  break;
181  default:
182  status = Mutex::Status::ERROR_OTHER;
183  break;
184  }
185  return status;
186 }
187 }
188 }
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
@ OP_OK
Operation succeeded.
Definition: Os.hpp:26
File::Status errno_to_file_status(PlatformIntType errno_input)
Definition: error.cpp:11
Directory::Status errno_to_directory_status(PlatformIntType errno_input)
Definition: error.cpp:106
FileSystem::Status errno_to_filesystem_status(PlatformIntType errno_input)
Definition: error.cpp:51
Task::Status posix_status_to_task_status(PlatformIntType posix_status)
Definition: error.cpp:147
Mutex::Status posix_status_to_mutex_status(PlatformIntType posix_status)
Definition: error.cpp:169
RawTime::Status errno_to_rawtime_status(PlatformIntType errno_input)
Definition: error.cpp:131
@ OTHER_ERROR
A catch-all for other errors. Have to look in implementation-specific code.
@ NO_SPACE
No space left on the device for writing.