]>
Commit | Line | Data |
---|---|---|
cda02a28 MN |
1 | /* |
2 | * lxc: linux Container library | |
3 | * | |
4 | * (C) Copyright IBM Corp. 2007, 2008 | |
5 | * | |
6 | * Authors: | |
9afe19d6 | 7 | * Daniel Lezcano <daniel.lezcano at free.fr> |
cda02a28 MN |
8 | * Michel Normand <normand at fr.ibm.com> |
9 | * | |
10 | * This library is free software; you can redistribute it and/or | |
11 | * modify it under the terms of the GNU Lesser General Public | |
12 | * License as published by the Free Software Foundation; either | |
13 | * version 2.1 of the License, or (at your option) any later version. | |
14 | * | |
15 | * This library is distributed in the hope that it will be useful, | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | * Lesser General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU Lesser General Public | |
21 | * License along with this library; if not, write to the Free Software | |
250b1eec | 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
cda02a28 | 23 | */ |
f1a4a029 ÇO |
24 | #ifndef __LXC_ARGUMENTS_H |
25 | #define __LXC_ARGUMENTS_H | |
cda02a28 MN |
26 | |
27 | #include <getopt.h> | |
d659597e | 28 | #include <stdint.h> |
cda02a28 MN |
29 | |
30 | struct lxc_arguments; | |
31 | ||
32 | typedef int (*lxc_arguments_parser_t) (struct lxc_arguments *, int, char*); | |
33 | typedef int (*lxc_arguments_checker_t) (const struct lxc_arguments *); | |
34 | ||
35 | struct lxc_arguments { | |
36 | const char *help; | |
f002c8a7 | 37 | void(*helpfn)(const struct lxc_arguments *); |
cda02a28 MN |
38 | const char *progname; |
39 | const struct option* options; | |
40 | lxc_arguments_parser_t parser; | |
41 | lxc_arguments_checker_t checker; | |
42 | ||
43 | const char *name; | |
44 | char *log_file; | |
45 | char *log_priority; | |
46 | int quiet; | |
c36583c3 | 47 | int daemonize; |
cda02a28 | 48 | const char *rcfile; |
829dd918 | 49 | const char *console; |
596a818d | 50 | const char *console_log; |
3114c982 | 51 | const char *pidfile; |
8d06bd13 DE |
52 | const char **lxcpath; |
53 | int lxcpath_cnt; | |
54 | /* set to 0 to accept only 1 lxcpath, -1 for unlimited */ | |
55 | int lxcpath_additional; | |
cda02a28 | 56 | |
9f30a190 | 57 | /* for lxc-start */ |
46926165 | 58 | const char *share_ns[32]; // size must be greater than LXC_NS_MAX |
9f30a190 | 59 | |
41cfbac9 MN |
60 | /* for lxc-console */ |
61 | int ttynum; | |
84a24de2 | 62 | char escape; |
41cfbac9 | 63 | |
84fbfcb4 | 64 | /* for lxc-wait */ |
41cfbac9 | 65 | char *states; |
b486346a | 66 | long timeout; |
84fbfcb4 DE |
67 | |
68 | /* for lxc-autostart */ | |
3e625e2d | 69 | int shutdown; |
41cfbac9 | 70 | |
8face1de | 71 | /* for lxc-stop */ |
84fbfcb4 DE |
72 | int hardstop; |
73 | int nokill; | |
8face1de | 74 | int nolock; |
84fbfcb4 DE |
75 | int nowait; |
76 | int reboot; | |
8face1de | 77 | |
60bf62d4 SH |
78 | /* for lxc-destroy */ |
79 | int force; | |
80 | ||
b119f362 SH |
81 | /* close fds from parent? */ |
82 | int close_all_fds; | |
83 | ||
1897e3bc SH |
84 | /* lxc-create */ |
85 | char *bdevtype, *configfile, *template; | |
86 | char *fstype; | |
d659597e | 87 | uint64_t fssize; |
f99c386b | 88 | char *lvname, *vgname, *thinpool; |
1897e3bc SH |
89 | char *zfsroot, *lowerdir, *dir; |
90 | ||
c5cd20ce PT |
91 | /* lxc-execute */ |
92 | uid_t uid; | |
93 | gid_t gid; | |
94 | ||
a6adab20 SG |
95 | /* auto-start */ |
96 | int all; | |
e582991f | 97 | int ignore_auto; |
a6adab20 SG |
98 | int list; |
99 | char *groups; | |
100 | ||
513f23df CB |
101 | /* lxc-snapshot and lxc-clone */ |
102 | enum task { | |
103 | DESTROY, | |
104 | LIST, | |
105 | RESTORE, | |
106 | SNAP, | |
107 | RENAME, | |
108 | } task; | |
109 | int print_comments; | |
110 | char *commentfile; | |
111 | char *newname; | |
112 | char *newpath; | |
113 | char *snapname; | |
114 | int keepname; | |
115 | int keepmac; | |
116 | ||
cda02a28 MN |
117 | /* remaining arguments */ |
118 | char *const *argv; | |
119 | int argc; | |
e788178a CLG |
120 | |
121 | /* private arguments */ | |
122 | void *data; | |
cda02a28 MN |
123 | }; |
124 | ||
125 | #define LXC_COMMON_OPTIONS \ | |
126 | {"name", required_argument, 0, 'n'}, \ | |
127 | {"help", no_argument, 0, 'h'}, \ | |
128 | {"usage", no_argument, 0, OPT_USAGE}, \ | |
7f12cae9 | 129 | {"version", no_argument, 0, OPT_VERSION}, \ |
cda02a28 MN |
130 | {"quiet", no_argument, 0, 'q'}, \ |
131 | {"logfile", required_argument, 0, 'o'}, \ | |
132 | {"logpriority", required_argument, 0, 'l'}, \ | |
67e571de | 133 | {"lxcpath", required_argument, 0, 'P'}, \ |
cda02a28 MN |
134 | {0, 0, 0, 0} |
135 | ||
136 | /* option keys for long only options */ | |
137 | #define OPT_USAGE 0x1000 | |
7f12cae9 | 138 | #define OPT_VERSION OPT_USAGE-1 |
cda02a28 | 139 | |
fa7eddbb | 140 | extern int lxc_arguments_parse(struct lxc_arguments *args, |
cda02a28 | 141 | int argc, char *const argv[]); |
fa7eddbb | 142 | |
501cbc71 | 143 | extern int lxc_arguments_str_to_int(struct lxc_arguments *args, const char *str); |
fa7eddbb | 144 | |
cda02a28 MN |
145 | extern const char *lxc_strerror(int errnum); |
146 | ||
147 | #define lxc_error(arg, fmt, args...) if (!(arg)->quiet) \ | |
148 | fprintf(stderr, "%s: " fmt "\n", (arg)->progname, ## args) | |
149 | ||
150 | #endif |