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