mount.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. *
  3. * Definitions for mount interface. This describes the in the kernel build
  4. * linkedlist with mounted filesystems.
  5. *
  6. * Author: Marco van Wieringen <mvw@planets.elm.net>
  7. *
  8. */
  9. #ifndef _LINUX_MOUNT_H
  10. #define _LINUX_MOUNT_H
  11. #include <linux/types.h>
  12. #include <linux/list.h>
  13. #include <linux/nodemask.h>
  14. #include <linux/spinlock.h>
  15. #include <asm/atomic.h>
  16. struct super_block;
  17. struct vfsmount;
  18. struct dentry;
  19. struct mnt_namespace;
  20. #define MNT_NOSUID 0x01
  21. #define MNT_NODEV 0x02
  22. #define MNT_NOEXEC 0x04
  23. #define MNT_NOATIME 0x08
  24. #define MNT_NODIRATIME 0x10
  25. #define MNT_RELATIME 0x20
  26. #define MNT_READONLY 0x40 /* does the user want this to be r/o? */
  27. #define MNT_STRICTATIME 0x80
  28. #define MNT_SHRINKABLE 0x100
  29. #define MNT_WRITE_HOLD 0x200
  30. #define MNT_SHARED 0x1000 /* if the vfsmount is a shared mount */
  31. #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
  32. #define MNT_PNODE_MASK 0x3000 /* propagation flag mask */
  33. struct vfsmount {
  34. struct list_head mnt_hash;
  35. struct vfsmount *mnt_parent; /* fs we are mounted on */
  36. struct dentry *mnt_mountpoint; /* dentry of mountpoint */
  37. struct dentry *mnt_root; /* root of the mounted tree */
  38. struct super_block *mnt_sb; /* pointer to superblock */
  39. struct list_head mnt_mounts; /* list of children, anchored here */
  40. struct list_head mnt_child; /* and going through their mnt_child */
  41. int mnt_flags;
  42. /* 4 bytes hole on 64bits arches */
  43. const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
  44. struct list_head mnt_list;
  45. struct list_head mnt_expire; /* link in fs-specific expiry list */
  46. struct list_head mnt_share; /* circular list of shared mounts */
  47. struct list_head mnt_slave_list;/* list of slave mounts */
  48. struct list_head mnt_slave; /* slave list entry */
  49. struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */
  50. struct mnt_namespace *mnt_ns; /* containing namespace */
  51. int mnt_id; /* mount identifier */
  52. int mnt_group_id; /* peer group identifier */
  53. /*
  54. * We put mnt_count & mnt_expiry_mark at the end of struct vfsmount
  55. * to let these frequently modified fields in a separate cache line
  56. * (so that reads of mnt_flags wont ping-pong on SMP machines)
  57. */
  58. atomic_t mnt_count;
  59. int mnt_expiry_mark; /* true if marked for expiry */
  60. int mnt_pinned;
  61. int mnt_ghosts;
  62. #ifdef CONFIG_SMP
  63. int __percpu *mnt_writers;
  64. #else
  65. int mnt_writers;
  66. #endif
  67. };
  68. static inline int *get_mnt_writers_ptr(struct vfsmount *mnt)
  69. {
  70. #ifdef CONFIG_SMP
  71. return mnt->mnt_writers;
  72. #else
  73. return &mnt->mnt_writers;
  74. #endif
  75. }
  76. static inline struct vfsmount *mntget(struct vfsmount *mnt)
  77. {
  78. if (mnt)
  79. atomic_inc(&mnt->mnt_count);
  80. return mnt;
  81. }
  82. struct file; /* forward dec */
  83. extern int mnt_want_write(struct vfsmount *mnt);
  84. extern int mnt_want_write_file(struct file *file);
  85. extern int mnt_clone_write(struct vfsmount *mnt);
  86. extern void mnt_drop_write(struct vfsmount *mnt);
  87. extern void mntput_no_expire(struct vfsmount *mnt);
  88. extern void mnt_pin(struct vfsmount *mnt);
  89. extern void mnt_unpin(struct vfsmount *mnt);
  90. extern int __mnt_is_readonly(struct vfsmount *mnt);
  91. static inline void mntput(struct vfsmount *mnt)
  92. {
  93. if (mnt) {
  94. mnt->mnt_expiry_mark = 0;
  95. mntput_no_expire(mnt);
  96. }
  97. }
  98. extern struct vfsmount *do_kern_mount(const char *fstype, int flags,
  99. const char *name, void *data);
  100. struct file_system_type;
  101. extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
  102. int flags, const char *name,
  103. void *data);
  104. struct nameidata;
  105. struct path;
  106. extern int do_add_mount(struct vfsmount *newmnt, struct path *path,
  107. int mnt_flags, struct list_head *fslist);
  108. extern void mark_mounts_for_expiry(struct list_head *mounts);
  109. extern spinlock_t vfsmount_lock;
  110. extern dev_t name_to_dev_t(char *name);
  111. #endif /* _LINUX_MOUNT_H */