I am a little confused about what is happening here. I was following a guide where a new mount point was added after calling clone with the CLONE_NEWNS flag set. The mount point was supposed to only exist for the child process. I'm trying to do change the new filesystem namespace and it seems to effect the parent one.
My c program is pretty simple. Main will call clone
pid_t pid = clone(child_exec,c_stack, SIGCHLD | CLONE_NEWNS | CLONE_NEWPID ,args);
args is a chat array that contains a command to exec.
int child_exec(void *arg)
{
int err =0;
char **commands = (char **)arg;
mount("none", "/mytmp", "tmpfs", 0, "");
execvp(commands[0],commands);
return 0;
}
If the command that is passed to execvp is mount
I would expect the output to contain the /mytmp mount point and running the command mount
again after the program exits to not see /mytmp come up. That's not happening. I see it in the out when execvp is called and after when I run mount.
I tried mounting with MS_PRIVATE flag and using unshare(CLONE_FS);
I also had a similar problem where I tried to unmount /proc from the child process and a get resource is busy error. I thought that shouldn't have happened with a new namespace.