lkml.org 
[lkml]   [2007]   [Oct]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] lockdep: Avoid /proc/lockdep & lock_stat infinite output
On Tue 09 Oct at 02:30:11 +0100 viro@ftp.linux.org.uk said:
> On Mon, Oct 08, 2007 at 06:15:51PM -0700, Tim Pepper wrote:
> >
> > - if (&class->lock_entry == all_lock_classes.next)
> > + if (*pos == 0)
> > seq_printf(m, "all lock classes:\n");
>
> Do not generate output outside of ->show() and you won't have these
> problems. That's where your infinite output crap comes from.
>
> IOW, NAK - fix the underlying problem.

Aaah...OK. Can we add something like the following then:




Document that output must only come from _show() and SEQ_START_TOKEN is how
a _start() indicates a header is to be printed.

Signed-off-by: Tim Pepper <lnxninja@linux.vnet.ibm.com>
Cc: Al Viro <viro@ftp.linux.org.uk>

---

--- linux-2.6.orig/include/linux/seq_file.h
+++ linux-2.6.23-rc9/include/linux/seq_file.h
@@ -36,9 +36,10 @@ ssize_t seq_read(struct file *, char __u
loff_t seq_lseek(struct file *, loff_t, int);
int seq_release(struct inode *, struct file *);
int seq_escape(struct seq_file *, const char *, const char *);
+
+/* these may only be called from a (*show) function */
int seq_putc(struct seq_file *m, char c);
int seq_puts(struct seq_file *m, const char *s);
-
int seq_printf(struct seq_file *, const char *, ...)
__attribute__ ((format (printf,2,3)));

@@ -48,6 +49,11 @@ int single_open(struct file *, int (*)(s
int single_release(struct inode *, struct file *);
int seq_release_private(struct inode *, struct file *);

+/*
+ * return SEQ_START_TOKEN in your (*start) function and test for
+ * (v == SEQ_START_TOKEN) in * your (*show) funtion in order to
+ * print a header before your seq data
+ */
#define SEQ_START_TOKEN ((void *)1)

/*
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2007-10-09 06:07    [W:0.661 / U:0.384 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site