From: Al Viro <viro@ftp.linux.org.uk>
To: torvalds@osdl.org
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linuxram@us.ibm.com
Subject: [PATCH 3/18] allow callers of seq_open do allocation themselves
Date: Tue, 08 Nov 2005 02:01:31 +0000 [thread overview]
Message-ID: <E1EZInj-0001Eh-9T@ZenIV.linux.org.uk> (raw)
From: Al Viro <viro@zeniv.linux.org.uk>
Date: 1131401734 -0500
Allows 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>
---
fs/seq_file.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
57865a0565080cc56de9aa5369ea1fc2b6477398
diff --git a/fs/seq_file.c b/fs/seq_file.c
--- 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
next reply other threads:[~2005-11-08 2:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-08 2:01 Al Viro [this message]
2005-11-08 3:03 ` [OT] Re: [PATCH 3/18] allow callers of seq_open do allocation themselves Randy.Dunlap
2005-11-08 3:24 ` Neil Brown
2005-11-08 3:12 ` Randy.Dunlap
2005-11-08 3:30 ` Al Viro
2005-11-08 3:48 ` Linus Torvalds
2005-11-08 3:45 ` Linus Torvalds
2005-11-08 20:33 ` Jonathan Corbet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1EZInj-0001Eh-9T@ZenIV.linux.org.uk \
--to=viro@ftp.linux.org.uk \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxram@us.ibm.com \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).