]> git.saurik.com Git - apple/libc.git/blob - os/boot_mode_private.h
Libc-1439.100.3.tar.gz
[apple/libc.git] / os / boot_mode_private.h
1 /*
2 * Copyright (c) 2020 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21 #ifndef __OS_BOOT_MODE_H__
22 #define __OS_BOOT_MODE_H__
23
24 #include <stdbool.h>
25
26 #include <os/base.h>
27 #include <os/availability.h>
28
29 __BEGIN_DECLS
30
31 #define OS_BOOT_MODE_FVUNLOCK "fvunlock"
32 #define OS_BOOT_MODE_KCGEN "kcgen"
33 #define OS_BOOT_MODE_DIAGNOSTICS "diagnostics"
34 #define OS_BOOT_MODE_MIGRATION "migration"
35
36 /*!
37 * @function os_boot_mode_query
38 *
39 * @abstract fetches the current boot mode if available
40 *
41 * @description
42 * This attempts to query the current boot mode.
43 *
44 * In general, please prefer the _LimitLoad[To|From]BootMode launchd plist key
45 * over direct use of this SPI.
46 *
47 * CAVEATS:
48 * - this is not guaranteed to succeed when called from boot tasks (we may not
49 * have figured out our boot mode yet)
50 * - though the boot mode can in principle be an arbitrary string, this can
51 * currently only be used to query for the "fvunlock", "kcgen", "diagnostics",
52 * and "migration" boot modes
53 *
54 * @result
55 * true if the query succeeds, with boot_mode_out set to the boot mode string
56 * (or NULL if no particular boot mode). false if the boot mode is not known,
57 * in which case boot_mode_out is not modified.
58 */
59 API_AVAILABLE(macosx(10.16)) API_UNAVAILABLE(ios, tvos, watchos, bridgeos)
60 OS_EXPORT OS_WARN_RESULT
61 bool
62 os_boot_mode_query(const char **boot_mode_out);
63
64 __END_DECLS
65
66 #endif // __OS_BOOT_MODE_H__