Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 8: The Virtual Filesystem


atomic_t mnt_count;
int mnt_expiry_mark; /* true if marked for expiry */
};

mnt_mntpointis the dentry structure of the mount pointin the parent directoryin which the filesystem was
mounted; the relative root directory of the filesystem itself is stored inmnt_root. Two dentry instances
represent the same directory (namely, the mount point). This means that it is not necessary to delete the
previous mount point information from memory and make it available again once the filesystem has been
unmounted. When I discuss themountsystem call, the need for two dentry entries will become crystal
clear.


Themnt_sbpointer creates a link to the associated superblock (of which there is exactly one instance for
eachmountedfilesystem);mnt_parentpoints to thevfsmountstructure of the parent filesystem.


The parent–child relationships are represented by a linked list implemented by two elements of the
structure. Themnt_mountslist head is the starting point for the list of child filesystems. The individual
list elements are linked by themnt_childfield.


Eachvfsmountinstance of the system can be identified in two further ways. All mounted filesystems of a
namespace are held in a linked list headed bynamespace->list. The individual objects are linked by the
mnt_listelement. I ignore the topology here because all mounts are performed one after the other.


Various filesystem-independent flags can be set innmt_flags. The following constants list all possible
flags:


<mount.h>
#define MNT_NOSUID 0x01
#define MNT_NODEV 0x02
#define MNT_NOEXEC 0x04
#define MNT_NOATIME 0x08
#define MNT_NODIRATIME 0x10
#define MNT_RELATIME 0x20

#define MNT_SHRINKABLE 0x100

#define MNT_SHARED 0x1000 /* if the vfsmount is a shared mount */
#define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
#define MNT_PNODE_MASK 0x3000 /* propagation flag mask *

The first block is concerned with classic properties like disallowing setuid execution or the existence of
device files on the mount, or how access time handling is managed.MNT_NODEVis set if the mounted
filesystem is virtual, that is, does not have a physical backing device.MNT_SHRINKABLEis a specialty of
NFS and AFS that is used to mark submounts. Mounts with this mark are allowed to be automatically
removed.


The last block contains flags that indicate shared and unbindable mounts. Refer to Section 8.4.1 for more
details on what these types are good for.


A hash table calledmount_hashtableanddefinedinfs/namespace.cis also used. The overflow list is
implemented as a linked list withmnt_hash. The address of thevfsmountinstance and the address of the
associateddentryobject are used to calculate the hash sum.mnt_namespaceis the namespace to which
the mount belongs.

Free download pdf