netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] CONNECTOR: add a proc entry to list connectors
@ 2008-06-24  8:38 Li Zefan
       [not found] ` <4860B279.9070105-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
  2008-06-28  3:03 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Li Zefan @ 2008-06-24  8:38 UTC (permalink / raw)
  To: David Miller; +Cc: Evgeniy Polyakov, LKML, netdev

I got a problem when I wanted to check if the kernel supports process
event connector, and It seems there's no way to do this check.

At best I can check if the kernel supports connector or not, by looking
into /proc/net/netlink, or maybe checking the return value of bind() to
see if it's ENOENT.

So it would be useful to add /proc/net/connector to list all supported
connectors:
 # cat /proc/net/connector
 Name            ID
 connector       4294967295:4294967295
 cn_proc         1:1
 w1              3:1

Changelog:
- fix memory leak: s/seq_release/single_release
- use spin_lock_bh instead of spin_lock_irqsave

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
---
 drivers/connector/connector.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 85e2ba7..bf48300 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -27,6 +27,8 @@
 #include <linux/moduleparam.h>
 #include <linux/connector.h>
 #include <linux/mutex.h>
+#include <linux/proc_fs.h>
+#include <linux/spinlock.h>
 
 #include <net/sock.h>
 
@@ -403,6 +405,40 @@ static void cn_callback(void *data)
 	mutex_unlock(&notify_lock);
 }
 
+static int cn_proc_show(struct seq_file *m, void *v)
+{
+	struct cn_queue_dev *dev = cdev.cbdev;
+	struct cn_callback_entry *cbq;
+
+	seq_printf(m, "Name            ID\n");
+
+	spin_lock_bh(&dev->queue_lock);
+
+	list_for_each_entry(cbq, &dev->queue_list, callback_entry) {
+		seq_printf(m, "%-15s %u:%u\n",
+			   cbq->id.name,
+			   cbq->id.id.idx,
+			   cbq->id.id.val);
+	}
+
+	spin_unlock_bh(&dev->queue_lock);
+
+	return 0;
+}
+
+static int cn_proc_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, cn_proc_show, NULL);
+}
+
+static const struct file_operations cn_file_ops = {
+	.owner   = THIS_MODULE,
+	.open    = cn_proc_open,
+	.read    = seq_read,
+	.llseek  = seq_lseek,
+	.release = single_release
+};
+
 static int __devinit cn_init(void)
 {
 	struct cn_dev *dev = &cdev;
@@ -434,6 +470,8 @@ static int __devinit cn_init(void)
 		return -EINVAL;
 	}
 
+	proc_net_fops_create(&init_net, "connector", S_IRUGO, &cn_file_ops);
+
 	return 0;
 }
 
@@ -443,6 +481,8 @@ static void __devexit cn_fini(void)
 
 	cn_already_initialized = 0;
 
+	proc_net_remove(&init_net, "connector");
+
 	cn_del_callback(&dev->id);
 	cn_queue_free_dev(dev->cbdev);
 	netlink_kernel_release(dev->nls);
-- 
1.5.4.rc3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] CONNECTOR: add a proc entry to list connectors
       [not found] ` <4860B279.9070105-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
@ 2008-06-24 10:00   ` Subrata Modak
  0 siblings, 0 replies; 3+ messages in thread
From: Subrata Modak @ 2008-06-24 10:00 UTC (permalink / raw)
  To: Li Zefan
  Cc: Evgeniy Polyakov, netdev-u79uwXL29TY76Z2rM5mHXA, ltp-list,
	David Miller, LKML


[-- Attachment #1.1: Type: text/plain, Size: 3595 bytes --]

Hi Li,

I hope we are also facing the same problem for executing the Process Event
Connector test cases patch in LTP. If this works out, so will our test cases
patch.

Regards--
Subrata

On Tue, Jun 24, 2008 at 2:08 PM, Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org> wrote:

> I got a problem when I wanted to check if the kernel supports process
> event connector, and It seems there's no way to do this check.
>
> At best I can check if the kernel supports connector or not, by looking
> into /proc/net/netlink, or maybe checking the return value of bind() to
> see if it's ENOENT.
>
> So it would be useful to add /proc/net/connector to list all supported
> connectors:
>  # cat /proc/net/connector
>  Name            ID
>  connector       4294967295:4294967295
>  cn_proc         1:1
>  w1              3:1
>
> Changelog:
> - fix memory leak: s/seq_release/single_release
> - use spin_lock_bh instead of spin_lock_irqsave
>
> Signed-off-by: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
> Acked-by: Evgeniy Polyakov <johnpol-9fLWQ3dKdXwox3rIn2DAYQ@public.gmane.org>
> ---
>  drivers/connector/connector.c |   40
> ++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 40 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
> index 85e2ba7..bf48300 100644
> --- a/drivers/connector/connector.c
> +++ b/drivers/connector/connector.c
> @@ -27,6 +27,8 @@
>  #include <linux/moduleparam.h>
>  #include <linux/connector.h>
>  #include <linux/mutex.h>
> +#include <linux/proc_fs.h>
> +#include <linux/spinlock.h>
>
>  #include <net/sock.h>
>
> @@ -403,6 +405,40 @@ static void cn_callback(void *data)
>        mutex_unlock(&notify_lock);
>  }
>
> +static int cn_proc_show(struct seq_file *m, void *v)
> +{
> +       struct cn_queue_dev *dev = cdev.cbdev;
> +       struct cn_callback_entry *cbq;
> +
> +       seq_printf(m, "Name            ID\n");
> +
> +       spin_lock_bh(&dev->queue_lock);
> +
> +       list_for_each_entry(cbq, &dev->queue_list, callback_entry) {
> +               seq_printf(m, "%-15s %u:%u\n",
> +                          cbq->id.name,
> +                          cbq->id.id.idx,
> +                          cbq->id.id.val);
> +       }
> +
> +       spin_unlock_bh(&dev->queue_lock);
> +
> +       return 0;
> +}
> +
> +static int cn_proc_open(struct inode *inode, struct file *file)
> +{
> +       return single_open(file, cn_proc_show, NULL);
> +}
> +
> +static const struct file_operations cn_file_ops = {
> +       .owner   = THIS_MODULE,
> +       .open    = cn_proc_open,
> +       .read    = seq_read,
> +       .llseek  = seq_lseek,
> +       .release = single_release
> +};
> +
>  static int __devinit cn_init(void)
>  {
>        struct cn_dev *dev = &cdev;
> @@ -434,6 +470,8 @@ static int __devinit cn_init(void)
>                return -EINVAL;
>        }
>
> +       proc_net_fops_create(&init_net, "connector", S_IRUGO,
> &cn_file_ops);
> +
>        return 0;
>  }
>
> @@ -443,6 +481,8 @@ static void __devexit cn_fini(void)
>
>        cn_already_initialized = 0;
>
> +       proc_net_remove(&init_net, "connector");
> +
>        cn_del_callback(&dev->id);
>        cn_queue_free_dev(dev->cbdev);
>        netlink_kernel_release(dev->nls);
> --
> 1.5.4.rc3
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>



-- 
Regards & Thanks--
Subrata

[-- Attachment #1.2: Type: text/html, Size: 5616 bytes --]

[-- Attachment #2: Type: text/plain, Size: 247 bytes --]

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

[-- Attachment #3: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] CONNECTOR: add a proc entry to list connectors
  2008-06-24  8:38 [PATCH v2] CONNECTOR: add a proc entry to list connectors Li Zefan
       [not found] ` <4860B279.9070105-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
@ 2008-06-28  3:03 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2008-06-28  3:03 UTC (permalink / raw)
  To: lizf; +Cc: johnpol, linux-kernel, netdev

From: Li Zefan <lizf@cn.fujitsu.com>
Date: Tue, 24 Jun 2008 16:38:17 +0800

> I got a problem when I wanted to check if the kernel supports process
> event connector, and It seems there's no way to do this check.
> 
> At best I can check if the kernel supports connector or not, by looking
> into /proc/net/netlink, or maybe checking the return value of bind() to
> see if it's ENOENT.
> 
> So it would be useful to add /proc/net/connector to list all supported
> connectors:
>  # cat /proc/net/connector
>  Name            ID
>  connector       4294967295:4294967295
>  cn_proc         1:1
>  w1              3:1
> 
> Changelog:
> - fix memory leak: s/seq_release/single_release
> - use spin_lock_bh instead of spin_lock_irqsave
> 
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> Acked-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-06-28  3:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-24  8:38 [PATCH v2] CONNECTOR: add a proc entry to list connectors Li Zefan
     [not found] ` <4860B279.9070105-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2008-06-24 10:00   ` Subrata Modak
2008-06-28  3:03 ` David Miller

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).