* [PATCH] add seq file helpers from 2.5 (fwd)
@ 2003-07-10 3:02 Marcelo Tosatti
2003-07-10 5:04 ` Randy.Dunlap
2003-07-10 18:28 ` Chris Wright
0 siblings, 2 replies; 4+ messages in thread
From: Marcelo Tosatti @ 2003-07-10 3:02 UTC (permalink / raw)
To: Alexander Viro, lkml, Jeff Muizelaar
[-- Attachment #1: Type: TEXT/PLAIN, Size: 454 bytes --]
Viro,
I think you are the right person to review that.
Would you do me the favour?
---------- Forwarded message ----------
Date: Wed, 09 Jul 2003 20:16:54 -0400
From: Jeff Muizelaar <kernel@infidigm.net>
To: Marcelo Tosatti <marcelo@conectiva.com.br>
Subject: [PATCH] add seq file helpers from 2.5
Marcelo,
The attached patch adds the single_* helpers that have been in 2.5 since
May 2002, it also adds some missing includes that are in 2.5.
-Jeff
[-- Attachment #2: Type: TEXT/PLAIN, Size: 2001 bytes --]
diff -urN linux-2.4.21-bk1/fs/seq_file.c linux-2.4.21-bk1-seq-file-single/fs/seq_file.c
--- linux-2.4.21-bk1/fs/seq_file.c 2003-06-13 10:51:37.000000000 -0400
+++ linux-2.4.21-bk1-seq-file-single/fs/seq_file.c 2003-07-09 20:06:25.000000000 -0400
@@ -295,3 +295,45 @@
m->count = m->size;
return -1;
}
+
+static void *single_start(struct seq_file *p, loff_t *pos)
+{
+ return NULL + (*pos == 0);
+}
+
+static void *single_next(struct seq_file *p, void *v, loff_t *pos)
+{
+ ++*pos;
+ return NULL;
+}
+
+static void single_stop(struct seq_file *p, void *v)
+{
+}
+
+int single_open(struct file *file, int (*show)(struct seq_file *, void*), void *data)
+{
+ struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
+ int res = -ENOMEM;
+
+ if (op) {
+ op->start = single_start;
+ op->next = single_next;
+ op->stop = single_stop;
+ op->show = show;
+ res = seq_open(file, op);
+ if (!res)
+ ((struct seq_file *)file->private_data)->private = data;
+ else
+ kfree(op);
+ }
+ return res;
+}
+
+int single_release(struct inode *inode, struct file *file)
+{
+ struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
+ int res = seq_release(inode, file);
+ kfree(op);
+ return res;
+}
diff -urN linux-2.4.21-bk1/include/linux/seq_file.h linux-2.4.21-bk1-seq-file-single/include/linux/seq_file.h
--- linux-2.4.21-bk1/include/linux/seq_file.h 2002-08-02 20:39:45.000000000 -0400
+++ linux-2.4.21-bk1-seq-file-single/include/linux/seq_file.h 2003-07-06 08:57:25.000000000 -0400
@@ -2,7 +2,13 @@
#define _LINUX_SEQ_FILE_H
#ifdef __KERNEL__
+#include <linux/types.h>
+#include <linux/string.h>
+#include <asm/semaphore.h>
+
struct seq_operations;
+struct file;
+struct inode;
struct seq_file {
char *buf;
@@ -52,5 +58,8 @@
int seq_printf(struct seq_file *, const char *, ...)
__attribute__ ((format (printf,2,3)));
+
+int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
+int single_release(struct inode *, struct file *);
#endif
#endif
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] add seq file helpers from 2.5 (fwd)
2003-07-10 3:02 [PATCH] add seq file helpers from 2.5 (fwd) Marcelo Tosatti
@ 2003-07-10 5:04 ` Randy.Dunlap
2003-07-10 18:28 ` Chris Wright
1 sibling, 0 replies; 4+ messages in thread
From: Randy.Dunlap @ 2003-07-10 5:04 UTC (permalink / raw)
To: marcelo; +Cc: viro, linux-kernel, kernel
Marcelo,
I didn't apply and build it, but it looks very much like the
patch that I sent to you on 2003-04-17 [1], to which you replied: [2]
Saved to 2.4.22-pre folder.
I suggest that you apply it. :)
~Randy
[1] http://marc.theaimsgroup.com/?l=linux-kernel&m=105061808602830&w=2
[2] http://marc.theaimsgroup.com/?l=linux-kernel&m=105094575909669&w=2
> Viro,
>
> I think you are the right person to review that.
>
> Would you do me the favour?
>
> ---------- Forwarded message ----------
> Date: Wed, 09 Jul 2003 20:16:54 -0400
> From: Jeff Muizelaar <kernel@infidigm.net>
> To: Marcelo Tosatti <marcelo@conectiva.com.br>
> Subject: [PATCH] add seq file helpers from 2.5
>
> Marcelo,
>
> The attached patch adds the single_* helpers that have been in 2.5 since May
> 2002, it also adds some missing includes that are in 2.5.
>
> -Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] add seq file helpers from 2.5 (fwd)
2003-07-10 3:02 [PATCH] add seq file helpers from 2.5 (fwd) Marcelo Tosatti
2003-07-10 5:04 ` Randy.Dunlap
@ 2003-07-10 18:28 ` Chris Wright
2003-07-10 18:45 ` Chris Wright
1 sibling, 1 reply; 4+ messages in thread
From: Chris Wright @ 2003-07-10 18:28 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: Alexander Viro, lkml, Jeff Muizelaar
* Marcelo Tosatti (marcelo@conectiva.com.br) wrote:
> +int single_open(struct file *file, int (*show)(struct seq_file *, void*), void *data)
> +{
> + struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
> + int res = -ENOMEM;
> +
> + if (op) {
> + op->start = single_start;
> + op->next = single_next;
> + op->stop = single_stop;
> + op->show = show;
> + res = seq_open(file, op);
Any reason not to simply allocate static ops struct? As in:
static struct seq_operations single_ops = {
.start = single_start;
.next = single_next;
.stop = single_stop;
.show = show;
};
int single_open()
{
req = seq_open(file, &single_ops);
...
}
thanks,
-chris
--
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] add seq file helpers from 2.5 (fwd)
2003-07-10 18:28 ` Chris Wright
@ 2003-07-10 18:45 ` Chris Wright
0 siblings, 0 replies; 4+ messages in thread
From: Chris Wright @ 2003-07-10 18:45 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: Alexander Viro, lkml, Jeff Muizelaar
* Chris Wright (chris@wirex.com) wrote:
> * Marcelo Tosatti (marcelo@conectiva.com.br) wrote:
> > +int single_open(struct file *file, int (*show)(struct seq_file *, void*), void *data)
> > +{
> > + struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
> > + int res = -ENOMEM;
> > +
> > + if (op) {
> > + op->start = single_start;
> > + op->next = single_next;
> > + op->stop = single_stop;
> > + op->show = show;
> > + res = seq_open(file, op);
>
> Any reason not to simply allocate static ops struct? As in:
Bah, nevermind, I didn't look closely enough to see that show is
dynamic here (not to mention it is simple straight backport). Sorry for
senseless noise ;-)
thanks,
-chris
--
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-07-10 18:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-10 3:02 [PATCH] add seq file helpers from 2.5 (fwd) Marcelo Tosatti
2003-07-10 5:04 ` Randy.Dunlap
2003-07-10 18:28 ` Chris Wright
2003-07-10 18:45 ` Chris Wright
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).