linux-kernel.vger.kernel.org archive mirror
 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 4/8] 2.5.74 - seq_file conversion of /proc/net/atm (svc)
Date: Wed, 9 Jul 2003 02:28:36 +0200	[thread overview]
Message-ID: <20030709022836.F11897@electric-eye.fr.zoreil.com> (raw)
In-Reply-To: <20030709021152.B11897@electric-eye.fr.zoreil.com>; from romieu@fr.zoreil.com on Wed, Jul 09, 2003 at 02:11:52AM +0200

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

Same comments as pvc. Just s/p/s/


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

diff -puN net/atm/proc.c~atm-proc-seq-svc-conversion net/atm/proc.c
--- linux-2.5.74-1.1360.1.1-to-1.1384/net/atm/proc.c~atm-proc-seq-svc-conversion	Wed Jul  9 01:42:59 2003
+++ linux-2.5.74-1.1360.1.1-to-1.1384-fr/net/atm/proc.c	Wed Jul  9 01:42:59 2003
@@ -326,29 +326,26 @@ static void vc_info(struct atm_vcc *vcc,
 	    atomic_read(&vcc->sk->sk_rmem_alloc), vcc->sk->sk_rcvbuf);
 }
 
-
-static void svc_info(struct atm_vcc *vcc,char *buf)
+static void svc_info(struct seq_file *seq, struct atm_vcc *vcc)
 {
-	char *here;
-	int i;
-
 	if (!vcc->dev)
-		sprintf(buf,sizeof(void *) == 4 ? "N/A@%p%10s" : "N/A@%p%2s",
-		    vcc,"");
-	else sprintf(buf,"%3d %3d %5d         ",vcc->dev->number,vcc->vpi,
-		    vcc->vci);
-	here = strchr(buf,0);
-	here += sprintf(here,"%-10s ",vcc_state(vcc));
-	here += sprintf(here,"%s%s",vcc->remote.sas_addr.pub,
+		seq_printf(seq, sizeof(void *) == 4 ?
+			   "N/A@%p%10s" : "N/A@%p%2s", vcc, "");
+	else
+		seq_printf(seq, "%3d %3d %5d         ",
+			   vcc->dev->number, vcc->vpi, vcc->vci);
+	seq_printf(seq, "%-10s ", vcc_state(vcc));
+	seq_printf(seq, "%s%s", vcc->remote.sas_addr.pub,
 	    *vcc->remote.sas_addr.pub && *vcc->remote.sas_addr.prv ? "+" : "");
-	if (*vcc->remote.sas_addr.prv)
+	if (*vcc->remote.sas_addr.prv) {
+		int i;
+
 		for (i = 0; i < ATM_ESA_LEN; i++)
-			here += sprintf(here,"%02x",
-			    vcc->remote.sas_addr.prv[i]);
-	strcat(here,"\n");
+			seq_printf(seq, "%02x", vcc->remote.sas_addr.prv[i]);
+	}
+	seq_putc(seq, '\n');
 }
 
-
 #if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
 
 static char*
@@ -525,31 +522,41 @@ static int atm_vc_info(loff_t pos,char *
 	return 0;
 }
 
-
-static int atm_svc_info(loff_t pos,char *buf)
+static int atm_svc_seq_show(struct seq_file *seq, void *v)
 {
-	struct hlist_node *node;
-	struct sock *s;
-	struct atm_vcc *vcc;
-	int left;
+	static char atm_svc_banner[] = 
+		"Itf VPI VCI           State      Remote\n";
 
-	if (!pos)
-		return sprintf(buf,"Itf VPI VCI           State      Remote\n");
-	left = pos-1;
-	read_lock(&vcc_sklist_lock);
-	sk_for_each(s, node, &vcc_sklist) {
-		vcc = atm_sk(s);
-		if (vcc->sk->sk_family == PF_ATMSVC && !left--) {
-			svc_info(vcc,buf);
-			read_unlock(&vcc_sklist_lock);
-			return strlen(buf);
-		}
-	}
-	read_unlock(&vcc_sklist_lock);
+	if (v == (void *)1)
+		seq_puts(seq, atm_svc_banner);
+	else {
+		struct atm_vc_state *state = seq->private;
+		struct atm_vcc *vcc = atm_sk(state->sk);
 
+		svc_info(seq, vcc);
+	}
 	return 0;
 }
 
+static struct seq_operations atm_svc_seq_ops = {
+	.start	= atm_vc_common_seq_start,
+	.next	= atm_vc_common_seq_next,
+	.stop	= atm_vc_common_seq_stop,
+	.show	= atm_svc_seq_show,
+};
+
+static int atm_svc_seq_open(struct inode *inode, struct file *file)
+{
+	return atm_vc_common_seq_open(inode, file, PF_ATMSVC, &atm_svc_seq_ops);
+}
+
+static struct file_operations atm_seq_svc_fops = {
+	.open		= atm_svc_seq_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= atm_vc_common_seq_release,
+};
+
 #if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
 static int atm_arp_info(loff_t pos,char *buf)
 {
@@ -795,7 +802,7 @@ int __init atm_proc_init(void)
 		return -ENOMEM;
 	CREATE_SEQ_ENTRY(devices);
 	CREATE_SEQ_ENTRY(pvc);
-	CREATE_ENTRY(svc);
+	CREATE_SEQ_ENTRY(svc);
 	CREATE_ENTRY(vc);
 #if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
 	CREATE_ENTRY(arp);

_

  parent reply	other threads:[~2003-07-09  0:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-09  0:11 [PATCHKIT] 2.5.74 - seq_file conversion of /proc/net/atm Francois Romieu
2003-07-09  0:23 ` [PATCH 1/8] 2.5.74 - seq_file conversion of /proc/net/atm (devices) Francois Romieu
2003-07-09  0:26 ` [PATCH 2/8] 2.5.74 - seq_file conversion of /proc/net/atm (vc helpers) Francois Romieu
2003-07-09  0:27 ` [PATCH 3/8] 2.5.74 - seq_file conversion of /proc/net/atm (pvc) Francois Romieu
2003-07-09  0:28 ` Francois Romieu [this message]
2003-07-09  0:29 ` [PATCH 5/8] 2.5.74 - seq_file conversion of /proc/net/atm (vc) Francois Romieu
2003-07-09 14:35   ` seq_file and proc_dir_entry data (was Re: [PATCH 5/8] 2.5.74 - seq_file conversion of /proc/net/atm (vc)) Ed L Cashin
2003-07-09  0:30 ` [PATCH 6/8] 2.5.74 - seq_file conversion of /proc/net/atm (arp) Francois Romieu
2003-07-09  0:31 ` [PATCH 7/8] 2.5.74 - seq_file conversion of /proc/net/atm (lec) Francois Romieu
2003-07-09  0:33 ` [PATCH 8/8] 2.5.74 - seq_file conversion of /proc/net/atm (cleanup) Francois Romieu
2003-07-10  5:49 ` [PATCHKIT] 2.5.74 - seq_file conversion of /proc/net/atm David S. Miller
2003-07-10 10:48   ` chas williams

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=20030709022836.F11897@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;
as well as URLs for NNTP newsgroup(s).