Commit 6ce6e24e authored by Al Viro's avatar Al Viro

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: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent f7a99c5b
...@@ -74,10 +74,12 @@ static inline void get_mnt_ns(struct mnt_namespace *ns) ...@@ -74,10 +74,12 @@ static inline void get_mnt_ns(struct mnt_namespace *ns)
} }
struct proc_mounts { struct proc_mounts {
struct seq_file m; /* must be the first element */ struct seq_file m;
struct mnt_namespace *ns; struct mnt_namespace *ns;
struct path root; struct path root;
int (*show)(struct seq_file *, struct vfsmount *); int (*show)(struct seq_file *, struct vfsmount *);
}; };
#define proc_mounts(p) (container_of((p), struct proc_mounts, m))
extern const struct seq_operations mounts_op; extern const struct seq_operations mounts_op;
...@@ -923,7 +923,7 @@ EXPORT_SYMBOL(replace_mount_options); ...@@ -923,7 +923,7 @@ EXPORT_SYMBOL(replace_mount_options);
/* iterator; we want it to have access to namespace_sem, thus here... */ /* iterator; we want it to have access to namespace_sem, thus here... */
static void *m_start(struct seq_file *m, loff_t *pos) static void *m_start(struct seq_file *m, loff_t *pos)
{ {
struct proc_mounts *p = container_of(m, struct proc_mounts, m); struct proc_mounts *p = proc_mounts(m);
down_read(&namespace_sem); down_read(&namespace_sem);
return seq_list_start(&p->ns->list, *pos); return seq_list_start(&p->ns->list, *pos);
...@@ -931,7 +931,7 @@ static void *m_start(struct seq_file *m, loff_t *pos) ...@@ -931,7 +931,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
static void *m_next(struct seq_file *m, void *v, loff_t *pos) static void *m_next(struct seq_file *m, void *v, loff_t *pos)
{ {
struct proc_mounts *p = container_of(m, struct proc_mounts, m); struct proc_mounts *p = proc_mounts(m);
return seq_list_next(v, &p->ns->list, pos); return seq_list_next(v, &p->ns->list, pos);
} }
...@@ -943,7 +943,7 @@ static void m_stop(struct seq_file *m, void *v) ...@@ -943,7 +943,7 @@ static void m_stop(struct seq_file *m, void *v)
static int m_show(struct seq_file *m, void *v) static int m_show(struct seq_file *m, void *v)
{ {
struct proc_mounts *p = container_of(m, struct proc_mounts, m); struct proc_mounts *p = proc_mounts(m);
struct mount *r = list_entry(v, struct mount, mnt_list); struct mount *r = list_entry(v, struct mount, mnt_list);
return p->show(m, &r->mnt); return p->show(m, &r->mnt);
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
static unsigned mounts_poll(struct file *file, poll_table *wait) static unsigned mounts_poll(struct file *file, poll_table *wait)
{ {
struct proc_mounts *p = file->private_data; struct proc_mounts *p = proc_mounts(file->private_data);
struct mnt_namespace *ns = p->ns; struct mnt_namespace *ns = p->ns;
unsigned res = POLLIN | POLLRDNORM; unsigned res = POLLIN | POLLRDNORM;
...@@ -121,7 +121,7 @@ static int show_vfsmnt(struct seq_file *m, struct vfsmount *mnt) ...@@ -121,7 +121,7 @@ static int show_vfsmnt(struct seq_file *m, struct vfsmount *mnt)
static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt) static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt)
{ {
struct proc_mounts *p = m->private; struct proc_mounts *p = proc_mounts(m);
struct mount *r = real_mount(mnt); struct mount *r = real_mount(mnt);
struct super_block *sb = mnt->mnt_sb; struct super_block *sb = mnt->mnt_sb;
struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; 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,7 +268,6 @@ static int mounts_open_common(struct inode *inode, struct file *file,
if (ret) if (ret)
goto err_free; goto err_free;
p->m.private = p;
p->ns = ns; p->ns = ns;
p->root = root; p->root = root;
p->m.poll_event = ns->event; p->m.poll_event = ns->event;
...@@ -288,7 +287,7 @@ static int mounts_open_common(struct inode *inode, struct file *file, ...@@ -288,7 +287,7 @@ static int mounts_open_common(struct inode *inode, struct file *file,
static int mounts_release(struct inode *inode, struct file *file) static int mounts_release(struct inode *inode, struct file *file)
{ {
struct proc_mounts *p = file->private_data; struct proc_mounts *p = proc_mounts(file->private_data);
path_put(&p->root); path_put(&p->root);
put_mnt_ns(p->ns); put_mnt_ns(p->ns);
return seq_release(inode, file); return seq_release(inode, file);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment