mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Francois Romieu <romieu@fr.zoreil.com>
To: chas@locutus.cmf.nrl.navy.mil
Cc: linux-kernel@vger.kernel.org, davem@redhat.com
Subject: [PATCH 5/8] 2.6.0-test2-bk8 - seq_file conversion of /proc/net/atm (vc)
Date: Sat, 9 Aug 2003 00:13:21 +0200	[thread overview]
Message-ID: <20030809001321.F2699@electric-eye.fr.zoreil.com> (raw)
In-Reply-To: <20030809001139.E2699@electric-eye.fr.zoreil.com>; from romieu@fr.zoreil.com on Sat, Aug 09, 2003 at 12:11:39AM +0200

seq_file support for /proc/net/atm/vc:

Same comments as for pvc and svc.


 net/atm/proc.c |   80 ++++++++++++++++++++++++++++++---------------------------
 1 files changed, 43 insertions(+), 37 deletions(-)

diff -puN net/atm/proc.c~atm-proc-seq-vc-conversion net/atm/proc.c
--- linux-2.6.0-test2-bk8/net/atm/proc.c~atm-proc-seq-vc-conversion	Fri Aug  8 20:29:29 2003
+++ linux-2.6.0-test2-bk8-fr/net/atm/proc.c	Fri Aug  8 20:29:29 2003
@@ -298,29 +298,27 @@ static const char *vcc_state(struct atm_
 	return map[ATM_VF2VS(vcc->flags)];
 }
 
-
-static void vc_info(struct atm_vcc *vcc,char *buf)
+static void vc_info(struct seq_file *seq, struct atm_vcc *vcc)
 {
-	char *here;
-
-	here = buf+sprintf(buf,"%p ",vcc);
-	if (!vcc->dev) here += sprintf(here,"Unassigned    ");
-	else here += sprintf(here,"%3d %3d %5d ",vcc->dev->number,vcc->vpi,
-		    vcc->vci);
+	seq_printf(seq, "%p ", vcc);
+	if (!vcc->dev)
+		seq_printf(seq, "Unassigned    ");
+	else 
+		seq_printf(seq, "%3d %3d %5d ", vcc->dev->number, vcc->vpi,
+			vcc->vci);
 	switch (vcc->sk->sk_family) {
 		case AF_ATMPVC:
-			here += sprintf(here,"PVC");
+			seq_printf(seq, "PVC");
 			break;
 		case AF_ATMSVC:
-			here += sprintf(here,"SVC");
+			seq_printf(seq, "SVC");
 			break;
 		default:
-			here += sprintf(here, "%3d", vcc->sk->sk_family);
+			seq_printf(seq, "%3d", vcc->sk->sk_family);
 	}
-	here += sprintf(here," %04lx  %5d %7d/%7d %7d/%7d\n",vcc->flags,
-	    vcc->sk->sk_err,
-	    atomic_read(&vcc->sk->sk_wmem_alloc), vcc->sk->sk_sndbuf,
-	    atomic_read(&vcc->sk->sk_rmem_alloc), vcc->sk->sk_rcvbuf);
+	seq_printf(seq, " %04lx  %5d %7d/%7d %7d/%7d\n", vcc->flags, vcc->sk->sk_err,
+		atomic_read(&vcc->sk->sk_wmem_alloc),vcc->sk->sk_sndbuf,
+		atomic_read(&vcc->sk->sk_rmem_alloc),vcc->sk->sk_rcvbuf);
 }
 
 static void svc_info(struct seq_file *seq, struct atm_vcc *vcc)
@@ -493,32 +491,33 @@ static struct file_operations atm_seq_pv
 	.release	= atm_vc_common_seq_release,
 };
 
-static int atm_vc_info(loff_t pos,char *buf)
+static int atm_vc_seq_show(struct seq_file *seq, void *v)
 {
-	struct atm_vcc *vcc;
-	struct hlist_node *node;
-	struct sock *s;
-	int left;
-
-	if (!pos)
-		return sprintf(buf,sizeof(void *) == 4 ? "%-8s%s" : "%-16s%s",
-		    "Address"," Itf VPI VCI   Fam Flags Reply Send buffer"
-		    "     Recv buffer\n");
-	left = pos-1;
-	read_lock(&vcc_sklist_lock);
-	sk_for_each(s, node, &vcc_sklist) {
-		vcc = atm_sk(s);
-		if (!left--) {
-			vc_info(vcc,buf);
-			read_unlock(&vcc_sklist_lock);
-			return strlen(buf);
-		}
-	}
-	read_unlock(&vcc_sklist_lock);
+	if (v == (void *)1) {
+		seq_printf(seq, sizeof(void *) == 4 ? "%-8s%s" : "%-16s%s",
+			"Address ", "Itf VPI VCI   Fam Flags Reply "
+			"Send buffer     Recv buffer\n");
+	} else {
+		struct atm_vc_state *state = seq->private;
+		struct atm_vcc *vcc = atm_sk(state->sk);
 
+		vc_info(seq, vcc);
+	}
 	return 0;
 }
 
+static struct seq_operations atm_vc_seq_ops = {
+	.start	= atm_vc_common_seq_start,
+	.next	= atm_vc_common_seq_next,
+	.stop	= atm_vc_common_seq_stop,
+	.show	= atm_vc_seq_show,
+};
+
+static int atm_vc_seq_open(struct inode *inode, struct file *file)
+{
+	return atm_vc_common_seq_open(inode, file, 0, &atm_vc_seq_ops);
+}
+
 static int atm_svc_seq_show(struct seq_file *seq, void *v)
 {
 	static char atm_svc_banner[] = 
@@ -535,6 +534,13 @@ static int atm_svc_seq_show(struct seq_f
 	return 0;
 }
 
+static struct file_operations atm_seq_vc_fops = {
+	.open		= atm_vc_seq_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= atm_vc_common_seq_release,
+};
+
 static struct seq_operations atm_svc_seq_ops = {
 	.start	= atm_vc_common_seq_start,
 	.next	= atm_vc_common_seq_next,
@@ -800,7 +806,7 @@ int __init atm_proc_init(void)
 	CREATE_SEQ_ENTRY(devices);
 	CREATE_SEQ_ENTRY(pvc);
 	CREATE_SEQ_ENTRY(svc);
-	CREATE_ENTRY(vc);
+	CREATE_SEQ_ENTRY(vc);
 #if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
 	CREATE_ENTRY(arp);
 #endif

_

  reply	other threads:[~2003-08-08 22:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-08 22:03 [PATCH] TRY #2 - 2.6.0-test2-bk8 - seq_file conversion of /proc/net/atm Francois Romieu
2003-08-08 22:06 ` [PATCH 1/8] 2.6.0-test2-bk8 - seq_file conversion of /proc/net/atm (devices) Francois Romieu
2003-08-08 22:08   ` [PATCH 2/8] 2.6.0-test2-bk8 - seq_file conversion of /proc/net/atm (vc helpers) Francois Romieu
2003-08-08 22:10     ` [PATCH 3/8] 2.6.0-test2-bk8 - seq_file conversion of /proc/net/atm (pvc) Francois Romieu
2003-08-08 22:11       ` [PATCH 4/8] 2.6.0-test2-bk8 - seq_file conversion of /proc/net/atm (svc) Francois Romieu
2003-08-08 22:13         ` Francois Romieu [this message]
2003-08-08 22:15           ` [PATCH 6/8] 2.6.0-test2-bk8 - seq_file conversion of /proc/net/atm (arp) Francois Romieu
2003-08-08 22:19             ` [PATCH 7/8] 2.6.0-test2-bk8 - seq_file conversion of /proc/net/atm (lec) Francois Romieu
2003-08-08 22:22               ` [PATCH 8/8] 2.6.0-test2-bk8 - seq_file conversion of /proc/net/atm (cleanup) Francois Romieu
2003-08-22 19:34       ` [PATCH 3/8] 2.6.0-test2-bk8 - seq_file conversion of /proc/net/atm (pvc) chas williams
2003-08-09  9:05 ` [PATCH] TRY #2 - 2.6.0-test2-bk8 - seq_file conversion of /proc/net/atm David S. Miller
2003-08-11 14:56   ` chas williams
2003-08-09 10:11 ` Francois Romieu

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=20030809001321.F2699@electric-eye.fr.zoreil.com \
    --to=romieu@fr.zoreil.com \
    --cc=chas@locutus.cmf.nrl.navy.mil \
    --cc=davem@redhat.com \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®