Fsnameic

static int _follow_mount(struct path *path)

while (d_mountpoint(path->dentry)) {

struct vfsmount *mounted = lookup_mnt(path->mnt, path->dentry); if (¡mounted)

break; path->mnt = mounted; path->dentry = mounted->mnt_root; res = 1;

return res;

How does this loop work? A check is first made to ascertain whether the current dentry instance is a mount point. In this context, the d_mountpoint macro need only check whether the value of d_mounted is greater than 0. The lookup_mount function extracts the vfsmount instance of the mounted filesystem from the mount_hashtable discussed in Section 8.4.1. The mnt_root field of the mounted filesystem is used as the new value for the dentry structure; all this means is that the root directory of the mounted filesystem is used as the mount point — and this is exactly what we want to achieve.

22I have omitted the required locking and reference counting operations, which would make the code less readable.

A while loop caters to the fact that several filesystems can be mounted one after the other where the last system mounted conceals all the others.

Continue reading here: Implementation of dofollowlink

Was this article helpful?

0 0