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>
44 * Additional POSIX-flavor error codes that are meaningful to Darwin. These
45 * definitions all have a "_NP" suffix to distinguish them from POSIX error
46 * codes (meaning "not POSIX").
49 #define _ENPERR(__c) (EBASE_NP + __c)
52 * @const ENOTENTITLED_NP
53 * The remote process lacked a required entitlement to perform the operation.
55 #define ENOTENTITLED_NP _ENPERR(0)
58 * @const ENOTPLATFORM_NP
59 * The operation may only be invoked by platform binaries.
61 #define ENOTPLATFORM_NP _ENPERR(1)
65 * The operation was denied by System Integrity Protection.
67 #define EROOTLESS_NP _ENPERR(2)
71 * The operation may only be invoked by processes which are not tainted by
72 * debugging and introspection functionality (e.g. dyld(1) environment
73 * variables, debugger attachment, etc.).
75 #define ETAINTED_NP _ENPERR(3)
78 * @const EQUARANTINE_NP
79 * The operation is not permitted on quarantined file.
81 #define EQUARANTINE_NP _ENPERR(4)
85 * The operation referenced a user name or identifier that was invalid.
87 #define EBADUSER_NP _ENPERR(5)
91 * The operation referenced a group name or identifier that was invalid.
93 #define EBADGROUP_NP _ENPERR(6)
96 * @const EOWNERSHIP_NP
97 * Ownership or access permissions on a file were too permissive.
99 #define EOWNERSHIP_NP _ENPERR(7)
103 * A series of operations was executed in the improper order (no out-of-order
104 * operations allowed).
106 #define ENOOOO_NP _ENPERR(8)
109 * @const ENOTBUNDLE_NP
110 * The path given to the operation did not refer to a bundle.
112 #define ENOTBUNDLE_NP _ENPERR(9)
115 * @const EBADBUNDLE_NP
116 * The path given to the operation did not refer to a valid bundle.
118 #define EBADBUNDLE_NP _ENPERR(10)
122 * The path given to the operation was not valid.
124 #define EBADPATH_NP _ENPERR(11)
127 * @const EBADPLIST_NP
128 * The plist given to the operation was invalid.
130 #define EBADPLIST_NP _ENPERR(12)
134 * A key in the given plist was unrecognized.
136 #define EBADKEY_NP _ENPERR(13)
140 * The value for a key in the given plist was either not present (and was
141 * required to be) or was present but not of the appropriate type.
143 #define EBADVAL_NP _ENPERR(14)
147 * The request referenced a subsystem that did not exist.
149 #define EBADSUBSYS_NP _ENPERR(15)
153 * The operation has not yet been implemented.
155 #define E2BIMPL_NP _ENPERR(16)
158 * @const EDEPRECATED_NP
159 * The operation has been deprecated.
161 #define EDEPRECATED_NP _ENPERR(17)
165 * The operation has been removed from the implementation.
167 #define EREMOVED_NP _ENPERR(18)
171 * The request referenced a data structure that will never achieve the state
172 * required to perform the operation.
174 #define EDROPPED_NP _ENPERR(19)
177 * @const EDEFERRED_NP
178 * The request referenced a data structure that was not in the state required
179 * to perform the operation, and the request has been pended until the object
180 * reaches the required state. This code is meant to be used for control flow
181 * purposes in the server and should not be returned to the caller.
183 #define EDEFERRED_NP _ENPERR(20)
187 * Improper command line usage. This code is meant to be used for control flow
188 * purposes in a command line tool so that routines may return an error code
189 * indicating improper usage without having to use EX_USAGE, which collides with
190 * the POSIX error space. It should not be passed to exit(3), _exit(2), et al.
191 * and should instead be translated into EX_USAGE either directly or with
192 * {@link darwin_sysexit}.
194 #define EUSAGE_NP _ENPERR(21)
198 * An error occurred in a subsystem, and insufficient detail as to the nature of
199 * the failure was available to translate it into a more descriptive error code.
201 #define EUNKNOWN_NP _ENPERR(22)
202 #define __ELAST_NP _ENPERR(22)
205 * @const EX_BADRECEIPT_NP
206 * An exit code indicating that the program could not verify its purchase
207 * receipt from the Mac App Store. This exit code is inspected by the system to
208 * trigger a re-validation of the purchase receipt. It must be passed to the
209 * exit(3) Libc API and not to _exit(2) system call. This exit code is only
210 * relevant to the macOS variant of Darwin.
212 #define EX_BADRECEIPT_NP (173)
217 * @function sysexit_np
218 * Translates a {@link errno_t} or POSIX error code into an exit code
219 * defined in sysexits(3).
222 * The error code to translate.
225 * The sysexits(3) exit code most appropriate for the given error. If no
226 * appropriate exit code could be determined, the designated ¯\_(ツ)_/¯ exit
227 * code, EX_UNAVAILABLE, is returned (cf. sysexits(3)).
229 DARWIN_API_AVAILABLE_20170407
230 OS_EXPORT OS_WARN_RESULT OS_CONST
232 sysexit_np(int code
);
236 #endif // __DARWIN_ERRNO_H