diff options
-rw-r--r-- | fs/seq_file.c | 18 | ||||
-rw-r--r-- | include/linux/seq_file.h | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index 38bb59f3f2ad..774c1eb7f1c9 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
@@ -599,6 +599,24 @@ int single_open(struct file *file, int (*show)(struct seq_file *, void *), | |||
599 | } | 599 | } |
600 | EXPORT_SYMBOL(single_open); | 600 | EXPORT_SYMBOL(single_open); |
601 | 601 | ||
602 | int single_open_size(struct file *file, int (*show)(struct seq_file *, void *), | ||
603 | void *data, size_t size) | ||
604 | { | ||
605 | char *buf = kmalloc(size, GFP_KERNEL); | ||
606 | int ret; | ||
607 | if (!buf) | ||
608 | return -ENOMEM; | ||
609 | ret = single_open(file, show, data); | ||
610 | if (ret) { | ||
611 | kfree(buf); | ||
612 | return ret; | ||
613 | } | ||
614 | ((struct seq_file *)file->private_data)->buf = buf; | ||
615 | ((struct seq_file *)file->private_data)->size = size; | ||
616 | return 0; | ||
617 | } | ||
618 | EXPORT_SYMBOL(single_open_size); | ||
619 | |||
602 | int single_release(struct inode *inode, struct file *file) | 620 | int single_release(struct inode *inode, struct file *file) |
603 | { | 621 | { |
604 | const struct seq_operations *op = ((struct seq_file *)file->private_data)->op; | 622 | const struct seq_operations *op = ((struct seq_file *)file->private_data)->op; |
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index 68a04a343cad..2da29ac178fc 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h | |||
@@ -123,6 +123,7 @@ static inline int seq_nodemask_list(struct seq_file *m, nodemask_t *mask) | |||
123 | } | 123 | } |
124 | 124 | ||
125 | int single_open(struct file *, int (*)(struct seq_file *, void *), void *); | 125 | int single_open(struct file *, int (*)(struct seq_file *, void *), void *); |
126 | int single_open_size(struct file *, int (*)(struct seq_file *, void *), void *, size_t); | ||
126 | int single_release(struct inode *, struct file *); | 127 | int single_release(struct inode *, struct file *); |
127 | void *__seq_open_private(struct file *, const struct seq_operations *, int); | 128 | void *__seq_open_private(struct file *, const struct seq_operations *, int); |
128 | int seq_open_private(struct file *, const struct seq_operations *, int); | 129 | int seq_open_private(struct file *, const struct seq_operations *, int); |