void change_mnt_propagation(struct vfsmount *mnt, int type) {

set_mnt_shared(mnt); return;

list_del_init(&mnt->mnt_slave); mnt->mnt_master = NULL; if (type == MS_UNBINDABLE)

mnt->mnt_flags |= MNT_UNBINDABLE;

This is simple for shared mounts: It suffices to set the flag mnt_shared with the auxiliary function set_mnt_shared.

If a slave — or a private or unbindable mount — has to be established, the kernel has to rearrange the mount data structure such that the vfsmount instance under consideration is turned into a slave mount. This is done by do_make_slave. The function proceeds in several steps:

1. A master for the mount itself and any possible slave mounts needs to be found. First, the kernel searches among the shared-mount peers; the first one with the same root dentry is taken as the new master. If no such peer exists, the first element in the peer list is used.

2. If a new master has been found, both the mount under consideration and all its slave mounts are made slaves of the new master.

3. If the kernel could not find a new master, all slave mounts of the mount under consideration are freed — they do not have a master anymore.

In any case, the mnt_shared flag is also removed.

After do_make_slave has performed these rearrangements, change_mnt_propagation needs some more steps for unbindable and private mounts.17 In both cases, the mount is deleted from a slave list if it should be on one, and the master is set to null — neither mount type has a master. For unbindable mounts, the mnt_unbindable flag is set to identify it as such.

Shared subtrees obviously also influence the kernel behavior when new mounts are added to the system. The crucial steps are taken in attach_recursive_mnt. Recall that the function has already been touched on before, but the presentation was simplified. This time, I also include the effects of shared subtrees.18 First of all, the function needs to check into which mounts the mount event is supposed to propagate.

Continue reading here: Fsnamespacec

Was this article helpful?

0 0