diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-06-09 01:16:59 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-14 08:32:48 -0400 |
commit | 6ce6e24e72233073c8ead9419fc5040d44803dae (patch) | |
tree | b66a74dd7aef822b4bc573ab283e21320bcc0b25 | |
parent | f7a99c5b7c8bd3d3f533c8b38274e33f3da9096e (diff) |
get rid of magic in proc_namespace.c
don't rely on proc_mounts->m being the first field; container_of()
is there for purpose. No need to bother with ->private, while
we are at it - the same container_of will do nicely.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/mount.h | 4 | ||||
-rw-r--r-- | fs/namespace.c | 6 | ||||
-rw-r--r-- | fs/proc_namespace.c | 7 |
3 files changed, 9 insertions, 8 deletions
diff --git a/fs/mount.h b/fs/mount.h index 05a2a1185efc..4f291f9de641 100644 --- a/fs/mount.h +++ b/fs/mount.h | |||
@@ -74,10 +74,12 @@ static inline void get_mnt_ns(struct mnt_namespace *ns) | |||
74 | } | 74 | } |
75 | 75 | ||
76 | struct proc_mounts { | 76 | struct proc_mounts { |
77 | struct seq_file m; /* must be the first element */ | 77 | struct seq_file m; |
78 | struct mnt_namespace *ns; | 78 | struct mnt_namespace *ns; |
79 | struct path root; | 79 | struct path root; |
80 | int (*show)(struct seq_file *, struct vfsmount *); | 80 | int (*show)(struct seq_file *, struct vfsmount *); |
81 | }; | 81 | }; |
82 | 82 | ||
83 | #define proc_mounts(p) (container_of((p), struct proc_mounts, m)) | ||
84 | |||
83 | extern const struct seq_operations mounts_op; | 85 | extern const struct seq_operations mounts_op; |
diff --git a/fs/namespace.c b/fs/namespace.c index a524ea4dbd80..8f412abcb67f 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -923,7 +923,7 @@ EXPORT_SYMBOL(replace_mount_options); | |||
923 | /* iterator; we want it to have access to namespace_sem, thus here... */ | 923 | /* iterator; we want it to have access to namespace_sem, thus here... */ |
924 | static void *m_start(struct seq_file *m, loff_t *pos) | 924 | static void *m_start(struct seq_file *m, loff_t *pos) |
925 | { | 925 | { |
926 | struct proc_mounts *p = container_of(m, struct proc_mounts, m); | 926 | struct proc_mounts *p = proc_mounts(m); |
927 | 927 | ||
928 | down_read(&namespace_sem); | 928 | down_read(&namespace_sem); |
929 | return seq_list_start(&p->ns->list, *pos); | 929 | return seq_list_start(&p->ns->list, *pos); |
@@ -931,7 +931,7 @@ static void *m_start(struct seq_file *m, loff_t *pos) | |||
931 | 931 | ||
932 | static void *m_next(struct seq_file *m, void *v, loff_t *pos) | 932 | static void *m_next(struct seq_file *m, void *v, loff_t *pos) |
933 | { | 933 | { |
934 | struct proc_mounts *p = container_of(m, struct proc_mounts, m); | 934 | struct proc_mounts *p = proc_mounts(m); |
935 | 935 | ||
936 | return seq_list_next(v, &p->ns->list, pos); | 936 | return seq_list_next(v, &p->ns->list, pos); |
937 | } | 937 | } |
@@ -943,7 +943,7 @@ static void m_stop(struct seq_file *m, void *v) | |||
943 | 943 | ||
944 | static int m_show(struct seq_file *m, void *v) | 944 | static int m_show(struct seq_file *m, void *v) |
945 | { | 945 | { |
946 | struct proc_mounts *p = container_of(m, struct proc_mounts, m); | 946 | struct proc_mounts *p = proc_mounts(m); |
947 | struct mount *r = list_entry(v, struct mount, mnt_list); | 947 | struct mount *r = list_entry(v, struct mount, mnt_list); |
948 | return p->show(m, &r->mnt); | 948 | return p->show(m, &r->mnt); |
949 | } | 949 | } |
diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c index 5e289a7cbad1..5fe34c355e85 100644 --- a/fs/proc_namespace.c +++ b/fs/proc_namespace.c | |||
@@ -17,7 +17,7 @@ | |||
17 | 17 | ||
18 | static unsigned mounts_poll(struct file *file, poll_table *wait) | 18 | static unsigned mounts_poll(struct file *file, poll_table *wait) |
19 | { | 19 | { |
20 | struct proc_mounts *p = file->private_data; | 20 | struct proc_mounts *p = proc_mounts(file->private_data); |
21 | struct mnt_namespace *ns = p->ns; | 21 | struct mnt_namespace *ns = p->ns; |
22 | unsigned res = POLLIN | POLLRDNORM; | 22 | unsigned res = POLLIN | POLLRDNORM; |
23 | 23 | ||
@@ -121,7 +121,7 @@ out: | |||
121 | 121 | ||
122 | static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt) | 122 | static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt) |
123 | { | 123 | { |
124 | struct proc_mounts *p = m->private; | 124 | struct proc_mounts *p = proc_mounts(m); |
125 | struct mount *r = real_mount(mnt); | 125 | struct mount *r = real_mount(mnt); |
126 | struct super_block *sb = mnt->mnt_sb; | 126 | struct super_block *sb = mnt->mnt_sb; |
127 | struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; | 127 | struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; |
@@ -268,7 +268,6 @@ static int mounts_open_common(struct inode *inode, struct file *file, | |||
268 | if (ret) | 268 | if (ret) |
269 | goto err_free; | 269 | goto err_free; |
270 | 270 | ||
271 | p->m.private = p; | ||
272 | p->ns = ns; | 271 | p->ns = ns; |
273 | p->root = root; | 272 | p->root = root; |
274 | p->m.poll_event = ns->event; | 273 | p->m.poll_event = ns->event; |
@@ -288,7 +287,7 @@ static int mounts_open_common(struct inode *inode, struct file *file, | |||
288 | 287 | ||
289 | static int mounts_release(struct inode *inode, struct file *file) | 288 | static int mounts_release(struct inode *inode, struct file *file) |
290 | { | 289 | { |
291 | struct proc_mounts *p = file->private_data; | 290 | struct proc_mounts *p = proc_mounts(file->private_data); |
292 | path_put(&p->root); | 291 | path_put(&p->root); |
293 | put_mnt_ns(p->ns); | 292 | put_mnt_ns(p->ns); |
294 | return seq_release(inode, file); | 293 | return seq_release(inode, file); |