简体   繁体   English

Linux-在克隆手册页中使用术语挂载

[英]Linux - use of term mount in clone man page

I asked a question to clarify what mount means in Linux. 我问了一个问题以阐明Linux中的安装方式。

I have a doubt in the use of this term in the clone man page: 我对克隆手册页中使用此术语有疑问:

The namespace of a process is the data (the set of mounts) describing the file 
hierarchy as seen by that process. 

The set of mounts - describing the file hierarchy seems misleading to me. 一组安装-描述文件层次结构似乎对我产生了误导。

From what I understood based on the accepted answer , the file hierarchy could be much more than just the set of mounts, as the set of mounts will be just be the mount points where file systems were added to existing file system. 根据我对公认答案的理解,文件层次结构可能不仅仅是安装集,因为安装集只是将文件系统添加到现有文件系统的安装点。

Can anyone clarify ? 有人可以澄清吗?

If you think of “the set of mounts” as being (at least) a set of (device, mount point) pairs, rather than merely a set of mount points , then it starts to look a lot like the fstab or the output of the mount command (with no arguments), albeit without the additional information about flags and options (eg rw , nosuid , etc.). 如果您认为“一组安装”是(至少)一组(设备,安装点)对,而不仅仅是一组安装 ,那么它看起来就很像fstabfstab的输出mount命令(不带参数),尽管没有有关标志和选项的附加信息(例如rwnosuid等)。

Such a “set of mounts” provides complete information about what filesystems are mounted where. 这样的“一组安装”提供了有关在何处安装了哪些文件系统的完整信息。 This is, by definition, the “mount namespace” of a process. 根据定义,这是进程的“挂载名称空间”。 Once you go from the traditional situation of having one global mount namespace to having per-process mount namespaces, additional questions arise when a process fork() s. 一旦从拥有一个全局挂载名称空间的传统情况变为具有每个进程的挂载名称空间,当流程fork()时,就会出现其他问题。

Traditionally, mounting or unmounting a filesystem changed the filesystem as seen by all processes. 传统上,挂载或卸载文件系统会更改所有进程所看到的文件系统。

With per-process mount namespaces, it is possible for a child process to have a different mount namespace from its parent. 使用按进程安装的命名空间,子进程可能具有与其父进程不同的安装命名空间。 A question now arises: 现在出现一个问题:

Should changes to the mount namespace made by the child propagate back to the parent? 子级对安装名称空间所做的更改是否应传播回父级?

Clearly, this functionality must at least be supported and, indeed, must probably be the default. 显然, 必须至少支持此功能,并且实际上可能必须是默认功能。 Otherwise, launching the mount command itself would effect no change (since the filesystem as seen by the parent shell would be unaffected). 否则,启动mount命令本身将不会有任何改变(因为父shell看到的文件系统将不受影响)。

Equally clearly, it must also be possible for this necessary propagation to be suppressed , otherwise we can never create a child process whose mount namespace differs from its parent, and we have one global mount namespace again (the filesystem as seen by init ). 同样清楚的是,也必须有可能抑制这种必要的传播,否则我们将永远无法创建一个子进程,其挂载名称空间不同于其父名称空间,而我们又拥有一个全局挂载名称空间(如init的文件系统)。

Thus, we must decide on fork() whether the child process gets its own copy of the data about mounted filesystems from the parent, which it can change without affecting the parent, or gets a pointer to the same data structures as the, which it can change (necessary for changes to propagate back, as when you launch mount from the shell). 因此,我们必须在fork()决定子进程是否从父进程获取有关已挂载文件系统的数据的自己的副本,可以在不影响父进程的情况下对其进行更改,还是获得指向与其相同的数据结构的指针可以更改(更改必须传播回去,就像从shell启动mount )。

If the CLONE_NEWNS flag is passed to clone() or fork() , the child gets a copy of its parent's mounted filesystem data, which it can change without affecting the parent's mount namespace. 如果将CLONE_NEWNS标志传递给clone()fork() ,则子级将获得其父级的已挂载文件系统数据的副本 ,可以对其进行更改而不会影响父级的挂载名称空间。 Otherwise, it gets a pointer to the parents data structure, where changes made by the child will be seen by the parent (so the mount command itself can work). 否则,它将获得指向父级数据结构的指针 ,父级将看到子级所做的更改(因此mount命令本身可以工作)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM