Commit b1ab3317 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Pavel Emelyanov

introduce find_ext_ns_id()

Preparation. Extract the "search the criu's mount info" code from
resolve_external_mounts() into the new simple helper, find_ext_ns_id().

Also change resolve_external_mounts() to check ext_ns == NULL rather
than !opts.autodetect_ext_mounts. Cosmetic.
Signed-off-by: 's avatarOleg Nesterov <oleg@redhat.com>
Tested-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 3ef1b53e
......@@ -692,20 +692,28 @@ static struct mount_info *find_best_external_match(struct mount_info *list, stru
return candidate;
}
static int resolve_external_mounts(struct mount_info *info)
static struct ns_id *find_ext_ns_id(void)
{
struct mount_info *m;
struct ns_id *ns = NULL, *iter;
int pid = getpid();
struct ns_id *ns;
for (iter = ns_ids; iter->next; iter = iter->next) {
if (iter->pid == getpid() && iter->nd == &mnt_ns_desc) {
ns = iter;
break;
}
for (ns = ns_ids; ns->next; ns = ns->next)
if (ns->pid == pid && ns->nd == &mnt_ns_desc) {
return ns;
}
if (!ns) {
pr_err("Failed to find criu pid's mount ns!");
return NULL;
}
static int resolve_external_mounts(struct mount_info *info)
{
struct ns_id *ext_ns = NULL;
struct mount_info *m;
if (opts.autodetect_ext_mounts) {
ext_ns = find_ext_ns_id();
if (!ext_ns)
return -1;
}
......@@ -721,13 +729,13 @@ static int resolve_external_mounts(struct mount_info *info)
ret = try_resolve_ext_mount(m);
if (ret < 0 && ret != -ENOTSUP) {
return -1;
} else if (ret == -ENOTSUP && !opts.autodetect_ext_mounts) {
} else if (ret == -ENOTSUP && !ext_ns) {
continue;
} else if (ret == 0) {
continue;
}
match = find_best_external_match(ns->mnt.mntinfo_list, m);
match = find_best_external_match(ext_ns->mnt.mntinfo_list, m);
if (!match)
continue;
......
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