mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-25 11:04:35 +00:00
mount: use switch_ns_by_fd() instead of open_proc() + setns()
This function was added recently. Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
6a430da7ca
commit
136ae76997
1 changed files with 2 additions and 13 deletions
15
criu/mount.c
15
criu/mount.c
|
|
@ -2945,15 +2945,7 @@ int depopulate_roots_yard(int mntns_fd, bool only_ghosts)
|
|||
return -1;
|
||||
}
|
||||
|
||||
old_ns = open_proc(PROC_SELF, "ns/mnt");
|
||||
if (old_ns < 0) {
|
||||
pr_perror("`- Can't keep old ns");
|
||||
close(old_cwd);
|
||||
return -1;
|
||||
}
|
||||
if (setns(mntns_fd, CLONE_NEWNS) < 0) {
|
||||
pr_perror("`- Can't switch");
|
||||
close(old_ns);
|
||||
if (switch_ns_by_fd(mntns_fd, &mnt_ns_desc, &old_ns)) {
|
||||
close(old_cwd);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -2964,11 +2956,8 @@ int depopulate_roots_yard(int mntns_fd, bool only_ghosts)
|
|||
if (__depopulate_roots_yard())
|
||||
ret = -1;
|
||||
|
||||
if (setns(old_ns, CLONE_NEWNS) < 0) {
|
||||
pr_perror("Fail to switch back!");
|
||||
if (restore_ns(old_ns, &mnt_ns_desc))
|
||||
ret = -1;
|
||||
}
|
||||
close(old_ns);
|
||||
|
||||
if (fchdir(old_cwd)) {
|
||||
pr_perror("Unable to restore cwd");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue