summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2018-04-24 17:05:17 +0200
committerChristoph Hellwig <hch@lst.de>2018-05-16 07:23:35 +0200
commit44414d82cfe0f68cb59d0a42f599ccd893ae0032 (patch)
treef89c89cf2f7c919c22bcf3dac566c89eac6d2ff4 /fs
parentfddda2b7b521185f3aa018f9559eb33b0aee53a9 (diff)
proc: introduce proc_create_seq_private
Variant of proc_create_data that directly take a struct seq_operations argument + a private state size and drastically reduces the boilerplate code in the callers. All trivial callers converted over. Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/locks.c16
-rw-r--r--fs/proc/generic.c9
-rw-r--r--fs/proc/internal.h1
3 files changed, 9 insertions, 17 deletions
diff --git a/fs/locks.c b/fs/locks.c
index 62bbe8b31f26..05e211be8684 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -2788,22 +2788,10 @@ static const struct seq_operations locks_seq_operations = {
.show = locks_show,
};
-static int locks_open(struct inode *inode, struct file *filp)
-{
- return seq_open_private(filp, &locks_seq_operations,
- sizeof(struct locks_iterator));
-}
-
-static const struct file_operations proc_locks_operations = {
- .open = locks_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = seq_release_private,
-};
-
static int __init proc_locks_init(void)
{
- proc_create("locks", 0, NULL, &proc_locks_operations);
+ proc_create_seq_private("locks", 0, NULL, &locks_seq_operations,
+ sizeof(struct locks_iterator), NULL);
return 0;
}
fs_initcall(proc_locks_init);
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index af644caaaf85..f87cb0053387 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -560,6 +560,8 @@ static int proc_seq_open(struct inode *inode, struct file *file)
{
struct proc_dir_entry *de = PDE(inode);
+ if (de->state_size)
+ return seq_open_private(file, de->seq_ops, de->state_size);
return seq_open(file, de->seq_ops);
}
@@ -570,9 +572,9 @@ static const struct file_operations proc_seq_fops = {
.release = seq_release,
};
-struct proc_dir_entry *proc_create_seq_data(const char *name, umode_t mode,
+struct proc_dir_entry *proc_create_seq_private(const char *name, umode_t mode,
struct proc_dir_entry *parent, const struct seq_operations *ops,
- void *data)
+ unsigned int state_size, void *data)
{
struct proc_dir_entry *p;
@@ -581,9 +583,10 @@ struct proc_dir_entry *proc_create_seq_data(const char *name, umode_t mode,
return NULL;
p->proc_fops = &proc_seq_fops;
p->seq_ops = ops;
+ p->state_size = state_size;
return proc_register(parent, p);
}
-EXPORT_SYMBOL(proc_create_seq_data);
+EXPORT_SYMBOL(proc_create_seq_private);
void proc_set_size(struct proc_dir_entry *de, loff_t size)
{
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 4fb01c5f9c1a..bcfe830ffd59 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -46,6 +46,7 @@ struct proc_dir_entry {
const struct file_operations *proc_fops;
const struct seq_operations *seq_ops;
void *data;
+ unsigned int state_size;
unsigned int low_ino;
nlink_t nlink;
kuid_t uid;