Commit 7fd39f96 authored by Radostin Stoyanov's avatar Radostin Stoyanov Committed by Andrei Vagin

mount: Fix cleanup_mnt_ns() when opts.root is set

In commit

    c1404f66
    mount: restore cwd after creating a roots yard (v2)

were introduced changes to the function cleanup_mnt_ns() that handle
the case when opts.root is set.

However, after commit

    2e8970be
    mount: create a mount point for the root mount namespace in the roots yard

the cleanup_mnt_ns() function always results in error:

    mnt: Can't remove the directory ...: No such file or directory

when restore fails and opts.root has been set.

Resolves #467
Signed-off-by: 's avatarRadostin Stoyanov <rstoyanov1@gmail.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@gmail.com>
parent 7cd1cf0b
......@@ -3263,13 +3263,10 @@ int depopulate_roots_yard(int mntns_fd, bool only_ghosts)
void cleanup_mnt_ns(void)
{
char path[PATH_MAX], *root = opts.root ? : "/";
if (mnt_roots == NULL)
return;
snprintf(path, sizeof(path), "%s/%s", root, mnt_roots);
if (rmdir(path))
if (rmdir(mnt_roots))
pr_perror("Can't remove the directory %s", mnt_roots);
}
......
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