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: David Howells <dhowells@redhat.com>
cc: reiserfs-devel@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
David Howells 2013-04-12 11:17:06 +01:00 committed by Al Viro
parent 4a520d2769
commit e42270a19e

View File

@ -394,20 +394,24 @@ static int set_sb(struct super_block *sb, void *data)
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)
{
struct proc_dir_entry *de = m->private;
struct super_block *s = de->parent->data;
struct reiserfs_seq_private *priv = m->private;
loff_t l = *pos;
if (l)
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;
up_write(&s->s_umount);
return s;
up_write(&priv->sb->s_umount);
return priv->sb;
}
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)
static int r_show(struct seq_file *m, void *v)
{
struct proc_dir_entry *de = m->private;
int (*show) (struct seq_file *, struct super_block *) = de->data;
return show(m, v);
struct reiserfs_seq_private *priv = m->private;
return priv->show(m, v);
}
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)
{
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) {
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;
}
@ -453,7 +460,7 @@ static const struct file_operations r_file_operations = {
.open = r_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
.release = seq_release_private,
.owner = THIS_MODULE,
};