2 * lxc: linux Container library
4 * (C) Copyright IBM Corp. 2007, 2008
7 * Daniel Lezcano <daniel.lezcano at free.fr>
8 * Michel Normand <normand at fr.ibm.com>
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.
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.
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
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #ifndef __LXC_ARGUMENTS_H
26 #define __LXC_ARGUMENTS_H
31 #include <sys/param.h>
32 #include <sys/types.h>
34 #include <lxc/lxccontainer.h>
38 typedef int (*lxc_arguments_parser_t
)(struct lxc_arguments
*, int, char *);
39 typedef int (*lxc_arguments_checker_t
)(const struct lxc_arguments
*);
41 struct lxc_arguments
{
43 void (*helpfn
)(const struct lxc_arguments
*);
45 const struct option
*options
;
46 lxc_arguments_parser_t parser
;
47 lxc_arguments_checker_t checker
;
56 const char *console_log
;
60 /* set to 0 to accept only 1 lxcpath, -1 for unlimited */
61 int lxcpath_additional
;
64 const char *share_ns
[32]; /* size must be greater than LXC_NS_MAX */
74 /* for lxc-autostart */
87 /* close fds from parent? */
91 char *bdevtype
, *configfile
, *template;
94 char *lvname
, *vgname
, *thinpool
;
95 char *rbdname
, *rbdpool
;
96 char *zfsroot
, *lowerdir
, *dir
;
98 /* lxc-execute and lxc-unshare */
106 char *groups
; /* also used by lxc-ls */
108 /* lxc-snapshot and lxc-copy */
128 char *ls_fancy_format
;
130 unsigned int ls_nesting
; /* maximum allowed nesting level */
144 int want_default_mounts
;
145 const char *want_hostname
;
148 /* remaining arguments */
152 /* private arguments */
156 #define LXC_COMMON_OPTIONS \
157 { "name", required_argument, 0, 'n' }, \
158 { "help", no_argument, 0, 'h' }, \
159 { "usage", no_argument, 0, OPT_USAGE }, \
160 { "version", no_argument, 0, OPT_VERSION }, \
161 { "quiet", no_argument, 0, 'q' }, \
162 { "logfile", required_argument, 0, 'o' }, \
163 { "logpriority", required_argument, 0, 'l' }, \
164 { "lxcpath", required_argument, 0, 'P' }, \
165 { "rcfile", required_argument, 0, OPT_RCFILE }, \
168 /* option keys for long only options */
169 #define OPT_USAGE 0x1000
170 #define OPT_VERSION OPT_USAGE - 1
171 #define OPT_RCFILE OPT_USAGE - 2
172 #define OPT_SHARE_NET OPT_USAGE - 3
173 #define OPT_SHARE_IPC OPT_USAGE - 4
174 #define OPT_SHARE_UTS OPT_USAGE - 5
175 #define OPT_SHARE_PID OPT_USAGE - 6
177 extern int lxc_arguments_parse(struct lxc_arguments
*args
, int argc
,
180 extern int lxc_arguments_str_to_int(struct lxc_arguments
*args
,
183 extern bool lxc_setup_shared_ns(struct lxc_arguments
*args
, struct lxc_container
*c
);
185 #define lxc_info(arg, fmt, args...) \
187 if (!(arg)->quiet) { \
188 fprintf(stdout, "%s: " fmt "\n", (arg)->progname, ##args); \
192 #define lxc_error(arg, fmt, args...) \
194 if (!(arg)->quiet) { \
195 fprintf(stderr, "%s: " fmt "\n", (arg)->progname, ##args); \
199 #define lxc_sys_error(arg, fmt, args...) \
201 if (!(arg)->quiet) { \
202 fprintf(stderr, "%s: " fmt "\n", (arg)->progname, ##args); \
206 #endif /* __LXC_ARGUMENTS_H */