Asylo
posix_error_space.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2017 Asylo authors
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef ASYLO_UTIL_POSIX_ERROR_SPACE_H_
20 #define ASYLO_UTIL_POSIX_ERROR_SPACE_H_
21 
22 #include <errno.h>
23 
24 #include <cerrno>
25 #include <string>
26 
27 #include "absl/base/macros.h"
28 #include "asylo/util/error_space.h"
29 
30 namespace asylo {
31 namespace error {
32 
33 /// The enum associated with the POSIX error-space. To avoid conflict with the
34 /// macros defined in the <cerrno> system header, all the codes in this enum are
35 /// prefixed with a "P_".
36 ///
37 /// \deprecated Deprecated as part of Asylo's `absl::Status` migration. Use the
38 /// functions from asylo/util/posix_errors.h or the matchers from
39 /// asylo/util/posix_error_matchers.h instead.
41  "Deprecated as part of Asylo's absl::Status migration. Use the functions "
42  "from asylo/util/posix_errors.h or the matchers from "
43  "asylo/util/posix_error_matchers.h instead.") PosixError {
44  P_E2BIG = E2BIG,
45  P_EACCES = EACCES,
46  P_EADDRINUSE = EADDRINUSE,
47  P_EADDRNOTAVAIL = EADDRNOTAVAIL,
48  P_EAFNOSUPPORT = EAFNOSUPPORT,
49  P_EAGAIN = EAGAIN,
50  P_EALREADY = EALREADY,
51  P_EBADF = EBADF,
52  P_EBADMSG = EBADMSG,
53  P_EBUSY = EBUSY,
54  P_ECANCELED = ECANCELED,
55  P_ECHILD = ECHILD,
56  P_ECONNABORTED = ECONNABORTED,
57  P_ECONNREFUSED = ECONNREFUSED,
58  P_ECONNRESET = ECONNRESET,
59  P_EDEADLK = EDEADLK,
60  P_EDESTADDRREQ = EDESTADDRREQ,
61  P_EDOM = EDOM,
62  P_EDQUOT = EDQUOT,
63  P_EEXIST = EEXIST,
64  P_EFAULT = EFAULT,
65  P_EFBIG = EFBIG,
66  P_EHOSTUNREACH = EHOSTUNREACH,
67  P_EIDRM = EIDRM,
68  P_EILSEQ = EILSEQ,
69  P_EINPROGRESS = EINPROGRESS,
70  P_EINTR = EINTR,
71  P_EINVAL = EINVAL,
72  P_EIO = EIO,
73  P_EISCONN = EISCONN,
74  P_EISDIR = EISDIR,
75  P_ELOOP = ELOOP,
76  P_EMFILE = EMFILE,
77  P_EMLINK = EMLINK,
78  P_EMSGSIZE = EMSGSIZE,
79  P_EMULTIHOP = EMULTIHOP,
80  P_ENAMETOOLONG = ENAMETOOLONG,
81  P_ENETDOWN = ENETDOWN,
82  P_ENETRESET = ENETRESET,
83  P_ENETUNREACH = ENETUNREACH,
84  P_ENFILE = ENFILE,
85  P_ENOBUFS = ENOBUFS,
86  P_ENODATA = ENODATA,
87  P_ENODEV = ENODEV,
88  P_ENOENT = ENOENT,
89  P_ENOEXEC = ENOEXEC,
90  P_ENOLCK = ENOLCK,
91  P_ENOLINK = ENOLINK,
92  P_ENOMEM = ENOMEM,
93  P_ENOMSG = ENOMSG,
94  P_ENOPROTOOPT = ENOPROTOOPT,
95  P_ENOSPC = ENOSPC,
96  P_ENOSR = ENOSR,
97  P_ENOSTR = ENOSTR,
98  P_ENOSYS = ENOSYS,
99  P_ENOTCONN = ENOTCONN,
100  P_ENOTDIR = ENOTDIR,
101  P_ENOTEMPTY = ENOTEMPTY,
102  P_ENOTRECOVERABLE = ENOTRECOVERABLE,
103  P_ENOTSOCK = ENOTSOCK,
104  P_ENOTSUP = ENOTSUP,
105  P_ENOTTY = ENOTTY,
106  P_ENXIO = ENXIO,
107  // P_EOPNOTSUPP: Linux aliases this. Use P_ENOTSUP instead.
108  P_EOVERFLOW = EOVERFLOW,
109  P_EOWNERDEAD = EOWNERDEAD,
110  P_EPERM = EPERM,
111  P_EPIPE = EPIPE,
112  P_EPROTO = EPROTO,
113  P_EPROTONOSUPPORT = EPROTONOSUPPORT,
114  P_EPROTOTYPE = EPROTOTYPE,
115  P_ERANGE = ERANGE,
116  P_EROFS = EROFS,
117  P_ESPIPE = ESPIPE,
118  P_ESRCH = ESRCH,
119  P_ESTALE = ESTALE,
120  P_ETIME = ETIME,
121  P_ETIMEDOUT = ETIMEDOUT,
122  P_ETXTBSY = ETXTBSY,
123  // P_EWOULDBLOCK: Linux aliases this. Use P_EAGAIN instead.
124  P_EXDEV = EXDEV
125 };
126 
127 /// Binds the PosixErrorSpace class to the PosixError enum.
128 ///
129 /// \deprecated Deprecated as part of Asylo's `absl::Status` migration. Use the
130 /// functions from asylo/util/posix_errors.h or the matchers from
131 /// asylo/util/posix_error_matchers.h instead.
133  "Deprecated as part of Asylo's absl::Status migration. Use the functions "
134  "from asylo/util/posix_errors.h or the matchers from "
135  "asylo/util/posix_error_matchers.h instead.")
137 
138 /// An implementation of the ErrorSpace interface for POSIX error codes.
139 ///
140 /// \deprecated Deprecated as part of Asylo's `absl::Status` migration. Use the
141 /// functions from asylo/util/posix_errors.h or the matchers from
142 /// asylo/util/posix_error_matchers.h instead.
143 class ABSL_DEPRECATED(
144  "Deprecated as part of Asylo's absl::Status migration. Use the functions "
145  "from asylo/util/posix_errors.h or the matchers from "
146  "asylo/util/posix_error_matchers.h instead.") PosixErrorSpace
148  public:
149  using code_type = PosixError;
150 
151  PosixErrorSpace(const PosixErrorSpace &other) = delete;
152  virtual ~PosixErrorSpace() = default;
153  PosixErrorSpace &operator=(const PosixErrorSpace &other) = delete;
154 
155  /// Gets the singleton instance of PosixErrorSpace.
156  /// \return The one instance of PosixErrorSpace.
157  static ErrorSpace const *GetInstance();
158 
159  private:
160  PosixErrorSpace();
162 };
163 
164 } // namespace error
165 } // namespace asylo
166 
167 #endif // ASYLO_UTIL_POSIX_ERROR_SPACE_H_
Definition: error_space.h:37
ABSL_CONST_INIT const char kStatusMoveAssignmentMsg[]