Info

struct fs_struct {

atomic_t count; int umask;

struct vfsmount * rootmnt, * pwdmnt, * altrootmnt;

umask represents the standard mask used to set permissions for a new file. Its value can be read or set using the umask command. The system call of the same name does this internally.

The dentry elements of the structure point to the name of a directory, and vfsmount represents a mounted filesystem (the exact definition of the data structures is given below).

There are three dentry and three VFS mount elements with similar names. In fact, the entries are linked in pairs.

□ root and rootmnt specify the root directory and the filesystem of the relevant process. Normally these are the / directory and the root filesystem of the system. This situation is, of course, different for processes locked into a certain subdirectory by chroot (and implicitly by the system call of the same name). A subdirectory is then used instead of the global root directory, and the process sees this subdirectory as its own new root directory.

□ pwd and pwdmnt specify the present working directory and the VFS mount structure of the filesystem. Both change dynamically when the process changes its present directory; this happens frequently (cd command) when working with a shell. Whereas the value of pwd changes with each chdir system call,9 pwdmnt is only modified when the territory of a new mount point is entered. Let us look at an example where a floppy disk drive is mounted at /mnt/floppy. A user starts working with the shell in the root directory (/ ) and switches to the appropriate directory by successively entering the cd /mnt and cd floppy commands. Both commands change the data in fs_struct.

□ cd /mnt changes the pwd entry but leaves the pwdmnt entry unchanged — we are still in root directory territory.

□ cd floppy changes the value of pwd and of pwdmnt because a switch has been made to a new directory and the territory of a new filesystem has been entered.

□ The altroot and altrootmnt elements are used when implementing personalities; they permit the creation of an emulation environment for binary programs so that they have the impression they are working with an operating system other than Linux. For example, this method is

9 The only exception is a switch to the . directory.

used on Sparc systems to emulate SunOS; special files and libraries needed for emulation are installed in a directory (usually /usr/gnemul/). Information on this path is stored in the alt elements.

The above directory is always scanned first when searching for a file so that libraries or system files of the emulation are found before the Linux originals (these are searched afterward). This supports the parallel use of different libraries for different binary formats. Since this technique is rarely used, I won't discuss it further.

Continue reading here: VFS Namespaces

Was this article helpful?

0 0