]>
Commit | Line | Data |
---|---|---|
cc73685d | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
8173e600 | 2 | |
f1a4a029 ÇO |
3 | #ifndef __LXC_CONFILE_H |
4 | #define __LXC_CONFILE_H | |
5 | ||
1160ce89 CB |
6 | #include "config.h" |
7 | ||
861d1ada | 8 | #include <stdbool.h> |
8173e600 | 9 | #include <stdio.h> |
54fc984b | 10 | |
12ae2a33 | 11 | #include "lxc.h" |
c2cc9f0a | 12 | |
674c9692 CB |
13 | #include "compiler.h" |
14 | ||
00b3c2e2 | 15 | struct lxc_conf; |
62e46035 | 16 | struct lxc_list; |
00b3c2e2 | 17 | |
fe9b7349 CB |
18 | /* Callback prototype to set a configuration item. |
19 | * Must be implemented when adding a new configuration key. | |
20 | */ | |
3aea1a76 CB |
21 | typedef int (*config_set_cb)(const char *key, const char *value, |
22 | struct lxc_conf *conf, void *data); | |
fe9b7349 CB |
23 | |
24 | /* Callback prototype to get a configuration item. | |
25 | * Must be implemented when adding a new configuration key. | |
26 | */ | |
3aea1a76 CB |
27 | typedef int (*config_get_cb)(const char *key, char *value, int inlen, |
28 | struct lxc_conf *conf, void *data); | |
fe9b7349 CB |
29 | |
30 | /* Callback prototype to clear a configuration item. | |
31 | * Must be implemented when adding a new configuration key. | |
32 | */ | |
3aea1a76 | 33 | typedef int (*config_clr_cb)(const char *key, struct lxc_conf *conf, |
c7e27aaf | 34 | void *data); |
01f55c40 | 35 | |
7707b0e0 CB |
36 | #define LXC_CONFIG_MEMBERS \ |
37 | char *name; \ | |
38 | bool strict; \ | |
39 | config_set_cb set; \ | |
40 | config_get_cb get; \ | |
41 | config_clr_cb clr | |
42 | ||
72d0e1cb | 43 | struct lxc_config_t { |
7707b0e0 | 44 | LXC_CONFIG_MEMBERS; |
72d0e1cb SG |
45 | }; |
46 | ||
eb0c9382 | 47 | struct new_config_item { |
48 | char *key; | |
49 | char *val; | |
50 | }; | |
51 | ||
fe9b7349 | 52 | /* Get the jump table entry for the given configuration key. */ |
6eb516a7 RJ |
53 | __hidden extern struct lxc_config_t *lxc_get_config_exact(const char *key); |
54 | ||
55 | /* Get the jump table entry if entry name is a prefix of the given configuration key. */ | |
63c2a0bf | 56 | __hidden extern struct lxc_config_t *lxc_get_config(const char *key); |
01f55c40 | 57 | |
fe9b7349 | 58 | /* List all available config items. */ |
63c2a0bf | 59 | __hidden extern int lxc_list_config_items(char *retv, int inlen) |
674c9692 | 60 | __access_rw(1, 2); |
fe9b7349 CB |
61 | |
62 | /* Given a configuration key namespace (e.g. lxc.apparmor) list all associated | |
63 | * subkeys for that namespace. | |
64 | * Must be implemented when adding a new configuration key. | |
65 | */ | |
63c2a0bf CB |
66 | __hidden extern int lxc_list_subkeys(struct lxc_conf *conf, const char *key, char *retv, int inlen) |
67 | __access_rw(3, 4); | |
fe9b7349 | 68 | |
01f55c40 CB |
69 | /* List all configuration items associated with a given network. For example |
70 | * pass "lxc.net.[i]" to retrieve all configuration items associated with | |
71 | * the network associated with index [i]. | |
72 | */ | |
63c2a0bf CB |
73 | __hidden extern int lxc_list_net(struct lxc_conf *c, const char *key, char *retv, int inlen) |
74 | __access_rw(3, 4); | |
fe9b7349 | 75 | |
63c2a0bf | 76 | __hidden extern int lxc_config_read(const char *file, struct lxc_conf *conf, bool from_include); |
fe9b7349 | 77 | |
63c2a0bf | 78 | __hidden extern int append_unexp_config_line(const char *line, struct lxc_conf *conf); |
c2cc9f0a | 79 | |
63c2a0bf | 80 | __hidden extern int lxc_config_define_add(struct lxc_list *defines, char *arg); |
fe9b7349 | 81 | |
63c2a0bf | 82 | __hidden extern bool lxc_config_define_load(struct lxc_list *defines, struct lxc_container *c); |
eb0c9382 | 83 | |
63c2a0bf | 84 | __hidden extern void lxc_config_define_free(struct lxc_list *defines); |
e16dad10 | 85 | |
ee142207 CB |
86 | #define LXC_ARCH_UNCHANGED 0xffffffffL |
87 | /* | |
7c43fa56 CB |
88 | * Parse personality of the container. Returns 0 if personality is valid, |
89 | * negative errno otherwise. | |
ee142207 | 90 | */ |
7c43fa56 | 91 | __hidden extern int lxc_config_parse_arch(const char *arch, signed long *persona); |
fe9b7349 | 92 | |
d253a09f | 93 | __hidden extern int lxc_fill_elevated_privileges(char *flaglist, unsigned int *flags); |
eb0c9382 | 94 | |
63c2a0bf | 95 | __hidden extern int lxc_clear_config_item(struct lxc_conf *c, const char *key); |
fe9b7349 | 96 | |
63c2a0bf | 97 | __hidden extern int write_config(int fd, const struct lxc_conf *conf); |
6b0d5538 | 98 | |
63c2a0bf CB |
99 | __hidden extern bool do_append_unexp_config_line(struct lxc_conf *conf, const char *key, |
100 | const char *v); | |
6b0d5538 SH |
101 | |
102 | /* These are used when cloning a container */ | |
63c2a0bf | 103 | __hidden extern void clear_unexp_config_line(struct lxc_conf *conf, const char *key, bool rm_subkeys); |
fe9b7349 | 104 | |
63c2a0bf CB |
105 | __hidden extern bool clone_update_unexp_hooks(struct lxc_conf *conf, const char *oldpath, |
106 | const char *newpath, const char *oldname, | |
107 | const char *newmame); | |
fe9b7349 | 108 | |
63c2a0bf CB |
109 | __hidden extern bool clone_update_unexp_ovl_paths(struct lxc_conf *conf, const char *oldpath, |
110 | const char *newpath, const char *oldname, | |
111 | const char *newname, const char *ovldir); | |
fe9b7349 | 112 | |
63c2a0bf | 113 | __hidden extern bool network_new_hwaddrs(struct lxc_conf *conf); |
fe9b7349 | 114 | |
63c2a0bf | 115 | __hidden extern int add_elem_to_mount_list(const char *value, struct lxc_conf *lxc_conf); |
0d190408 | 116 | |
fe9b7349 | 117 | #endif /* __LXC_CONFILE_H */ |