1 .. SPDX-License-Identifier: GPL-2.0 1 .. SPDX-License-Identifier: GPL-2.0 2 2 3 ================= 3 ================= 4 Automount Support 4 Automount Support 5 ================= 5 ================= 6 6 7 7 8 Support is available for filesystems that wish 8 Support is available for filesystems that wish to do automounting 9 support (such as kAFS which can be found in fs 9 support (such as kAFS which can be found in fs/afs/ and NFS in 10 fs/nfs/). This facility includes allowing in-k 10 fs/nfs/). This facility includes allowing in-kernel mounts to be 11 performed and mountpoint degradation to be req 11 performed and mountpoint degradation to be requested. The latter can 12 also be requested by userspace. 12 also be requested by userspace. 13 13 14 14 15 In-Kernel Automounting 15 In-Kernel Automounting 16 ====================== 16 ====================== 17 17 18 See section "Mount Traps" of Documentation/fi 18 See section "Mount Traps" of Documentation/filesystems/autofs.rst 19 19 20 Then from userspace, you can just do something 20 Then from userspace, you can just do something like:: 21 21 22 [root@andromeda root]# mount -t afs \# 22 [root@andromeda root]# mount -t afs \#root.afs. /afs 23 [root@andromeda root]# ls /afs 23 [root@andromeda root]# ls /afs 24 asd cambridge cambridge.redhat.com 24 asd cambridge cambridge.redhat.com grand.central.org 25 [root@andromeda root]# ls /afs/cambrid 25 [root@andromeda root]# ls /afs/cambridge 26 afsdoc 26 afsdoc 27 [root@andromeda root]# ls /afs/cambrid 27 [root@andromeda root]# ls /afs/cambridge/afsdoc/ 28 ChangeLog html LICENSE pdf RELNOTE 28 ChangeLog html LICENSE pdf RELNOTES-1.2.2 29 29 30 And then if you look in the mountpoint catalog 30 And then if you look in the mountpoint catalogue, you'll see something like:: 31 31 32 [root@andromeda root]# cat /proc/mount 32 [root@andromeda root]# cat /proc/mounts 33 ... 33 ... 34 #root.afs. /afs afs rw 0 0 34 #root.afs. /afs afs rw 0 0 35 #root.cell. /afs/cambridge.redhat.com 35 #root.cell. /afs/cambridge.redhat.com afs rw 0 0 36 #afsdoc. /afs/cambridge.redhat.com/afs 36 #afsdoc. /afs/cambridge.redhat.com/afsdoc afs rw 0 0 37 37 38 38 39 Automatic Mountpoint Expiry 39 Automatic Mountpoint Expiry 40 =========================== 40 =========================== 41 41 42 Automatic expiration of mountpoints is easy, p 42 Automatic expiration of mountpoints is easy, provided you've mounted the 43 mountpoint to be expired in the automounting p 43 mountpoint to be expired in the automounting procedure outlined separately. 44 44 45 To do expiration, you need to follow these ste 45 To do expiration, you need to follow these steps: 46 46 47 (1) Create at least one list off which the vf 47 (1) Create at least one list off which the vfsmounts to be expired can be 48 hung. 48 hung. 49 49 50 (2) When a new mountpoint is created in the - 50 (2) When a new mountpoint is created in the ->d_automount method, add 51 the mnt to the list using mnt_set_expiry( 51 the mnt to the list using mnt_set_expiry():: 52 52 53 mnt_set_expiry(newmnt, &afs_vfsmo 53 mnt_set_expiry(newmnt, &afs_vfsmounts); 54 54 55 (3) When you want mountpoints to be expired, 55 (3) When you want mountpoints to be expired, call mark_mounts_for_expiry() 56 with a pointer to this list. This will pr 56 with a pointer to this list. This will process the list, marking every 57 vfsmount thereon for potential expiry on 57 vfsmount thereon for potential expiry on the next call. 58 58 59 If a vfsmount was already flagged for exp 59 If a vfsmount was already flagged for expiry, and if its usage count is 1 60 (it's only referenced by its parent vfsmo 60 (it's only referenced by its parent vfsmount), then it will be deleted 61 from the namespace and thrown away (effec 61 from the namespace and thrown away (effectively unmounted). 62 62 63 It may prove simplest to simply call this 63 It may prove simplest to simply call this at regular intervals, using 64 some sort of timed event to drive it. 64 some sort of timed event to drive it. 65 65 66 The expiration flag is cleared by calls to mnt 66 The expiration flag is cleared by calls to mntput. This means that expiration 67 will only happen on the second expiration requ 67 will only happen on the second expiration request after the last time the 68 mountpoint was accessed. 68 mountpoint was accessed. 69 69 70 If a mountpoint is moved, it gets removed from 70 If a mountpoint is moved, it gets removed from the expiration list. If a bind 71 mount is made on an expirable mount, the new v 71 mount is made on an expirable mount, the new vfsmount will not be on the 72 expiration list and will not expire. 72 expiration list and will not expire. 73 73 74 If a namespace is copied, all mountpoints cont 74 If a namespace is copied, all mountpoints contained therein will be copied, 75 and the copies of those that are on an expirat 75 and the copies of those that are on an expiration list will be added to the 76 same expiration list. 76 same expiration list. 77 77 78 78 79 Userspace Driven Expiry 79 Userspace Driven Expiry 80 ======================= 80 ======================= 81 81 82 As an alternative, it is possible for userspac 82 As an alternative, it is possible for userspace to request expiry of any 83 mountpoint (though some will be rejected - the 83 mountpoint (though some will be rejected - the current process's idea of the 84 rootfs for example). It does this by passing t 84 rootfs for example). It does this by passing the MNT_EXPIRE flag to 85 umount(). This flag is considered incompatible 85 umount(). This flag is considered incompatible with MNT_FORCE and MNT_DETACH. 86 86 87 If the mountpoint in question is in referenced 87 If the mountpoint in question is in referenced by something other than 88 umount() or its parent mountpoint, an EBUSY er 88 umount() or its parent mountpoint, an EBUSY error will be returned and the 89 mountpoint will not be marked for expiration o 89 mountpoint will not be marked for expiration or unmounted. 90 90 91 If the mountpoint was not already marked for e 91 If the mountpoint was not already marked for expiry at that time, an EAGAIN 92 error will be given and it won't be unmounted. 92 error will be given and it won't be unmounted. 93 93 94 Otherwise if it was already marked and it wasn 94 Otherwise if it was already marked and it wasn't referenced, unmounting will 95 take place as usual. 95 take place as usual. 96 96 97 Again, the expiration flag is cleared every ti 97 Again, the expiration flag is cleared every time anything other than umount() 98 looks at a mountpoint. 98 looks at a mountpoint.
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.