|
ret = lxc_mount_auto_mounts(lxc_conf, lxc_conf->auto_mounts & ~LXC_AUTO_CGROUP_MASK, handler); |
|
if (ret < 0) { |
|
ERROR("Failed to setup first automatic mounts"); |
|
return -1; |
|
} |
|
|
|
ret = setup_mount(lxc_conf, &lxc_conf->rootfs, lxc_conf->fstab, name, lxcpath); |
|
if (ret < 0) { |
|
ERROR("Failed to setup mounts"); |
|
return -1; |
|
} |
|
|
|
if (lxc_conf->is_execute) { |
|
if (execveat_supported()) { |
|
int fd; |
|
char path[PATH_MAX]; |
|
|
|
ret = snprintf(path, PATH_MAX, SBINDIR "/init.lxc.static"); |
|
if (ret < 0 || ret >= PATH_MAX) { |
|
ERROR("Path to init.lxc.static too long"); |
|
return -1; |
|
} |
|
|
|
fd = open(path, O_PATH | O_CLOEXEC); |
|
if (fd < 0) { |
|
SYSERROR("Unable to open lxc.init.static"); |
|
return -1; |
|
} |
|
|
|
((struct execute_args *)handler->data)->init_fd = fd; |
|
((struct execute_args *)handler->data)->init_path = NULL; |
|
} else { |
|
ret = lxc_execute_bind_init(handler); |
|
if (ret < 0) { |
|
ERROR("Failed to bind-mount the lxc init system"); |
|
return -1; |
|
} |
|
} |
|
} |
|
|
|
/* Now mount only cgroups, if wanted. Before, /sys could not have been |
|
* mounted. It is guaranteed to be mounted now either through |
|
* automatically or via fstab entries. |
|
*/ |
|
ret = lxc_mount_auto_mounts(lxc_conf, lxc_conf->auto_mounts & LXC_AUTO_CGROUP_MASK, handler); |
|
if (ret < 0) { |
|
ERROR("Failed to setup remaining automatic mounts"); |
|
return -1; |
|
} |
|
|
|
ret = run_lxc_hooks(name, "mount", lxc_conf, NULL); |
|
if (ret < 0) { |
|
ERROR("Failed to run mount hooks"); |
|
return -1; |
|
} |
|
|
|
if (lxc_conf->autodev > 0) { |
|
ret = run_lxc_hooks(name, "autodev", lxc_conf, NULL); |
|
if (ret < 0) { |
|
ERROR("Failed to run autodev hooks"); |
|
return -1; |
|
} |
|
|
|
ret = lxc_fill_autodev(&lxc_conf->rootfs); |
|
if (ret < 0) { |
|
ERROR("Failed to populate \"/dev\""); |
|
return -1; |
|
} |
|
} |
|
|
|
if (!lxc_list_empty(&lxc_conf->mount_list)) { |
|
ret = setup_mount_entries(lxc_conf, &lxc_conf->rootfs, |
|
&lxc_conf->mount_list, name, lxcpath); |
|
if (ret < 0) { |
|
ERROR("Failed to setup mount entries"); |
|
return -1; |
|
} |
|
} |
Mostly a nice to have, but I got confused for a while on why our
mounthook ("a hook to be run in the container's namespace after mounting has been done, but before the pivot_root") was called before thelxc.mount.entrybut after thelxc.mount.auto.From the code:
lxc/src/lxc/conf.c
Lines 3537 to 3614 in 9810d19
The order is:
lxc.mount.auto = procandlxc.mount.auto = syslxc.mount.fstablxc.mount.auto = cgrouplxc.hook.mountlxc.autodevlxc.mount.entryBy the way, was there a reason to not have
lxc.mount.entryimmediately afterlxc.mount.fstab?