From: Pavel Emelyanov <xemul@openvz.org>
To: David Miller <davem@davemloft.net>
Cc: Linux Netdev List <netdev@vger.kernel.org>, devel@openvz.org
Subject: [PATCH 1/6][NET-2.6.24] Introduce the seq_open_private()
Date: Tue, 09 Oct 2007 19:52:58 +0400 [thread overview]
Message-ID: <470BA3DA.6050905@openvz.org> (raw)
In-Reply-To: <470BA351.3070208@openvz.org>
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>
---
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 *in
}
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) {
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 83783ab..8bf1e05 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -46,6 +46,8 @@ int seq_path(struct seq_file *, struct v
int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
int single_release(struct inode *, struct file *);
+void *__seq_open_private(struct file *, const struct seq_operations *, int);
+int seq_open_private(struct file *, const struct seq_operations *, int);
int seq_release_private(struct inode *, struct file *);
#define SEQ_START_TOKEN ((void *)1)
next prev parent reply other threads:[~2007-10-09 15:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-09 15:50 [PATCH 0/6][NET-2.6.24] Consolidate private allocations in seq files Pavel Emelyanov
2007-10-09 15:52 ` Pavel Emelyanov [this message]
2007-10-10 9:32 ` [PATCH 1/6][NET-2.6.24] Introduce the seq_open_private() David Miller
2007-10-09 15:55 ` [PATCH 2/6][NET-2.6.24] Make core networking code use seq_open_private Pavel Emelyanov
2007-10-10 9:32 ` David Miller
2007-10-09 15:57 ` [PATCH 3/6][NET-2.6.24] Make netfilter code use the seq_open_private Pavel Emelyanov
2007-10-10 9:33 ` David Miller
2007-10-09 15:59 ` [PATCH 4/6][NET-2.6.24] Make decnet code use the seq_open_private() Pavel Emelyanov
2007-10-10 9:33 ` David Miller
2007-10-09 16:01 ` [PATCH 5/6][NET-2.6.24] Make the IRDA " Pavel Emelyanov
2007-10-10 9:33 ` David Miller
2007-10-09 16:04 ` [PATCH 6/6][NET-2.6.24] Make the sunrpc " Pavel Emelyanov
2007-10-10 9:33 ` David Miller
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=470BA3DA.6050905@openvz.org \
--to=xemul@openvz.org \
--cc=davem@davemloft.net \
--cc=devel@openvz.org \
--cc=netdev@vger.kernel.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).