Commit 5ea6163a by Serge Hallyn Committed by Stéphane Graber

Add lxc.hook.pre-mount

This happens in the container's namespace, but before the rootfs is setup and mounted. This gives us a chance to mangle the rootfs - i.e. ecryptfs-mount it. Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent 06200a37
......@@ -110,7 +110,7 @@ lxc_log_define(lxc_conf, lxc);
#endif
char *lxchook_names[NUM_LXC_HOOKS] = {
"pre-start", "mount", "start", "post-stop" };
"pre-start", "pre-mount", "mount", "start", "post-stop" };
extern int pivot_root(const char * new_root, const char * put_old);
......@@ -2253,6 +2253,8 @@ int lxc_setup(const char *name, struct lxc_conf *lxc_conf)
return -1;
}
HOOK(name, "pre-mount", lxc_conf);
if (setup_rootfs(&lxc_conf->rootfs)) {
ERROR("failed to setup rootfs for '%s'", name);
return -1;
......@@ -2340,6 +2342,8 @@ int run_lxc_hooks(const char *name, char *hook, struct lxc_conf *conf)
if (strcmp(hook, "pre-start") == 0)
which = LXCHOOK_PRESTART;
else if (strcmp(hook, "pre-mount") == 0)
which = LXCHOOK_PREMOUNT;
else if (strcmp(hook, "mount") == 0)
which = LXCHOOK_MOUNT;
else if (strcmp(hook, "start") == 0)
......
......@@ -207,7 +207,7 @@ struct lxc_rootfs {
#endif
*/
enum lxchooks {
LXCHOOK_PRESTART, LXCHOOK_MOUNT, LXCHOOK_START,
LXCHOOK_PRESTART, LXCHOOK_PREMOUNT, LXCHOOK_MOUNT, LXCHOOK_START,
LXCHOOK_POSTSTOP, NUM_LXC_HOOKS};
extern char *lxchook_names[NUM_LXC_HOOKS];
......
......@@ -98,6 +98,7 @@ static struct lxc_config_t config[] = {
{ "lxc.pivotdir", config_pivotdir },
{ "lxc.utsname", config_utsname },
{ "lxc.hook.pre-start", config_hook },
{ "lxc.hook.pre-mount", config_hook },
{ "lxc.hook.mount", config_hook },
{ "lxc.hook.start", config_hook },
{ "lxc.hook.post-stop", config_hook },
......@@ -801,6 +802,8 @@ static int config_hook(const char *key, char *value,
}
if (strcmp(key, "lxc.hook.pre-start") == 0)
return add_hook(lxc_conf, LXCHOOK_PRESTART, copy);
else if (strcmp(key, "lxc.hook.pre-mount") == 0)
return add_hook(lxc_conf, LXCHOOK_PREMOUNT, copy);
else if (strcmp(key, "lxc.hook.mount") == 0)
return add_hook(lxc_conf, LXCHOOK_MOUNT, copy);
else if (strcmp(key, "lxc.hook.start") == 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment