2 * Copyright (c) 2018 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 * Non-standard, Darwin-specific additions to the error codes enumerated in
27 * intro(2) and sys/errno.h.
29 #ifndef __DARWIN_ERRNO_H
30 #define __DARWIN_ERRNO_H
34 #include <sys/errno.h>
35 #include <sys/cdefs.h>
40 * Additional POSIX-flavor error codes that are meaningful to Darwin. These
41 * definitions all have a "_NP" suffix to distinguish them from POSIX error
42 * codes (meaning "not POSIX").
45 #define _ENPERR(__c) (EBASE_NP + __c)
48 * @const ENOTENTITLED_NP
49 * The remote process lacked a required entitlement to perform the operation.
51 #define ENOTENTITLED_NP _ENPERR(0)
54 * @const ENOTPLATFORM_NP
55 * The operation may only be invoked by platform binaries.
57 #define ENOTPLATFORM_NP _ENPERR(1)
61 * The operation was denied by System Integrity Protection.
63 #define EROOTLESS_NP _ENPERR(2)
67 * The operation may only be invoked by processes which are not tainted by
68 * debugging and introspection functionality (e.g. dyld(1) environment
69 * variables, debugger attachment, etc.).
71 #define ETAINTED_NP _ENPERR(3)
74 * @const EQUARANTINE_NP
75 * The operation is not permitted on quarantined file.
77 #define EQUARANTINE_NP _ENPERR(4)
81 * The operation referenced a user name or identifier that was invalid.
83 #define EBADUSER_NP _ENPERR(5)
87 * The operation referenced a group name or identifier that was invalid.
89 #define EBADGROUP_NP _ENPERR(6)
92 * @const EOWNERSHIP_NP
93 * Ownership or access permissions on a file were too permissive.
95 #define EOWNERSHIP_NP _ENPERR(7)
99 * A series of operations was executed in the improper order (no out-of-order
100 * operations allowed).
102 #define ENOOOO_NP _ENPERR(8)
105 * @const ENOTBUNDLE_NP
106 * The path given to the operation did not refer to a bundle.
108 #define ENOTBUNDLE_NP _ENPERR(9)
111 * @const EBADBUNDLE_NP
112 * The path given to the operation did not refer to a valid bundle.
114 #define EBADBUNDLE_NP _ENPERR(10)
118 * The path given to the operation was not valid.
120 #define EBADPATH_NP _ENPERR(11)
123 * @const EBADPLIST_NP
124 * The plist given to the operation was invalid.
126 #define EBADPLIST_NP _ENPERR(12)
130 * A key in the given plist was unrecognized.
132 #define EBADKEY_NP _ENPERR(13)
136 * The value for a key in the given plist was either not present (and was
137 * required to be) or was present but not of the appropriate type.
139 #define EBADVAL_NP _ENPERR(14)
143 * The request referenced a subsystem that did not exist.
145 #define EBADSUBSYS_NP _ENPERR(15)
149 * The operation has not yet been implemented.
151 #define E2BIMPL_NP _ENPERR(16)
154 * @const EDEPRECATED_NP
155 * The operation has been deprecated.
157 #define EDEPRECATED_NP _ENPERR(17)
161 * The operation has been removed from the implementation.
163 #define EREMOVED_NP _ENPERR(18)
167 * The request referenced a data structure that will never achieve the state
168 * required to perform the operation.
170 #define EDROPPED_NP _ENPERR(19)
173 * @const EDEFERRED_NP
174 * The request referenced a data structure that was not in the state required
175 * to perform the operation, and the request has been pended until the object
176 * reaches the required state. This code is meant to be used for control flow
177 * purposes in the server and should not be returned to the caller.
179 #define EDEFERRED_NP _ENPERR(20)
183 * Improper command line usage. This code is meant to be used for control flow
184 * purposes in a command line tool so that routines may return an error code
185 * indicating improper usage without having to use EX_USAGE, which collides with
186 * the POSIX error space. It should not be passed to exit(3), _exit(2), et al.
187 * and should instead be translated into EX_USAGE either directly or with
188 * {@link darwin_sysexit}.
190 #define EUSAGE_NP _ENPERR(21)
194 * An error occurred in a subsystem, and insufficient detail as to the nature of
195 * the failure was available to translate it into a more descriptive error code.
197 #define EUNKNOWN_NP _ENPERR(22)
198 #define __ELAST_NP _ENPERR(22)
201 * @const EX_BADRECEIPT_NP
202 * An exit code indicating that the program could not verify its purchase
203 * receipt from the Mac App Store. This exit code is inspected by the system to
204 * trigger a re-validation of the purchase receipt. It must be passed to the
205 * exit(3) Libc API and not to _exit(2) system call. This exit code is only
206 * relevant to the macOS variant of Darwin.
208 #define EX_BADRECEIPT_NP (173)
213 * @function sysexit_np
214 * Translates a {@link errno_t} or POSIX error code into an exit code
215 * defined in sysexits(3).
218 * The error code to translate.
221 * The sysexits(3) exit code most appropriate for the given error. If no
222 * appropriate exit code could be determined, the designated ¯\_(ツ)_/¯ exit
223 * code, EX_UNAVAILABLE, is returned (cf. sysexits(3)).
225 DARWIN_API_AVAILABLE_20170407
226 OS_EXPORT OS_WARN_RESULT OS_CONST
228 sysexit_np(int code
);
232 #endif // __DARWIN_ERRNO_H