Thread (1 message) 1 message, 1 author, 2003-08-19

Re: [RFT][PATCH] convert 802/tr to seq_file

From: Francois Romieu <romieu@fr.zoreil.com>
Date: 2003-08-19 23:20:14

Stephen Hemminger [off-list ref] :
quoted hunk
Convert the /proc interface to tokenring routing information
to the new seq_file interface.

Builds and loads on 2.6.0-test3, but I don't have any real tokenring hardware
to make entries show up in table.

diff -Nru a/net/802/tr.c b/net/802/tr.c
--- a/net/802/tr.c	Tue Aug 19 14:07:56 2003
+++ b/net/802/tr.c	Tue Aug 19 14:07:56 2003
[...]
quoted hunk
@@ -456,84 +457,108 @@
  *	routing.
  */
  
-#ifndef CONFIG_PROC_FS
-static int rif_get_info(char *buffer,char **start, off_t offset, int length)  { return 0;}
-#else
-static int rif_get_info(char *buffer,char **start, off_t offset, int length) 
-{
-	int len=0;
-	off_t begin=0;
-	off_t pos=0;
-	int size,i,j,rcf_len,segment,brdgnmb;
-	unsigned long now=jiffies;
+#ifdef CONFIG_PROC_FS
+/* Magic token to indicate first entry (header line) */
+#define RIF_PROC_START	((void *)1)
+
+static struct rif_cache_s *rif_get_idx(loff_t pos)
+{
+	int i;
+	struct rif_cache_s *entry;
+	loff_t off = 0;
+
+	for(i=0;i < RIF_TABLE_SIZE;i++) 
+		for(entry=rif_table[i];entry;entry=entry->next) {
+			if (off == pos)
+				return entry;
+			++off;
+		}
+
Add a few more spaces and braces (it's 1:00 AM here |o) )
	for (i = 0; i < RIF_TABLE_SIZE; i++) {
		for (entry = rif_table[i]; entry; entry = entry->next) {
			if (--pos < 0)
				return entry;
		}
	}
(killed "off" btw)
quoted hunk
+	return NULL;
+}
+
+static void *rif_seq_start(struct seq_file *seq, loff_t *pos)
+{
 	unsigned long flags;
 
-	rif_cache entry;
+	spin_lock_irqsave(&rif_lock, flags);
+	seq->private = (void *) flags;
+
+	return *pos ? rif_get_idx(*pos - 1) : RIF_PROC_START;
+}
+
+static void *rif_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+{
+	return rif_get_idx(*pos++);
                           ^^^^^^
Won't this increment the pointer instead of the value it adresses ?

<jargon>
	void *v;

	v = rif_get_idx(*pos + 1);
	*pos += !!ERR_PTR(v);
	return v;
</jargon>
quoted hunk
+}
+
+static void rif_seq_stop(struct seq_file *seq, void *v)
+{
+	unsigned long flags = (unsigned long) seq->private;
+	spin_lock_irqsave(&rif_lock, flags);
        ^^^^^^^^^^^^^^^^^

This should probably read:
  +	spin_unlock_irqrestore(&rif_lock, flags);

--
Ueimor
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help