]>
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 SH |
21 | #include <stdio.h> |
22 | #include "config.h" | |
23 | #include "lxccontainer.h" | |
24 | ||
25 | struct lxc_config_items { | |
26 | char *name; | |
27 | const char *(*fn)(void); | |
28 | }; | |
29 | ||
30 | struct lxc_config_items items[] = | |
31 | { | |
32 | { .name = "lxcpath", .fn = &lxc_get_default_config_path, }, | |
33 | { .name = "lvm_vg", .fn = &lxc_get_default_lvm_vg, }, | |
34 | { .name = "zfsroot", .fn = &lxc_get_default_zfs_root, }, | |
35 | { .name = NULL, }, | |
36 | }; | |
37 | ||
38 | void usage(char *me) | |
39 | { | |
40 | printf("Usage: %s -l: list all available configuration items\n", me); | |
41 | printf(" %s item: print configuration item\n", me); | |
42 | exit(1); | |
43 | } | |
44 | ||
45 | void list_config_items(void) | |
46 | { | |
47 | struct lxc_config_items *i; | |
48 | ||
49 | for (i = &items[0]; i->name; i++) | |
50 | printf("%s\n", i->name); | |
51 | exit(0); | |
52 | } | |
53 | ||
54 | int main(int argc, char *argv[]) | |
55 | { | |
56 | struct lxc_config_items *i; | |
57 | ||
58 | if (argc < 2) | |
59 | usage(argv[0]); | |
60 | if (strcmp(argv[1], "-l") == 0) | |
61 | list_config_items(); | |
62 | for (i = &items[0]; i->name; i++) { | |
63 | if (strcmp(argv[1], i->name) == 0) { | |
64 | printf("%s\n", i->fn()); | |
65 | exit(0); | |
66 | } | |
67 | } | |
68 | printf("Unknown configuration item: %s\n", argv[1]); | |
69 | exit(-1); | |
70 | } |