【发布时间】:2014-05-18 07:52:17
【问题描述】:
我正在阅读 mount 和 clone 手册页。我想澄清一下 CLONE_NEWNS 如何影响子进程的文件系统视图。
(文件层次结构)
让我们将此树视为目录层次结构。让我们说 5 和 6 是父进程中的挂载点。我在另一个question 中阐明了挂载点。
所以我的理解是:5 和 6 是挂载点意味着 mount 命令以前用于在 5 和 6 处“挂载”文件系统(目录层次结构)(这意味着 5 和 6 下必须有目录树以及)。
来自mount 手册页:
A mount namespace is the set of filesystem mounts that are visible to a process.
来自clone 手册页:
Every process lives in a mount namespace. The namespace of a process is the data
(the set of mounts) describing the file hierarchy as seen by that process. After
a fork(2) or clone() where the CLONE_NEWNS flag is not set, the child lives in the
same mount namespace as the parent.
还有:
After a clone() where the CLONE_NEWNS flag is set, the cloned child is started in a
new mount namespace, initialized with a copy of the namespace of the parent.
现在,如果我使用 clone() 和 CLONE_NEWNS 创建子进程,这是否意味着子进程将获得树中安装点的精确副本(5 和 6)并且仍然能够访问其余部分原来的树?这是否也意味着子进程可以随意挂载 5 和 6,而不会影响在其父进程的挂载命名空间中挂载在 5 或 6 的内容。
如果是,是否也意味着子进程可以挂载/卸载不同于 5 或 6 的目录并影响父进程可见的内容?
谢谢。
【问题讨论】:
标签: linux clone mount linux-namespaces