linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/18] allow callers of seq_open do allocation themselves
@ 2005-11-08  2:01 Al Viro
  2005-11-08  3:03 ` [OT] " Randy.Dunlap
  2005-11-08 20:33 ` Jonathan Corbet
  0 siblings, 2 replies; 8+ messages in thread
From: Al Viro @ 2005-11-08  2:01 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, linux-fsdevel, linuxram

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-11-08 20:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-08  2:01 [PATCH 3/18] allow callers of seq_open do allocation themselves Al Viro
2005-11-08  3:03 ` [OT] " 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

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).