]>
Commit | Line | Data |
---|---|---|
250b1eec SG |
1 | /* lxc_config |
2 | * | |
3 | * Copyright © 2012 Serge Hallyn <serge.hallyn@ubuntu.com>. | |
4 | * Copyright © 2012 Canonical Ltd. | |
5 | * | |
6 | * This library is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU Lesser General Public | |
8 | * License as published by the Free Software Foundation; either | |
9 | * version 2.1 of the License, or (at your option) any later version. | |
10 | ||
11 | * This library is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * Lesser General Public License for more details. | |
15 | ||
16 | * You should have received a copy of the GNU Lesser General Public | |
17 | * License along with this library; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | ||
a8428dfa | 21 | #include <stdio.h> |
95ee490b | 22 | #include <string.h> |
f2363e38 | 23 | |
948955a2 | 24 | #include <lxc/lxccontainer.h> |
a8428dfa | 25 | |
f2363e38 ÇO |
26 | #include "config.h" |
27 | ||
a8428dfa SH |
28 | struct lxc_config_items { |
29 | char *name; | |
a8428dfa SH |
30 | }; |
31 | ||
74a3920a | 32 | static struct lxc_config_items items[] = |
a8428dfa | 33 | { |
593e8478 SG |
34 | { .name = "lxc.default_config", }, |
35 | { .name = "lxc.lxcpath", }, | |
2e59ba02 SG |
36 | { .name = "lxc.bdev.lvm.vg", }, |
37 | { .name = "lxc.bdev.lvm.thin_pool", }, | |
38 | { .name = "lxc.bdev.zfs.root", }, | |
0c3720a3 KY |
39 | { .name = "lxc.cgroup.use", }, |
40 | { .name = "lxc.cgroup.pattern", }, | |
a8428dfa SH |
41 | { .name = NULL, }, |
42 | }; | |
43 | ||
74a3920a | 44 | static void usage(char *me) |
a8428dfa SH |
45 | { |
46 | printf("Usage: %s -l: list all available configuration items\n", me); | |
47 | printf(" %s item: print configuration item\n", me); | |
48 | exit(1); | |
49 | } | |
50 | ||
74a3920a | 51 | static void list_config_items(void) |
a8428dfa SH |
52 | { |
53 | struct lxc_config_items *i; | |
54 | ||
55 | for (i = &items[0]; i->name; i++) | |
56 | printf("%s\n", i->name); | |
57 | exit(0); | |
58 | } | |
59 | ||
60 | int main(int argc, char *argv[]) | |
61 | { | |
62 | struct lxc_config_items *i; | |
0c3720a3 | 63 | const char *value; |
a8428dfa SH |
64 | |
65 | if (argc < 2) | |
66 | usage(argv[0]); | |
67 | if (strcmp(argv[1], "-l") == 0) | |
68 | list_config_items(); | |
69 | for (i = &items[0]; i->name; i++) { | |
70 | if (strcmp(argv[1], i->name) == 0) { | |
0c3720a3 KY |
71 | value = lxc_get_global_config_item(i->name); |
72 | if (value) | |
73 | printf("%s\n", value); | |
74 | else | |
75 | printf("%s is not set.\n", argv[1]); | |
a8428dfa SH |
76 | exit(0); |
77 | } | |
78 | } | |
79 | printf("Unknown configuration item: %s\n", argv[1]); | |
13bc2fd2 | 80 | exit(1); |
a8428dfa | 81 | } |