diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2005-11-07 23:15:34 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-08 03:18:09 +0100 |
commit | 1abe77b0fc4b485927f1f798ae81a752677e1d05 (patch) | |
tree | f7a2de3728fa475975144310e67b643c446e5a6f /fs | |
parent | [PATCH] cleanups and bug fix in do_loopback() (diff) | |
download | linux-1abe77b0fc4b485927f1f798ae81a752677e1d05.tar.xz linux-1abe77b0fc4b485927f1f798ae81a752677e1d05.zip |
[PATCH] allow callers of seq_open do allocation themselves
Allow caller of seq_open() to kmalloc() seq_file + whatever else they
want and set ->private_data to it. seq_open() will then abstain from
doing allocation itself.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/seq_file.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index 38ef913767ff..7c40570b71dc 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -28,13 +28,17 @@ */ int seq_open(struct file *file, struct seq_operations *op) { - struct seq_file *p = kmalloc(sizeof(*p), GFP_KERNEL); - if (!p) - return -ENOMEM; + struct seq_file *p = file->private_data; + + if (!p) { + p = kmalloc(sizeof(*p), GFP_KERNEL); + if (!p) + return -ENOMEM; + file->private_data = p; + } memset(p, 0, sizeof(*p)); sema_init(&p->sem, 1); p->op = op; - file->private_data = p; /* * Wrappers around seq_open(e.g. swaps_open) need to be |