Commit fcae4f39 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

mnt: add --enable-external-masters option

This option enables external (slave) bind mounts to be resolved.

v2: don't always assume that when the master id matches, the mounts match
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 0afffc9d
...@@ -206,6 +206,7 @@ int main(int argc, char *argv[], char *envp[]) ...@@ -206,6 +206,7 @@ int main(int argc, char *argv[], char *envp[])
{ "skip-mnt", required_argument, 0, 1064}, { "skip-mnt", required_argument, 0, 1064},
{ "enable-fs", required_argument, 0, 1065}, { "enable-fs", required_argument, 0, 1065},
{ "enable-external-sharing", no_argument, 0, 1066 }, { "enable-external-sharing", no_argument, 0, 1066 },
{ "enable-external-masters", no_argument, 0, 1067 },
{ }, { },
}; };
...@@ -430,6 +431,9 @@ int main(int argc, char *argv[], char *envp[]) ...@@ -430,6 +431,9 @@ int main(int argc, char *argv[], char *envp[])
case 1066: case 1066:
opts.enable_external_sharing = true; opts.enable_external_sharing = true;
break; break;
case 1067:
opts.enable_external_masters = true;
break;
case 'M': case 'M':
{ {
char *aux; char *aux;
...@@ -466,6 +470,11 @@ int main(int argc, char *argv[], char *envp[]) ...@@ -466,6 +470,11 @@ int main(int argc, char *argv[], char *envp[])
return 1; return 1;
} }
if (!opts.autodetect_ext_mounts && (opts.enable_external_masters || opts.enable_external_sharing)) {
pr_msg("must specify --ext-mount-map auto with --enable-external-{sharing|masters}");
return 1;
}
if (work_dir == NULL) if (work_dir == NULL)
work_dir = imgs_dir; work_dir = imgs_dir;
...@@ -660,6 +669,8 @@ usage: ...@@ -660,6 +669,8 @@ usage:
" attempt to autodetect external mount mapings\n" " attempt to autodetect external mount mapings\n"
" --enable-external-sharing\n" " --enable-external-sharing\n"
" allow autoresolving mounts with external sharing\n" " allow autoresolving mounts with external sharing\n"
" --enable-external-masters\n"
" allow autoresolving mounts with external masters\n"
" --manage-cgroups dump or restore cgroups the process is in\n" " --manage-cgroups dump or restore cgroups the process is in\n"
" --cgroup-root [controller:]/newroot\n" " --cgroup-root [controller:]/newroot\n"
" change the root cgroup the controller will be\n" " change the root cgroup the controller will be\n"
......
...@@ -64,6 +64,7 @@ struct cr_options { ...@@ -64,6 +64,7 @@ struct cr_options {
struct list_head new_cgroup_roots; struct list_head new_cgroup_roots;
bool autodetect_ext_mounts; bool autodetect_ext_mounts;
bool enable_external_sharing; bool enable_external_sharing;
bool enable_external_masters;
bool aufs; /* auto-deteced, not via cli */ bool aufs; /* auto-deteced, not via cli */
}; };
......
...@@ -739,6 +739,20 @@ static int resolve_external_mounts(struct mount_info *info) ...@@ -739,6 +739,20 @@ static int resolve_external_mounts(struct mount_info *info)
m->internal_sharing = true; m->internal_sharing = true;
} }
if (m->flags & MS_SLAVE) {
if (!opts.enable_external_masters)
continue;
/*
* In order to support something like internal slavery,
* we need to teach can_mount_now and do_mount_one
* about slavery relationships in external mounts. This
* seems like an uncommon case, so we punt for not.
*/
if (m->master_id != match->shared_id)
continue;
}
size = strlen(match->mountpoint + 1) + strlen(m->root) + 1; size = strlen(match->mountpoint + 1) + strlen(m->root) + 1;
p = xmalloc(sizeof(char) * size); p = xmalloc(sizeof(char) * size);
if (!p) if (!p)
......
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