Skip to content

Commit

Permalink
mount: clone a mount namespace to open a detached mount
Browse files Browse the repository at this point in the history
If we can't create a temporary directory for a detached mount,
we can clone a whole mount namespace, open a mount and release
the created namespace. The result will be the same.

https://jira.sw.ru/browse/PSBM-57135
opencontainers/runc#1202
travis-ci: success for A few fixes to c/r a docker container with a console (rev3)
Signed-off-by: Andrei Vagin <[email protected]>
Signed-off-by: Pavel Emelyanov <[email protected]>
  • Loading branch information
avagin committed Feb 28, 2017
1 parent 00fbf92 commit d4e5cf8
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions criu/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -1091,10 +1091,23 @@ int open_mountpoint(struct mount_info *pm)
goto out;

mnt_path = get_clean_mnt(pm, mnt_path_tmp, mnt_path_root);
if (mnt_path == NULL)
goto out;
if (mnt_path == NULL) {
/*
* We probably can't create a temporary direcotry,
* so we can try to clone the mount namespace, open
* the required mount and destroy this mount namespace
* by calling restore_ns() below in this function.
*/
if (unshare(CLONE_NEWNS)) {
pr_perror("Unable to clone a mount namespace");
goto out;
}

fd = open_detach_mount(mnt_path);
fd = open(pm->mountpoint, O_RDONLY | O_DIRECTORY, 0);
if (fd < 0)
pr_perror("Can't open directory %s: %d", pm->mountpoint, fd);
} else
fd = open_detach_mount(mnt_path);
if (fd < 0)
goto out;

Expand Down

0 comments on commit d4e5cf8

Please sign in to comment.