Commit e42270a1 authored by David Howells's avatar David Howells Committed by Al Viro

reiserfs: Don't access the proc_dir_entry in r_open(), r_start() r_show()

Don't access the proc_dir_entry in ReiserFS's r_open(), r_start() r_show()
procfs interface functions.

ReiserFS stores the ->show() method pointer in PDE->data and the super_block
pointer in PDE->parent->data.  This isn't changing.

Currently, ReiserFS passes the PDE pointer into seq_file::private from
r_open() so that r_start() and r_show() can then access it.  Instead, use
seq_open_private() to allocate a two-pointer struct that's passed through
seq_file::private and put the ->show() method and the sb pointers in there.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
cc: reiserfs-devel@vger.kernel.org
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 4a520d27
...@@ -394,20 +394,24 @@ static int set_sb(struct super_block *sb, void *data) ...@@ -394,20 +394,24 @@ static int set_sb(struct super_block *sb, void *data)
return -ENOENT; return -ENOENT;
} }
struct reiserfs_seq_private {
struct super_block *sb;
int (*show) (struct seq_file *, struct super_block *);
};
static void *r_start(struct seq_file *m, loff_t * pos) static void *r_start(struct seq_file *m, loff_t * pos)
{ {
struct proc_dir_entry *de = m->private; struct reiserfs_seq_private *priv = m->private;
struct super_block *s = de->parent->data;
loff_t l = *pos; loff_t l = *pos;
if (l) if (l)
return NULL; return NULL;
if (IS_ERR(sget(&reiserfs_fs_type, test_sb, set_sb, 0, s))) if (IS_ERR(sget(&reiserfs_fs_type, test_sb, set_sb, 0, priv->sb)))
return NULL; return NULL;
up_write(&s->s_umount); up_write(&priv->sb->s_umount);
return s; return priv->sb;
} }
static void *r_next(struct seq_file *m, void *v, loff_t * pos) static void *r_next(struct seq_file *m, void *v, loff_t * pos)
...@@ -426,9 +430,8 @@ static void r_stop(struct seq_file *m, void *v) ...@@ -426,9 +430,8 @@ static void r_stop(struct seq_file *m, void *v)
static int r_show(struct seq_file *m, void *v) static int r_show(struct seq_file *m, void *v)
{ {
struct proc_dir_entry *de = m->private; struct reiserfs_seq_private *priv = m->private;
int (*show) (struct seq_file *, struct super_block *) = de->data; return priv->show(m, v);
return show(m, v);
} }
static const struct seq_operations r_ops = { static const struct seq_operations r_ops = {
...@@ -440,11 +443,15 @@ static const struct seq_operations r_ops = { ...@@ -440,11 +443,15 @@ static const struct seq_operations r_ops = {
static int r_open(struct inode *inode, struct file *file) static int r_open(struct inode *inode, struct file *file)
{ {
int ret = seq_open(file, &r_ops); struct reiserfs_seq_private *priv;
int ret = seq_open_private(file, &r_ops,
sizeof(struct reiserfs_seq_private));
if (!ret) { if (!ret) {
struct seq_file *m = file->private_data; struct seq_file *m = file->private_data;
m->private = PDE(inode); priv = m->private;
priv->sb = proc_get_parent_data(inode);
priv->show = PDE_DATA(inode);
} }
return ret; return ret;
} }
...@@ -453,7 +460,7 @@ static const struct file_operations r_file_operations = { ...@@ -453,7 +460,7 @@ static const struct file_operations r_file_operations = {
.open = r_open, .open = r_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
.release = seq_release, .release = seq_release_private,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
......
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