Commit 6e83f543 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Pavel Emelyanov

mount: Restore binfmt_misc content in case of missing mount

In case of mount image is not containing binfmt_misc mountpoint,
add temporary mountpoint to mount tree and try to restore
binfmt_misc content in ordinary way. Then, umount temporary mountpoint.

v4: New
v5: Check for opts.has_binfmt_misc to determine if image presents
v6: Check for binfmt_misc_list to determine if binfmt_misc entries present
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent f5876445
...@@ -2488,6 +2488,15 @@ static int do_new_mount(struct mount_info *mi) ...@@ -2488,6 +2488,15 @@ static int do_new_mount(struct mount_info *mi)
if (tp->restore && tp->restore(mi)) if (tp->restore && tp->restore(mi))
return -1; return -1;
if (mi->mnt_id == CRTIME_MNT_ID) {
/* C-r time mountpoint, umount it */
if (umount(mi->mountpoint) < 0) {
pr_perror("Can't umount %s\n", mi->mountpoint);
return -1;
}
goto out;
}
if (remount_ro && mount(NULL, mi->mountpoint, tp->name, if (remount_ro && mount(NULL, mi->mountpoint, tp->name,
MS_REMOUNT | MS_RDONLY, NULL)) { MS_REMOUNT | MS_RDONLY, NULL)) {
pr_perror("Unable to apply mount options"); pr_perror("Unable to apply mount options");
...@@ -2507,7 +2516,7 @@ static int do_new_mount(struct mount_info *mi) ...@@ -2507,7 +2516,7 @@ static int do_new_mount(struct mount_info *mi)
BUG_ON(mi->master_id); BUG_ON(mi->master_id);
if (restore_shared_options(mi, !mi->shared_id, mi->shared_id, 0)) if (restore_shared_options(mi, !mi->shared_id, mi->shared_id, 0))
return -1; return -1;
out:
mi->mounted = true; mi->mounted = true;
return 0; return 0;
...@@ -3399,6 +3408,13 @@ static int populate_mnt_ns(void) ...@@ -3399,6 +3408,13 @@ static int populate_mnt_ns(void)
if (!pms) if (!pms)
return -1; return -1;
if (!opts.has_binfmt_misc && !list_empty(&binfmt_misc_list)) {
/* Add to mount tree. Generic code will mount it later */
ret = add_cr_time_mount(pms, "binfmt_misc", BINFMT_MISC_HOME, 0);
if (ret)
return -1;
}
if (resolve_shared_mounts(mntinfo, pms->master_id)) if (resolve_shared_mounts(mntinfo, pms->master_id))
return -1; return -1;
......
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