diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-10-10 02:28:42 -0700 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 16:55:33 -0700 |
commit | 39699037a5c94d7cd1363dfe48a50c78c643fd9a (patch) | |
tree | ea5a0ab329dbe43531c3b713536e45491e1cb51f /fs/seq_file.c | |
parent | 59e90b2d22500f2e9cc635793562154abc8f4621 (diff) | |
download | kernel_samsung_aries-39699037a5c94d7cd1363dfe48a50c78c643fd9a.zip kernel_samsung_aries-39699037a5c94d7cd1363dfe48a50c78c643fd9a.tar.gz kernel_samsung_aries-39699037a5c94d7cd1363dfe48a50c78c643fd9a.tar.bz2 |
[FS] seq_file: Introduce the seq_open_private()
This function allocates the zeroed chunk of memory and
call seq_open(). The __seq_open_private() helper returns
the allocated memory to make it possible for the caller
to initialize it.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'fs/seq_file.c')
-rw-r--r-- | fs/seq_file.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index bbb19be..ca71c11 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -429,6 +429,39 @@ int seq_release_private(struct inode *inode, struct file *file) } EXPORT_SYMBOL(seq_release_private); +void *__seq_open_private(struct file *f, const struct seq_operations *ops, + int psize) +{ + int rc; + void *private; + struct seq_file *seq; + + private = kzalloc(psize, GFP_KERNEL); + if (private == NULL) + goto out; + + rc = seq_open(f, ops); + if (rc < 0) + goto out_free; + + seq = f->private_data; + seq->private = private; + return private; + +out_free: + kfree(private); +out: + return NULL; +} +EXPORT_SYMBOL(__seq_open_private); + +int seq_open_private(struct file *filp, const struct seq_operations *ops, + int psize) +{ + return __seq_open_private(filp, ops, psize) ? 0 : -ENOMEM; +} +EXPORT_SYMBOL(seq_open_private); + int seq_putc(struct seq_file *m, char c) { if (m->count < m->size) { |