]>
Commit | Line | Data |
---|---|---|
cc73685d | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
250b1eec | 2 | |
d38dd64a CB |
3 | #ifndef _GNU_SOURCE |
4 | #define _GNU_SOURCE 1 | |
5 | #endif | |
a8428dfa | 6 | #include <stdio.h> |
95ee490b | 7 | #include <string.h> |
f2363e38 | 8 | |
12ae2a33 | 9 | #include "lxc.h" |
a8428dfa | 10 | |
d38dd64a CB |
11 | #include "config.h" |
12 | ||
a8428dfa SH |
13 | struct lxc_config_items { |
14 | char *name; | |
a8428dfa SH |
15 | }; |
16 | ||
74a3920a | 17 | static struct lxc_config_items items[] = |
a8428dfa | 18 | { |
593e8478 SG |
19 | { .name = "lxc.default_config", }, |
20 | { .name = "lxc.lxcpath", }, | |
2e59ba02 SG |
21 | { .name = "lxc.bdev.lvm.vg", }, |
22 | { .name = "lxc.bdev.lvm.thin_pool", }, | |
23 | { .name = "lxc.bdev.zfs.root", }, | |
0c3720a3 KY |
24 | { .name = "lxc.cgroup.use", }, |
25 | { .name = "lxc.cgroup.pattern", }, | |
a8428dfa SH |
26 | { .name = NULL, }, |
27 | }; | |
28 | ||
74a3920a | 29 | static void usage(char *me) |
a8428dfa SH |
30 | { |
31 | printf("Usage: %s -l: list all available configuration items\n", me); | |
32 | printf(" %s item: print configuration item\n", me); | |
f0c6ee28 | 33 | exit(EXIT_SUCCESS); |
a8428dfa SH |
34 | } |
35 | ||
74a3920a | 36 | static void list_config_items(void) |
a8428dfa SH |
37 | { |
38 | struct lxc_config_items *i; | |
39 | ||
40 | for (i = &items[0]; i->name; i++) | |
41 | printf("%s\n", i->name); | |
b27cdf66 | 42 | |
f0c6ee28 | 43 | exit(EXIT_SUCCESS); |
a8428dfa SH |
44 | } |
45 | ||
46 | int main(int argc, char *argv[]) | |
47 | { | |
48 | struct lxc_config_items *i; | |
0c3720a3 | 49 | const char *value; |
a8428dfa | 50 | |
dc71fcca | 51 | if (argc < 2 || strncmp(argv[1], "-h", strlen(argv[1])) == 0 || |
52 | strncmp(argv[1], "--help", strlen(argv[1])) == 0) | |
a8428dfa | 53 | usage(argv[0]); |
b27cdf66 | 54 | |
dc71fcca | 55 | if (strncmp(argv[1], "-l", strlen(argv[1])) == 0) |
a8428dfa | 56 | list_config_items(); |
b27cdf66 | 57 | |
a8428dfa | 58 | for (i = &items[0]; i->name; i++) { |
dc71fcca | 59 | if (strncmp(argv[1], i->name, strlen(argv[1])) == 0) { |
0c3720a3 KY |
60 | value = lxc_get_global_config_item(i->name); |
61 | if (value) | |
62 | printf("%s\n", value); | |
63 | else | |
64 | printf("%s is not set.\n", argv[1]); | |
b27cdf66 | 65 | |
b52b0595 | 66 | exit(EXIT_SUCCESS); |
a8428dfa SH |
67 | } |
68 | } | |
b27cdf66 | 69 | |
a8428dfa | 70 | printf("Unknown configuration item: %s\n", argv[1]); |
b52b0595 | 71 | exit(EXIT_FAILURE); |
a8428dfa | 72 | } |