gpt4 book ai didi

linux - 卸载 ("/proc") 挂载命名空间 "Invalid Argument"错误的系统调用

转载 作者:太空宇宙 更新时间:2023-11-04 12:06:45 30 4
gpt4 key购买 nike

我目前正在尝试使用不同的 namespace 进行测试。为此,我尝试实现一个 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“无效参数”结束。

这段代码片段是在一个函数中调用的,该函数在创建具有命名空间的子进程时被调用:

 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  ;

使用 CLONE_NEWNS 为新的挂载命名空间 (http://man7.org/linux/man-pages/man7/namespaces.7.html)

程序输出如下:

Testing with Isolation
Starting Container engine
In-Child-PID: 1
Error number 22
Error when unmounting /proc: Invalid argument

有人可以指出我的错误,以便我可以卸载该文件夹吗?提前谢谢你

最佳答案

除非使用 pivot_root 后跟 umount 来卸载 /,否则您无法卸载在不同用户命名空间中安装的东西。您可以在不卸载旧的 /proc 的情况下覆盖 /proc

关于linux - 卸载 ("/proc") 挂载命名空间 "Invalid Argument"错误的系统调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50435255/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com