mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-07 22:39:41 +00:00
cleanup lxc-init
Make some cleanup around the parameters of lxc-init. The option mount procfs is not needed as we want to do that all the time. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
parent
0d9f8e188c
commit
e46ac65175
@ -105,8 +105,7 @@ int main(int argc, char *argv[])
|
|||||||
autodestroy = 1;
|
autodestroy = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lxc-init --mount-procfs -- .... */
|
args = alloca((my_args.argc + 3)*sizeof(*args));
|
||||||
args = malloc((my_args.argc + 8)*sizeof(*args));
|
|
||||||
if (!args) {
|
if (!args) {
|
||||||
ERROR("failed to allocate memory for '%s'", my_args.name);
|
ERROR("failed to allocate memory for '%s'", my_args.name);
|
||||||
goto out;
|
goto out;
|
||||||
@ -114,14 +113,14 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
nbargs = 0;
|
nbargs = 0;
|
||||||
args[nbargs++] = LXCLIBEXECDIR "/lxc-init";
|
args[nbargs++] = LXCLIBEXECDIR "/lxc-init";
|
||||||
args[nbargs++] = "--mount-procfs";
|
|
||||||
if (my_args.log_file) {
|
if (my_args.log_file) {
|
||||||
args[nbargs++] = "--logfile";
|
args[nbargs++] = "--logfile";
|
||||||
args[nbargs++] = my_args.log_file;
|
args[nbargs++] = strdupa(my_args.log_file);
|
||||||
}
|
}
|
||||||
if (my_args.log_priority) {
|
if (my_args.log_priority) {
|
||||||
args[nbargs++] = "--logpriority";
|
args[nbargs++] = "--logpriority";
|
||||||
args[nbargs++] = my_args.log_priority;
|
args[nbargs++] = strdupa(my_args.log_priority);
|
||||||
}
|
}
|
||||||
if (my_args.quiet) {
|
if (my_args.quiet) {
|
||||||
args[nbargs++] = "--quiet";
|
args[nbargs++] = "--quiet";
|
||||||
@ -129,7 +128,9 @@ int main(int argc, char *argv[])
|
|||||||
args[nbargs++] = "--";
|
args[nbargs++] = "--";
|
||||||
|
|
||||||
for (opt = 0; opt < my_args.argc; opt++)
|
for (opt = 0; opt < my_args.argc; opt++)
|
||||||
args[nbargs++] = my_args.argv[opt];
|
args[nbargs++] = strdupa(my_args.argv[opt]);
|
||||||
|
|
||||||
|
args[nbargs] = '\0';
|
||||||
|
|
||||||
ret = lxc_start(my_args.name, args);
|
ret = lxc_start(my_args.name, args);
|
||||||
out:
|
out:
|
||||||
|
@ -37,15 +37,11 @@
|
|||||||
|
|
||||||
lxc_log_define(lxc_init, lxc);
|
lxc_log_define(lxc_init, lxc);
|
||||||
|
|
||||||
static int mount_sysfs;
|
|
||||||
static int mount_procfs;
|
|
||||||
static char const *log_file;
|
static char const *log_file;
|
||||||
static char const *log_priority;
|
static char const *log_priority;
|
||||||
static int quiet;
|
static int quiet;
|
||||||
|
|
||||||
static struct option options[] = {
|
static struct option options[] = {
|
||||||
{ "mount-sysfs", no_argument, &mount_sysfs, 1 },
|
|
||||||
{ "mount-procfs", no_argument, &mount_procfs, 1 },
|
|
||||||
{ "logfile", required_argument, 0, 'o' },
|
{ "logfile", required_argument, 0, 'o' },
|
||||||
{ "logpriority", required_argument, 0, 'l' },
|
{ "logpriority", required_argument, 0, 'l' },
|
||||||
{ "quiet", no_argument, &quiet, 1 },
|
{ "quiet", no_argument, &quiet, 1 },
|
||||||
@ -91,12 +87,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
|
|
||||||
if (mount_sysfs && mount("sysfs", "/sys", "sysfs", 0, NULL)) {
|
if (mount("proc", "/proc", "proc", 0, NULL)) {
|
||||||
ERROR("failed to mount '/sys' : %s", strerror(errno));
|
|
||||||
exit(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mount_procfs && mount("proc", "/proc", "proc", 0, NULL)) {
|
|
||||||
ERROR("failed to mount '/proc' : %s", strerror(errno));
|
ERROR("failed to mount '/proc' : %s", strerror(errno));
|
||||||
exit(err);
|
exit(err);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user