Now the empty foo file on the floppy filesystem can be accessed both as flpfoo and flpmntfoo
It is also possible to stack multiple mounts on a single mount point. Each new mount on the same mount point hides the previously mounted filesystem, although processes already using the files and directories under the old mount can continue to do so. When the topmost mounting is removed, then the next lower mount is once more made visible.
As you can imagine, keeping track of mounted filesystems can quickly become a nightmare. For each mount operation, the kernel must save in memory the mount point and the mount flags, as well as the relationships between the filesystem to be mounted and the other mounted filesystems. Such information is stored in data structures named mounted filesystem descriptors; each descriptor is a data structure that has type vfsmount, whose fields are shown in Table 12-11.
|
Type |
Field |
Description |
|
struct list head |
mnt hash |
Pointers for the hash table list |
|
struct vfsmount * |
mnt parent |
Points to the parent filesystem on which this filesystem is mounted on |
|
mnt mountpoint |
Points to the dentry of the mount directory of this filesystem | |
|
struct dentry * |
mnt root |
Points to the dentry of the root directory of this filesystem |
|
struct super block * |
mnt_sb |
Points to the superblock object of this filesystem |
|
struct list head |
mnt mounts |
Head of the parent list of descriptors (relative to this filesystem) |
|
struct list head |
mnt child |
Pointers for the parent list of descriptors (relative to the parent filesystem) |
|
atomic t |
mnt count |
Usage counter |
|
int |
mnt flags |
Flags |
|
char * |
mnt devname |
Device file name |
|
struct list head |
mnt list |
Pointers for global list of descriptors |
• A circular doubly linked "global" list including the descriptors of all mounted filesystems. The head of the list is a first dummy element, which is represented by the vfsmntlist variable. The mnt_list field of the descriptor contains the pointers to adjacent elements in the list.
• An hash table indexed by the address of the vfsmount descriptor of the parent filesystem and the address of the dentry object of the mount point directory. The hash table is stored in the mount_hashtable array, whose size depends on the amount of RAM in the system. Each item of the table is the head of a circular doubly linked list storing all descriptors that have the same hash value. The mnt_hash field of the descriptor contains the pointers to adjacent elements in this list.
• For each mounted filesystem, a circular doubly linked list including all child mounted filesystems. The head of each list is stored in the mnt_mounts field of the mounted filesystem descriptor; moreover, the mnt_child field of the descriptor stores the pointers to the adjacent elements in the list.
The mount_sem semaphore protects the lists of mounted filesystem objects from concurrent accesses.
The mnt_flags field of the descriptor stores the value of several flags that specify how some kinds of files in the mounted filesystem are handled. The flags are listed in Table 1212.
|
Name |
Description |
|
MNT NOSUID |
Forbid setuid and setgid flags in the mounted filesystem |
|
MNT NODEV |
Forbid access to device files in the mounted filesystem |
|
MNT NOEXEC |
Disallow program execution in the mounted filesystem |
The following functions handle the mounted filesystem descriptors:
alloc vfsmnt( )
Allocates and initializes a mounted filesystem descriptor free vfsmnt(mnt)
Frees a mounted filesystem descriptor pointed by mnt lookup mnt( parent,mountpoint)
Looks up a descriptor in the hash table and returns its address
Continue reading here: Mounting the Root Filesystem
Was this article helpful?