]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/lxc_config.c
ovl_rsync: make sure to umount
[mirror_lxc.git] / src / lxc / lxc_config.c
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
21 #include <stdio.h>
22 #include <string.h>
23
24 #include <lxc/lxccontainer.h>
25
26 #include "config.h"
27
28 struct lxc_config_items {
29 char *name;
30 };
31
32 static struct lxc_config_items items[] =
33 {
34 { .name = "lxc.default_config", },
35 { .name = "lxc.lxcpath", },
36 { .name = "lxc.bdev.lvm.vg", },
37 { .name = "lxc.bdev.lvm.thin_pool", },
38 { .name = "lxc.bdev.zfs.root", },
39 { .name = "lxc.cgroup.use", },
40 { .name = "lxc.cgroup.pattern", },
41 { .name = NULL, },
42 };
43
44 static void usage(char *me)
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
51 static void list_config_items(void)
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;
63 const char *value;
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) {
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]);
76 exit(0);
77 }
78 }
79 printf("Unknown configuration item: %s\n", argv[1]);
80 exit(1);
81 }