automount-support.txt 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. Support is available for filesystems that wish to do automounting
  2. support (such as kAFS which can be found in fs/afs/ and NFS in
  3. fs/nfs/). This facility includes allowing in-kernel mounts to be
  4. performed and mountpoint degradation to be requested. The latter can
  5. also be requested by userspace.
  6. ======================
  7. IN-KERNEL AUTOMOUNTING
  8. ======================
  9. See section "Mount Traps" of Documentation/filesystems/autofs4.txt
  10. Then from userspace, you can just do something like:
  11. [root@andromeda root]# mount -t afs \#root.afs. /afs
  12. [root@andromeda root]# ls /afs
  13. asd cambridge cambridge.redhat.com grand.central.org
  14. [root@andromeda root]# ls /afs/cambridge
  15. afsdoc
  16. [root@andromeda root]# ls /afs/cambridge/afsdoc/
  17. ChangeLog html LICENSE pdf RELNOTES-1.2.2
  18. And then if you look in the mountpoint catalogue, you'll see something like:
  19. [root@andromeda root]# cat /proc/mounts
  20. ...
  21. #root.afs. /afs afs rw 0 0
  22. #root.cell. /afs/cambridge.redhat.com afs rw 0 0
  23. #afsdoc. /afs/cambridge.redhat.com/afsdoc afs rw 0 0
  24. ===========================
  25. AUTOMATIC MOUNTPOINT EXPIRY
  26. ===========================
  27. Automatic expiration of mountpoints is easy, provided you've mounted the
  28. mountpoint to be expired in the automounting procedure outlined separately.
  29. To do expiration, you need to follow these steps:
  30. (1) Create at least one list off which the vfsmounts to be expired can be
  31. hung.
  32. (2) When a new mountpoint is created in the ->d_automount method, add
  33. the mnt to the list using mnt_set_expiry()
  34. mnt_set_expiry(newmnt, &afs_vfsmounts);
  35. (3) When you want mountpoints to be expired, call mark_mounts_for_expiry()
  36. with a pointer to this list. This will process the list, marking every
  37. vfsmount thereon for potential expiry on the next call.
  38. If a vfsmount was already flagged for expiry, and if its usage count is 1
  39. (it's only referenced by its parent vfsmount), then it will be deleted
  40. from the namespace and thrown away (effectively unmounted).
  41. It may prove simplest to simply call this at regular intervals, using
  42. some sort of timed event to drive it.
  43. The expiration flag is cleared by calls to mntput. This means that expiration
  44. will only happen on the second expiration request after the last time the
  45. mountpoint was accessed.
  46. If a mountpoint is moved, it gets removed from the expiration list. If a bind
  47. mount is made on an expirable mount, the new vfsmount will not be on the
  48. expiration list and will not expire.
  49. If a namespace is copied, all mountpoints contained therein will be copied,
  50. and the copies of those that are on an expiration list will be added to the
  51. same expiration list.
  52. =======================
  53. USERSPACE DRIVEN EXPIRY
  54. =======================
  55. As an alternative, it is possible for userspace to request expiry of any
  56. mountpoint (though some will be rejected - the current process's idea of the
  57. rootfs for example). It does this by passing the MNT_EXPIRE flag to
  58. umount(). This flag is considered incompatible with MNT_FORCE and MNT_DETACH.
  59. If the mountpoint in question is in referenced by something other than
  60. umount() or its parent mountpoint, an EBUSY error will be returned and the
  61. mountpoint will not be marked for expiration or unmounted.
  62. If the mountpoint was not already marked for expiry at that time, an EAGAIN
  63. error will be given and it won't be unmounted.
  64. Otherwise if it was already marked and it wasn't referenced, unmounting will
  65. take place as usual.
  66. Again, the expiration flag is cleared every time anything other than umount()
  67. looks at a mountpoint.