linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] add seq_file "single" interfaces
@ 2003-08-25 17:03 Randy.Dunlap
  2003-08-25 17:57 ` J.A. Magallon
  0 siblings, 1 reply; 3+ messages in thread
From: Randy.Dunlap @ 2003-08-25 17:03 UTC (permalink / raw)
  To: marcelo; +Cc: lkml, johnstul, jamesclv

Hi,

This patch adds the seq_file "single" interfaces from 2.6.0-test4
to 2.4.22++.  This will enable larger /proc/interrupts and
/proc/mdstat, which currently have some oopsing problems
with large outputs.

Please apply.

--
~Randy


patch_name:	seq_single_2423p1.patch
patch_version:	2003-08-25.09:34:59
author:		Randy.Dunlap <rddunlap@osdl.org>
description:	add seq_file "single" interfaces from 2.6.0-test4
product:	Linux
product_versions: 2422
diffstat:	=
 fs/seq_file.c            |   90 +++++++++++++++++++++++++++++++++++++++++++++--
 include/linux/seq_file.h |   13 ++++++
 2 files changed, 100 insertions(+), 3 deletions(-)

diff -Naurp ./include/linux/seq_file.h~seqsingle ./include/linux/seq_file.h
--- ./include/linux/seq_file.h~seqsingle	2002-08-02 17:39:45.000000000 -0700
+++ ./include/linux/seq_file.h	2003-08-25 09:34:39.000000000 -0700
@@ -2,7 +2,15 @@
 #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 vfsmount;
+struct dentry;
+struct inode;
 
 struct seq_file {
 	char *buf;
@@ -52,5 +60,10 @@ static inline int seq_puts(struct seq_fi
 int seq_printf(struct seq_file *, const char *, ...)
 	__attribute__ ((format (printf,2,3)));
 
+int seq_path(struct seq_file *, struct vfsmount *, struct dentry *, char *);
+
+int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
+int single_release(struct inode *, struct file *);
+int seq_release_private(struct inode *, struct file *);
 #endif
 #endif
diff -Naurp ./fs/seq_file.c~seqsingle ./fs/seq_file.c
--- ./fs/seq_file.c~seqsingle	2003-06-13 07:51:37.000000000 -0700
+++ ./fs/seq_file.c	2003-08-25 09:34:39.000000000 -0700
@@ -1,7 +1,7 @@
 /*
  * linux/fs/seq_file.c
  *
- * helper functions for making syntetic files from sequences of records.
+ * helper functions for making synthetic files from sequences of records.
  * initial implementation -- AV, Oct 2001.
  */
 
@@ -10,6 +10,7 @@
 #include <linux/slab.h>
 
 #include <asm/uaccess.h>
+#include <asm/page.h>
 
 /**
  *	seq_open -	initialize sequential file
@@ -214,7 +215,7 @@ loff_t seq_lseek(struct file *file, loff
 				while ((retval=traverse(m, offset)) == -EAGAIN)
 					;
 				if (retval) {
-					/* with extreme perjudice... */
+					/* with extreme prejudice... */
 					file->f_pos = 0;
 					m->index = 0;
 					m->count = 0;
@@ -249,7 +250,7 @@ int seq_release(struct inode *inode, str
  *	@s:	string
  *	@esc:	set of characters that need escaping
  *
- *	Puts string into buffer, replacing each occurence of character from
+ *	Puts string into buffer, replacing each occurrence of character from
  *	@esc with usual octal escape.  Returns 0 in case of success, -1 - in
  *	case of overflow.
  */
@@ -295,3 +296,86 @@ int seq_printf(struct seq_file *m, const
 	m->count = m->size;
 	return -1;
 }
+
+int seq_path(struct seq_file *m,
+		struct vfsmount *mnt, struct dentry *dentry,
+		char *esc)
+{
+	if (m->count < m->size) {
+		char *s = m->buf + m->count;
+		char *p = d_path(dentry, mnt, s, m->size - m->count);
+		if (!IS_ERR(p)) {
+			while (s <= p) {
+				char c = *p++;
+				if (!c) {
+					p = m->buf + m->count;
+					m->count = s - m->buf;
+					return s - p;
+				} else if (!strchr(esc, c)) {
+					*s++ = c;
+				} else if (s + 4 > p) {
+					break;
+				} else {
+					*s++ = '\\';
+					*s++ = '0' + ((c & 0300) >> 6);
+					*s++ = '0' + ((c & 070) >> 3);
+					*s++ = '0' + (c & 07);
+				}
+			}
+		}
+	}
+	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;
+}
+
+int seq_release_private(struct inode *inode, struct file *file)
+{
+	struct seq_file *seq = file->private_data;
+
+	kfree(seq->private);
+	seq->private = NULL;
+	return seq_release(inode, file);
+}
+


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

* Re: [PATCH] add seq_file "single" interfaces
  2003-08-25 17:03 [PATCH] add seq_file "single" interfaces Randy.Dunlap
@ 2003-08-25 17:57 ` J.A. Magallon
  2003-08-25 18:07   ` Marc-Christian Petersen
  0 siblings, 1 reply; 3+ messages in thread
From: J.A. Magallon @ 2003-08-25 17:57 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: marcelo, lkml, johnstul, jamesclv


On 08.25, Randy.Dunlap wrote:
> Hi,
> 
> This patch adds the seq_file "single" interfaces from 2.6.0-test4
> to 2.4.22++.  This will enable larger /proc/interrupts and
> /proc/mdstat, which currently have some oopsing problems
> with large outputs.
> 
> Please apply.
> 

How about exporting them in kernel/ksyms ?

-- 
J.A. Magallon <jamagallon@able.es>      \                 Software is like sex:
werewolf.able.es                         \           It's better when it's free
Mandrake Linux release 9.2 (Cooker) for i586
Linux 2.4.22-rc3-jam1m (gcc 3.3.1 (Mandrake Linux 9.2 3.3.1-1mdk))

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

* Re: [PATCH] add seq_file "single" interfaces
  2003-08-25 17:57 ` J.A. Magallon
@ 2003-08-25 18:07   ` Marc-Christian Petersen
  0 siblings, 0 replies; 3+ messages in thread
From: Marc-Christian Petersen @ 2003-08-25 18:07 UTC (permalink / raw)
  To: J.A. Magallon, Randy.Dunlap; +Cc: marcelo, lkml, johnstul, jamesclv

[-- Attachment #1: Type: text/plain, Size: 358 bytes --]

On Monday 25 August 2003 19:57, J.A. Magallon wrote:

> > This patch adds the seq_file "single" interfaces from 2.6.0-test4
> > to 2.4.22++.  This will enable larger /proc/interrupts and
> > /proc/mdstat, which currently have some oopsing problems
> > with large outputs.
> > Please apply.

> How about exporting them in kernel/ksyms ?

Right.

ciao, Marc



[-- Attachment #2: seq-file-for-single-open-exports.patch --]
[-- Type: text/x-diff, Size: 412 bytes --]

--- a/kernel/ksyms.c	Thu Apr 17 10:42:17 2003
+++ b/kernel/ksyms.c	Thu Apr 17 14:49:54 2003
@@ -515,6 +515,10 @@ EXPORT_SYMBOL(seq_open);
 EXPORT_SYMBOL(seq_release);
 EXPORT_SYMBOL(seq_read);
 EXPORT_SYMBOL(seq_lseek);
+EXPORT_SYMBOL(seq_path);
+EXPORT_SYMBOL(single_open);
+EXPORT_SYMBOL(single_release);
+EXPORT_SYMBOL(seq_release_private);
 
 /* Program loader interfaces */
 EXPORT_SYMBOL(setup_arg_pages);

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

end of thread, other threads:[~2003-08-25 18:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-25 17:03 [PATCH] add seq_file "single" interfaces Randy.Dunlap
2003-08-25 17:57 ` J.A. Magallon
2003-08-25 18:07   ` Marc-Christian Petersen

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