blob: e9c37dd3d00dbc958107f2d2165a5207d5a26934 [file] [log] [blame]
Al Virob2dba1a2011-11-23 19:26:23 -05001#include <linux/mount.h>
Al Viro0226f492011-12-06 12:21:54 -05002#include <linux/seq_file.h>
3#include <linux/poll.h>
4
5struct mnt_namespace {
6 atomic_t count;
Al Virobe08d6d2011-12-06 13:32:36 -05007 struct mount * root;
Al Viro0226f492011-12-06 12:21:54 -05008 struct list_head list;
Eric W. Biederman8823c072010-03-07 18:49:36 -08009 u64 seq; /* Sequence number to prevent loops */
Al Viro0226f492011-12-06 12:21:54 -050010 wait_queue_head_t poll;
11 int event;
12};
Al Virob2dba1a2011-11-23 19:26:23 -050013
Al Viro68e8a9f2011-11-24 22:53:09 -050014struct mnt_pcp {
15 int mnt_count;
16 int mnt_writers;
17};
18
Al Viro7d6fec42011-11-23 12:14:10 -050019struct mount {
Al Viro1b8e5562011-11-24 21:01:32 -050020 struct list_head mnt_hash;
Al Viro0714a532011-11-24 22:19:58 -050021 struct mount *mnt_parent;
Al Viroa73324d2011-11-24 22:25:07 -050022 struct dentry *mnt_mountpoint;
Al Viro7d6fec42011-11-23 12:14:10 -050023 struct vfsmount mnt;
Al Viro68e8a9f2011-11-24 22:53:09 -050024#ifdef CONFIG_SMP
25 struct mnt_pcp __percpu *mnt_pcp;
Al Viro68e8a9f2011-11-24 22:53:09 -050026#else
27 int mnt_count;
28 int mnt_writers;
29#endif
Al Viro6b41d532011-11-24 23:24:33 -050030 struct list_head mnt_mounts; /* list of children, anchored here */
31 struct list_head mnt_child; /* and going through their mnt_child */
Miklos Szeredi39f7c4d2011-11-21 12:11:30 +010032 struct list_head mnt_instance; /* mount instance on sb->s_mounts */
Al Viro52ba1622011-11-25 02:25:17 -050033 const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
Al Viro1a4eeaf2011-11-25 02:19:55 -050034 struct list_head mnt_list;
Al Viro6776db3d2011-11-25 00:22:05 -050035 struct list_head mnt_expire; /* link in fs-specific expiry list */
36 struct list_head mnt_share; /* circular list of shared mounts */
37 struct list_head mnt_slave_list;/* list of slave mounts */
38 struct list_head mnt_slave; /* slave list entry */
Al Viro32301922011-11-25 00:10:28 -050039 struct mount *mnt_master; /* slave is on master->mnt_slave_list */
Al Viro143c8c92011-11-25 00:46:35 -050040 struct mnt_namespace *mnt_ns; /* containing namespace */
Al Viroc63181e2011-11-25 02:35:16 -050041#ifdef CONFIG_FSNOTIFY
42 struct hlist_head mnt_fsnotify_marks;
43 __u32 mnt_fsnotify_mask;
44#endif
Al Viro15169fe2011-11-25 00:50:41 -050045 int mnt_id; /* mount identifier */
46 int mnt_group_id; /* peer group identifier */
Al Viro863d6842011-11-25 00:57:42 -050047 int mnt_expiry_mark; /* true if marked for expiry */
48 int mnt_pinned;
49 int mnt_ghosts;
Al Viro7d6fec42011-11-23 12:14:10 -050050};
51
Al Virof7a99c52012-06-09 00:59:08 -040052#define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
53
Al Viro7d6fec42011-11-23 12:14:10 -050054static inline struct mount *real_mount(struct vfsmount *mnt)
55{
56 return container_of(mnt, struct mount, mnt);
57}
58
Al Viro676da582011-11-24 21:47:05 -050059static inline int mnt_has_parent(struct mount *mnt)
Al Virob2dba1a2011-11-23 19:26:23 -050060{
Al Viro0714a532011-11-24 22:19:58 -050061 return mnt != mnt->mnt_parent;
Al Virob2dba1a2011-11-23 19:26:23 -050062}
Al Viroc7105362011-11-24 18:22:03 -050063
Al Virof7a99c52012-06-09 00:59:08 -040064static inline int is_mounted(struct vfsmount *mnt)
65{
66 /* neither detached nor internal? */
67 return !IS_ERR_OR_NULL(real_mount(mnt));
68}
69
Al Viroc7105362011-11-24 18:22:03 -050070extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int);
Al Viro0226f492011-12-06 12:21:54 -050071
72static inline void get_mnt_ns(struct mnt_namespace *ns)
73{
74 atomic_inc(&ns->count);
75}
76
77struct proc_mounts {
Al Viro6ce6e242012-06-09 01:16:59 -040078 struct seq_file m;
Al Viro0226f492011-12-06 12:21:54 -050079 struct mnt_namespace *ns;
80 struct path root;
81 int (*show)(struct seq_file *, struct vfsmount *);
82};
83
Al Viro6ce6e242012-06-09 01:16:59 -040084#define proc_mounts(p) (container_of((p), struct proc_mounts, m))
85
Al Viro0226f492011-12-06 12:21:54 -050086extern const struct seq_operations mounts_op;