mount.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. * Version: $Id: mount.h,v 1.1.1.1 2007/06/12 07:27:16 eyryu Exp $
  9. *
  10. */
  11. #ifndef _LINUX_MOUNT_H
  12. #define _LINUX_MOUNT_H
  13. #ifdef __KERNEL__
  14. #include <linux/types.h>
  15. #include <linux/list.h>
  16. #include <linux/spinlock.h>
  17. #include <asm/atomic.h>
  18. struct super_block;
  19. struct vfsmount;
  20. struct dentry;
  21. struct mnt_namespace;
  22. #define MNT_NOSUID 0x01
  23. #define MNT_NODEV 0x02
  24. #define MNT_NOEXEC 0x04
  25. #define MNT_NOATIME 0x08
  26. #define MNT_NODIRATIME 0x10
  27. #define MNT_RELATIME 0x20
  28. #define MNT_SHRINKABLE 0x100
  29. #define MNT_SHARED 0x1000 /* if the vfsmount is a shared mount */
  30. #define MNT_UNBINDABLE 0x2000 /* if the vfsmount is a unbindable mount */
  31. #define MNT_PNODE_MASK 0x3000 /* propogation flag mask */
  32. struct vfsmount {
  33. struct list_head mnt_hash;
  34. struct vfsmount *mnt_parent; /* fs we are mounted on */
  35. struct dentry *mnt_mountpoint; /* dentry of mountpoint */
  36. struct dentry *mnt_root; /* root of the mounted tree */
  37. struct super_block *mnt_sb; /* pointer to superblock */
  38. struct list_head mnt_mounts; /* list of children, anchored here */
  39. struct list_head mnt_child; /* and going through their mnt_child */
  40. int mnt_flags;
  41. /* 4 bytes hole on 64bits arches */
  42. char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
  43. struct list_head mnt_list;
  44. struct list_head mnt_expire; /* link in fs-specific expiry list */
  45. struct list_head mnt_share; /* circular list of shared mounts */
  46. struct list_head mnt_slave_list;/* list of slave mounts */
  47. struct list_head mnt_slave; /* slave list entry */
  48. struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */
  49. struct mnt_namespace *mnt_ns; /* containing namespace */
  50. /*
  51. * We put mnt_count & mnt_expiry_mark at the end of struct vfsmount
  52. * to let these frequently modified fields in a separate cache line
  53. * (so that reads of mnt_flags wont ping-pong on SMP machines)
  54. */
  55. atomic_t mnt_count;
  56. int mnt_expiry_mark; /* true if marked for expiry */
  57. int mnt_pinned;
  58. };
  59. static inline struct vfsmount *mntget(struct vfsmount *mnt)
  60. {
  61. if (mnt)
  62. atomic_inc(&mnt->mnt_count);
  63. return mnt;
  64. }
  65. extern void mntput_no_expire(struct vfsmount *mnt);
  66. extern void mnt_pin(struct vfsmount *mnt);
  67. extern void mnt_unpin(struct vfsmount *mnt);
  68. static inline void mntput(struct vfsmount *mnt)
  69. {
  70. if (mnt) {
  71. mnt->mnt_expiry_mark = 0;
  72. mntput_no_expire(mnt);
  73. }
  74. }
  75. extern void free_vfsmnt(struct vfsmount *mnt);
  76. extern struct vfsmount *alloc_vfsmnt(const char *name);
  77. extern struct vfsmount *do_kern_mount(const char *fstype, int flags,
  78. const char *name, void *data);
  79. struct file_system_type;
  80. extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
  81. int flags, const char *name,
  82. void *data);
  83. struct nameidata;
  84. extern int do_add_mount(struct vfsmount *newmnt, struct nameidata *nd,
  85. int mnt_flags, struct list_head *fslist);
  86. extern void mark_mounts_for_expiry(struct list_head *mounts);
  87. extern void shrink_submounts(struct vfsmount *mountpoint, struct list_head *mounts);
  88. extern spinlock_t vfsmount_lock;
  89. extern dev_t name_to_dev_t(char *name);
  90. #endif
  91. #endif /* _LINUX_MOUNT_H */