]>
Commit | Line | Data |
---|---|---|
1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ | |
2 | ||
3 | #include <errno.h> | |
4 | ||
5 | #include "alloc-util.h" | |
6 | #include "macro.h" | |
7 | #include "parse-util.h" | |
8 | #include "proc-cmdline.h" | |
9 | #include "string-table.h" | |
10 | #include "string-util.h" | |
11 | #include "volatile-util.h" | |
12 | ||
13 | int query_volatile_mode(VolatileMode *ret) { | |
14 | _cleanup_free_ char *mode = NULL; | |
15 | int r; | |
16 | ||
17 | r = proc_cmdline_get_key("systemd.volatile", PROC_CMDLINE_VALUE_OPTIONAL, &mode); | |
18 | if (r < 0) | |
19 | return r; | |
20 | if (r == 0) { | |
21 | *ret = VOLATILE_NO; | |
22 | return 0; | |
23 | } | |
24 | ||
25 | if (mode) { | |
26 | VolatileMode m; | |
27 | ||
28 | m = volatile_mode_from_string(mode); | |
29 | if (m < 0) | |
30 | return m; | |
31 | ||
32 | *ret = m; | |
33 | } else | |
34 | *ret = VOLATILE_YES; | |
35 | ||
36 | return 1; | |
37 | } | |
38 | ||
39 | static const char* const volatile_mode_table[_VOLATILE_MODE_MAX] = { | |
40 | [VOLATILE_NO] = "no", | |
41 | [VOLATILE_YES] = "yes", | |
42 | [VOLATILE_STATE] = "state", | |
43 | [VOLATILE_OVERLAY] = "overlay", | |
44 | }; | |
45 | ||
46 | DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(volatile_mode, VolatileMode, VOLATILE_YES); |