我正在阅读mount和clone手册。我想澄清CLONE_NEWNS如何影响子进程对文件系统的视图。
(文件层次结构)
让我们把这棵树看作目录层次结构。假设5和6是父进程中的挂载点。我在另一个question中澄清了挂载点。
所以我的理解是:5和6是挂载点,这意味着先前使用了
来自
从
此外:
现在如果我使用带有CLONE_NEWNS的clone()来创建一个子进程,这是否意味着子进程将获得树中挂载点(5和6)的精确副本,并仍然能够访问原始树的其余部分?这是否也意味着子进程可以随意挂载5和6,而不影响父进程挂载命名空间中挂载在5或6的内容?
如果是,这是否还意味着子进程可以挂载/卸载与5或6不同的目录,并影响父进程可见的内容?
谢谢。
(文件层次结构)
让我们把这棵树看作目录层次结构。假设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_NEWNS的clone()来创建一个子进程,这是否意味着子进程将获得树中挂载点(5和6)的精确副本,并仍然能够访问原始树的其余部分?这是否也意味着子进程可以随意挂载5和6,而不影响父进程挂载命名空间中挂载在5或6的内容?
如果是,这是否还意味着子进程可以挂载/卸载与5或6不同的目录,并影响父进程可见的内容?
谢谢。