【问题标题】:Umount("/proc") syscall for mount namespaces "Invalid Argument" error挂载命名空间“无效参数”错误的 Umount("/proc") 系统调用
【发布时间】:2018-05-20 13:19:41
【问题描述】:

我目前正在尝试使用不同的命名空间进行测试。为此,我尝试实现一个 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

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

【问题讨论】:

    标签: linux namespaces unmount


    【解决方案1】:

    除了使用pivot_root 后跟umount 来卸载/ 之外,您无法卸载已安装在不同用户命名空间中的内容。您可以在不卸载旧的 /proc 的情况下重载 /proc

    【讨论】:

      猜你喜欢
      • 2014-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-06
      • 2011-07-03
      • 2016-12-04
      • 2012-04-11
      • 1970-01-01
      相关资源
      最近更新 更多