我目前正在尝试使用不同的名称空间进行测试。为此,我尝试实现一个MNT名称空间(与PID名称空间相结合),以便此名称空间中的程序无法看到系统上的其他进程。
当尝试像这样使用umount系统调用时( umount("/proc")也是如此,或者使用umount2和Force-option ):
if (umount2("/proc", 0)!= 0)
{
fprintf(stderr, "Error when unmounting /proc: %s\n",strerror(errno));
printf("\tKernel version might be incorrect\n");
exit(-1);
}系统调用的执行以错误号22 "Invalid Argument“结束。
这段代码在一个函数中调用,该函数在创建具有名称空间的子进程时调用:
pid_t child_pid = clone(child_exec, child_stack+1024*1024, Child_Flags,&args);( child_exec函数)。标志设置如下:
int Child_Flags = CLONE_NEWIPC | CLONE_NEWUSER | CLONE_NEWUTS | CLONE_NEWNET |CLONE_NEWPID | CLONE_NEWNS |SIGCHLD ;使用新装载命名空间(http://man7.org/linux/man-pages/man7/namespaces.7.html)的CLONE_NEWNS
程序输出如下:
Testing with Isolation
Starting Container engine
In-Child-PID: 1
Error number 22
Error when unmounting /proc: Invalid argument有人可以指出我的错误,这样我就可以卸载文件夹了吗?提前谢谢你
发布于 2019-01-08 18:22:47
您不能卸载在不同用户名称空间中挂载的内容,除非先使用pivot_root,然后使用umount卸载/。您可以在不卸载旧/proc的情况下覆盖/proc。
https://stackoverflow.com/questions/50435255
复制相似问题