mount.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #include <linux/mount.h>
  2. #include <linux/seq_file.h>
  3. #include <linux/poll.h>
  4. struct mnt_namespace {
  5. atomic_t count;
  6. unsigned int proc_inum;
  7. struct mount * root;
  8. struct list_head list;
  9. struct user_namespace *user_ns;
  10. u64 seq; /* Sequence number to prevent loops */
  11. wait_queue_head_t poll;
  12. int event;
  13. };
  14. struct mnt_pcp {
  15. int mnt_count;
  16. int mnt_writers;
  17. };
  18. struct mountpoint {
  19. struct list_head m_hash;
  20. struct dentry *m_dentry;
  21. int m_count;
  22. };
  23. struct mount {
  24. struct list_head mnt_hash;
  25. struct mount *mnt_parent;
  26. struct dentry *mnt_mountpoint;
  27. struct vfsmount mnt;
  28. struct rcu_head mnt_rcu;
  29. #ifdef CONFIG_SMP
  30. struct mnt_pcp __percpu *mnt_pcp;
  31. #else
  32. int mnt_count;
  33. int mnt_writers;
  34. #endif
  35. struct list_head mnt_mounts; /* list of children, anchored here */
  36. struct list_head mnt_child; /* and going through their mnt_child */
  37. struct list_head mnt_instance; /* mount instance on sb->s_mounts */
  38. const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
  39. struct list_head mnt_list;
  40. struct list_head mnt_expire; /* link in fs-specific expiry list */
  41. struct list_head mnt_share; /* circular list of shared mounts */
  42. struct list_head mnt_slave_list;/* list of slave mounts */
  43. struct list_head mnt_slave; /* slave list entry */
  44. struct mount *mnt_master; /* slave is on master->mnt_slave_list */
  45. struct mnt_namespace *mnt_ns; /* containing namespace */
  46. struct mountpoint *mnt_mp; /* where is it mounted */
  47. #ifdef CONFIG_FSNOTIFY
  48. struct hlist_head mnt_fsnotify_marks;
  49. __u32 mnt_fsnotify_mask;
  50. #endif
  51. int mnt_id; /* mount identifier */
  52. int mnt_group_id; /* peer group identifier */
  53. int mnt_expiry_mark; /* true if marked for expiry */
  54. int mnt_pinned;
  55. struct path mnt_ex_mountpoint;
  56. };
  57. #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
  58. static inline struct mount *real_mount(struct vfsmount *mnt)
  59. {
  60. return container_of(mnt, struct mount, mnt);
  61. }
  62. static inline int mnt_has_parent(struct mount *mnt)
  63. {
  64. return mnt != mnt->mnt_parent;
  65. }
  66. static inline int is_mounted(struct vfsmount *mnt)
  67. {
  68. /* neither detached nor internal? */
  69. return !IS_ERR_OR_NULL(real_mount(mnt));
  70. }
  71. extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *);
  72. extern struct mount *__lookup_mnt_last(struct vfsmount *, struct dentry *);
  73. extern bool legitimize_mnt(struct vfsmount *, unsigned);
  74. static inline void get_mnt_ns(struct mnt_namespace *ns)
  75. {
  76. atomic_inc(&ns->count);
  77. }
  78. extern seqlock_t mount_lock;
  79. static inline void lock_mount_hash(void)
  80. {
  81. write_seqlock(&mount_lock);
  82. }
  83. static inline void unlock_mount_hash(void)
  84. {
  85. write_sequnlock(&mount_lock);
  86. }
  87. struct proc_mounts {
  88. struct seq_file m;
  89. struct mnt_namespace *ns;
  90. struct path root;
  91. int (*show)(struct seq_file *, struct vfsmount *);
  92. };
  93. #define proc_mounts(p) (container_of((p), struct proc_mounts, m))
  94. extern const struct seq_operations mounts_op;