Commit 2b6aca2d authored by Chas Williams's avatar Chas Williams Committed by Hideaki Yoshifuji

[ATM]: seq_file for /proc/net/atm (svc) [4/8] (from romieu@fr.zoreil.com)

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

Exactly same comments as pvc. Just s/p/s/
parent 2fcd83e9
...@@ -323,29 +323,26 @@ static void vc_info(struct atm_vcc *vcc,char *buf) ...@@ -323,29 +323,26 @@ static void vc_info(struct atm_vcc *vcc,char *buf)
atomic_read(&vcc->sk->sk_rmem_alloc), vcc->sk->sk_rcvbuf); atomic_read(&vcc->sk->sk_rmem_alloc), vcc->sk->sk_rcvbuf);
} }
static void svc_info(struct seq_file *seq, struct atm_vcc *vcc)
static void svc_info(struct atm_vcc *vcc,char *buf)
{ {
char *here;
int i;
if (!vcc->dev) if (!vcc->dev)
sprintf(buf,sizeof(void *) == 4 ? "N/A@%p%10s" : "N/A@%p%2s", seq_printf(seq, sizeof(void *) == 4 ?
vcc,""); "N/A@%p%10s" : "N/A@%p%2s", vcc, "");
else sprintf(buf,"%3d %3d %5d ",vcc->dev->number,vcc->vpi, else
vcc->vci); seq_printf(seq, "%3d %3d %5d ",
here = strchr(buf,0); vcc->dev->number, vcc->vpi, vcc->vci);
here += sprintf(here,"%-10s ",vcc_state(vcc)); seq_printf(seq, "%-10s ", vcc_state(vcc));
here += sprintf(here,"%s%s",vcc->remote.sas_addr.pub, seq_printf(seq, "%s%s", vcc->remote.sas_addr.pub,
*vcc->remote.sas_addr.pub && *vcc->remote.sas_addr.prv ? "+" : ""); *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++) for (i = 0; i < ATM_ESA_LEN; i++)
here += sprintf(here,"%02x", seq_printf(seq, "%02x", vcc->remote.sas_addr.prv[i]);
vcc->remote.sas_addr.prv[i]); }
strcat(here,"\n"); seq_putc(seq, '\n');
} }
#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE) #if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
static char* static char*
...@@ -493,31 +490,41 @@ static int atm_vc_info(loff_t pos,char *buf) ...@@ -493,31 +490,41 @@ static int atm_vc_info(loff_t pos,char *buf)
return 0; return 0;
} }
static int svc_seq_show(struct seq_file *seq, void *v)
static int atm_svc_info(loff_t pos,char *buf)
{ {
struct hlist_node *node; static char atm_svc_banner[] =
struct sock *s; "Itf VPI VCI State Remote\n";
struct atm_vcc *vcc;
int left;
if (!pos) if (v == (void *)1)
return sprintf(buf,"Itf VPI VCI State Remote\n"); seq_puts(seq, atm_svc_banner);
left = pos-1; else {
read_lock(&vcc_sklist_lock); struct vcc_state *state = seq->private;
sk_for_each(s, node, &vcc_sklist) { struct atm_vcc *vcc = atm_sk(state->sk);
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);
svc_info(seq, vcc);
}
return 0; return 0;
} }
static struct seq_operations svc_seq_ops = {
.start = vcc_seq_start,
.next = vcc_seq_next,
.stop = vcc_seq_stop,
.show = svc_seq_show,
};
static int svc_seq_open(struct inode *inode, struct file *file)
{
return __vcc_seq_open(inode, file, PF_ATMSVC, &svc_seq_ops);
}
static struct file_operations svc_seq_fops = {
.open = svc_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = vcc_seq_release,
};
#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE) #if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
static int atm_arp_info(loff_t pos,char *buf) static int atm_arp_info(loff_t pos,char *buf)
{ {
...@@ -770,7 +777,7 @@ int __init atm_proc_init(void) ...@@ -770,7 +777,7 @@ int __init atm_proc_init(void)
return -ENOMEM; return -ENOMEM;
CREATE_SEQ_ENTRY(devices); CREATE_SEQ_ENTRY(devices);
CREATE_SEQ_ENTRY(pvc); CREATE_SEQ_ENTRY(pvc);
CREATE_ENTRY(svc); CREATE_SEQ_ENTRY(svc);
CREATE_ENTRY(vc); CREATE_ENTRY(vc);
#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE) #if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
CREATE_ENTRY(arp); CREATE_ENTRY(arp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment