Skip to contentSkip to conversation

Kernel conector. Reincarnation #1.

PATCH Applied Evgeniy Polyakov 3 participants 12 messages Dec 22, 2004 – Jan 20, 2005 8 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#5 lore raw
In reply to a message not in the archive

Hello, Greg, developers.

This is first public resending of connector patch after several private discussions.
Noone objected before, so if there are no complaints, Greg, please apply.

Signature · 3 lines
        Evgeniy Polyakov

Crash is better than data corruption -- Arthur Grabowski
drivers/connector/Kconfig renamed from tmp/empty/Kconfig +13 -0
diff -Nru /tmp/empty/Kconfig linux-2.6/drivers/connector/Kconfig
@@ -0,0 +1,13 @@
+menu "Connector - unified userspace <-> kernelspace linker"
+
+config CONNECTOR
+	tristate "Connector - unified userspace <-> kernelspace linker"
+	depends on NET
+	---help---
+	  This is unified userspace <-> kernelspace connector working on top
+	  of the netlink socket protocol.
+
+	  Connector support can also be built as a module.  If so, the module
+	  will be called connector.ko.
+
+endmenu
drivers/connector/Makefile renamed from tmp/empty/Makefile +2 -0
diff -Nru /tmp/empty/Makefile linux-2.6/drivers/connector/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_CONNECTOR)		+= cn.o
+cn-objs		:= cn_queue.o connector.o
drivers/connector/cn_queue.c renamed from tmp/empty/cn_queue.c +219 -0

219 lines not on this page · raw message

drivers/connector/cn_queue.h renamed from tmp/empty/cn_queue.h +90 -0

90 lines not on this page · raw message

drivers/connector/connector.c renamed from tmp/empty/connector.c +498 -0

498 lines not on this page · raw message

drivers/connector/connector.h renamed from tmp/empty/connector.h +81 -0

81 lines not on this page · raw message

drivers/Kconfig renamed from drivers/Kconfig.orig +2 -0
@@ -44,6 +44,8 @@
 
 source "drivers/w1/Kconfig"
 
+source "drivers/connector/Kconfig"
+
 source "drivers/misc/Kconfig"
 
 source "drivers/media/Kconfig"
drivers/Makefile renamed from drivers/Makefile.orig +1 -0
@@ -44,6 +44,7 @@
 obj-$(CONFIG_I2O)		+= message/
 obj-$(CONFIG_I2C)		+= i2c/
 obj-$(CONFIG_W1)		+= w1/
+obj-$(CONFIG_CONNECTOR)	+= connector/
 obj-$(CONFIG_PHONE)		+= telephony/
 obj-$(CONFIG_MD)		+= md/
 obj-$(CONFIG_BT)		+= bluetooth/
#6 lore raw
Quoted 6 lines · Evgeniy Polyakov

Hello, Greg, developers.

This is first public resending of connector patch after several private discussions.
Noone objected before, so if there are no complaints, Greg, please apply.

one minor issue:

Quoted 1 line

+#include "../connector/connector.h"

Shouldn't connector.h go into include/linux so that everyone can use it within the kernel? If so, then it's dependancy on cn_queue.h needs to be fixed up too (why not just merge them both together)?

Quoted 1 line

+#include "../connector/cn_queue.h"

This can just be:

	#include "cn_queue.h"

if you end up still needing it.

Sorry for taking so long to get back to this, was on vacation.

thanks,

greg k-h

#7 lore raw
Quoted 16 lines · On Wed, 12 Jan 2005 11:03:19 -0800 Greg KH <[email protected]> wrote:
Quoted 6 lines · Evgeniy Polyakov

Hello, Greg, developers.

This is first public resending of connector patch after several private discussions.
Noone objected before, so if there are no complaints, Greg, please apply.

one minor issue:

Quoted 1 line

+#include "../connector/connector.h"

Shouldn't connector.h go into include/linux so that everyone can use it within the kernel? If so, then it's dependancy on cn_queue.h needs to be fixed up too (why not just merge them both together)?

Quoted 5 lines
Quoted 1 line

+#include "../connector/cn_queue.h"

This can just be:

	#include "cn_queue.h"

if you end up still needing it.

Yep, I've fixed that.
Now it has only one header connector.h in linux/ include directory.

Quoted 2 lines

Sorry for taking so long to get back to this, was on vacation.

Do not mention, hope they were cool.

Quoted 3 lines

thanks,

greg k-h

Evgeniy Polyakov

Only failure makes us experts. -- Theo de Raadt

drivers/connector/Kconfig renamed from tmp/empty/Kconfig +13 -0
diff -Nru /tmp/empty/Kconfig linux-2.6.9/drivers/connector/Kconfig
@@ -0,0 +1,13 @@
+menu "Connector - unified userspace <-> kernelspace linker"
+
+config CONNECTOR
+	tristate "Connector - unified userspace <-> kernelspace linker"
+	depends on NET
+	---help---
+	  This is unified userspace <-> kernelspace connector working on top
+	  of the netlink socket protocol.
+
+	  Connector support can also be built as a module.  If so, the module
+	  will be called cn.ko.
+
+endmenu
drivers/connector/Makefile renamed from tmp/empty/Makefile +2 -0
diff -Nru /tmp/empty/Makefile linux-2.6.9/drivers/connector/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_CONNECTOR)		+= cn.o
+cn-objs		:= cn_queue.o connector.o
drivers/connector/cn_queue.c renamed from tmp/empty/cn_queue.c +224 -0

224 lines not on this page · raw message

drivers/connector/connector.c renamed from tmp/empty/connector.c +496 -0

496 lines not on this page · raw message

include/linux/connector.h new file +142 -0

142 lines not on this page · raw message

#8 lore raw

Sorry, forget about nasty typo.
Current one is right.

drivers/connector/Kconfig renamed from tmp/empty/Kconfig +13 -0
diff -Nru /tmp/empty/Kconfig linux-2.6.9/drivers/connector/Kconfig
@@ -0,0 +1,13 @@
+menu "Connector - unified userspace <-> kernelspace linker"
+
+config CONNECTOR
+	tristate "Connector - unified userspace <-> kernelspace linker"
+	depends on NET
+	---help---
+	  This is unified userspace <-> kernelspace connector working on top
+	  of the netlink socket protocol.
+
+	  Connector support can also be built as a module.  If so, the module
+	  will be called cn.ko.
+
+endmenu
drivers/connector/Makefile renamed from tmp/empty/Makefile +2 -0
diff -Nru /tmp/empty/Makefile linux-2.6.9/drivers/connector/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_CONNECTOR)		+= cn.o
+cn-objs		:= cn_queue.o connector.o
drivers/connector/cn_queue.c renamed from tmp/empty/cn_queue.c +224 -0

224 lines not on this page · raw message

drivers/connector/connector.c renamed from tmp/empty/connector.c +496 -0

496 lines not on this page · raw message

include/linux/connector.h new file +142 -0

142 lines not on this page · raw message

drivers/Kconfig renamed from drivers/Kconfig.orig +2 -0
@@ -4,6 +4,8 @@
 
 source "drivers/base/Kconfig"
 
+source "drivers/connector/Kconfig"
+
 source "drivers/mtd/Kconfig"
 
 source "drivers/parport/Kconfig"
drivers/Makefile renamed from drivers/Makefile.orig +2 -0
@@ -17,6 +17,8 @@
 # default.
 obj-y				+= char/
 
+obj-$(CONFIG_CONNECTOR)	+= connector/
+
 # i810fb and intelfb depend on char/agp/
 obj-$(CONFIG_FB_I810)           += video/i810/
 obj-$(CONFIG_FB_INTEL)          += video/intelfb/

Evgeniy Polyakov

Only failure makes us experts. -- Theo de Raadt

#16 lore raw

kobject_uevent.c moved to kernel connector.

In reply to a message not in the archive

kobject_uevent.c change which allows to use new kernel connector interface. More details at http://marc.theaimsgroup.com/?l=linux-kernel&m=110370721906005&w=2
They require small change to kernel connector itself(needs it export initialization flag), also attached small programm to read kobject data. Usage:

s0mbre@kuasar:~/aWork/connector$ sudo ./kobj
Password:
Thu Jan 13 00:36:58 2005 : [abcd.0] [seq=4294967295, ack=4294967295], add@/devices/pci0000:00/0000:00:1d.2/usb3/3-1.
Thu Jan 13 00:36:58 2005 : [abcd.0] [seq=1936024425, ack=1768124463], add@/devices/pci0000:00/0000:00:1d.2/usb3/3-1/3-1:1.0.
Thu Jan 13 00:36:58 2005 : [abcd.0] [seq=1936024425, ack=1768124463], add@/devices/pci0000:00/0000:00:1d.2/usb3/3-1/3-1:1.1.
Thu Jan 13 00:36:58 2005 : [abcd.0] [seq=1936024425, ack=1768124463], add@/devices/pci0000:00/0000:00:1d.2/usb3/3-1/3-1:1.2.
Thu Jan 13 00:36:58 2005 : [abcd.0] [seq=1936024425, ack=0], add@/module/hci_usb.
Thu Jan 13 00:36:58 2005 : [abcd.0] [seq=1936024425, ack=0], add@/module/hci_usb/sections.
Thu Jan 13 00:36:58 2005 : [abcd.0] [seq=1936024425, ack=0], add@/bus/usb/drivers/hci_usb.
Thu Jan 13 00:36:58 2005 : [abcd.0] [seq=1936024425, ack=0], add@/class/bluetooth/hci0.
Thu Jan 13 00:37:04 2005 : [abcd.0] [seq=1647276915, ack=1952806252], remove@/class/bluetooth/hci0.
Thu Jan 13 00:37:05 2005 : [abcd.0] [seq=1935764579, ack=1818374003], remove@/devices/pci0000:00/0000:00:1d.2/usb3/3-1/3-1:1.0.
Thu Jan 13 00:37:05 2005 : [abcd.0] [seq=1935764579, ack=1818374003], remove@/devices/pci0000:00/0000:00:1d.2/usb3/3-1/3-1:1.1.
Thu Jan 13 00:37:05 2005 : [abcd.0] [seq=1935764579, ack=1818374003], remove@/devices/pci0000:00/0000:00:1d.2/usb3/3-1/3-1:1.2.
Thu Jan 13 00:37:05 2005 : [abcd.0] [seq=1935764579, ack=1818374003], remove@/devices/pci0000:00/0000:00:1d.2/usb3/3-1.

P.S. I'm not subscribed to these mail lists, please CC me in your answers.

linux/connector.h renamed from linux/connector.h~ +3 -0
@@ -24,6 +24,9 @@
 
 #include <asm/types.h>
 
+#define CONN_IDX_KOBJECT_UEVENT		0xabcd
+#define CONN_VAL_KOBJECT_UEVENT		0x0000
+
 #define CONNECTOR_MAX_MSG_SIZE 	1024
 
 struct cb_id
drivers/connector/connector.c renamed from drivers/connector/connector.c.orig +14 -1
@@ -46,6 +46,8 @@
 
 static struct cn_dev cdev;
 
+int cn_already_initialized = 0;
+
 /*
  * msg->seq and msg->ack are used to determine message genealogy.
  * When someone sends message it puts there locally unique sequence 
@@ -456,6 +458,7 @@
 static int cn_init(void)
 {
 	struct cn_dev *dev = &cdev;
+	int err;
 
 	dev->input = cn_input;
 	dev->id.idx = cn_idx;
@@ -475,7 +478,17 @@
 		return -EINVAL;
 	}
 
-	return cn_add_callback(&dev->id, "connector", &cn_callback);
+	err = cn_add_callback(&dev->id, "connector", &cn_callback);
+	if (err) {
+		cn_queue_free_dev(dev->cbdev);
+		if (dev->nls->sk_socket)
+			sock_release(dev->nls->sk_socket);
+		return -EINVAL;
+	}
+
+	cn_already_initialized = 1;
+
+	return 0;
 }
 
 static void cn_fini(void)
lib/kobject_uevent.c renamed from lib/kobject_uevent.c.orig +66 -0

90 lines not on this page · raw message

Evgeniy Polyakov

Only failure makes us experts. -- Theo de Raadt

/*
* kobj.c
*
* Copyright (c) 2005 Evgeniy Polyakov <[email protected]>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */

#include <asm/types.h>

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/poll.h>

#include <linux/netlink.h>
#include <linux/rtnetlink.h>

#include <arpa/inet.h>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <time.h>

#include "connector.h"
#include "../soekris/sc_conn.h"

static int need_exit;
__u32 seq;

int main(int argc, char *argv[])

{
	int s;
	char buf[1024];
	int len;
	struct nlmsghdr *reply;
	struct sockaddr_nl l_local;
	struct cn_msg *data;
	char *m;
	FILE *out;
	time_t tm;
	struct pollfd pfd;
	int pin_number = 0;

	if (argc < 2)
		out = stdout;
	else {
		out = fopen(argv[1], "a+");
		if (!out) {
			fprintf(stderr, "Unable to open %s for writing: %s\n",
				argv[1], strerror(errno));
			out = stdout;
		}
	}

	memset(buf, 0, sizeof(buf));

	s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_NFLOG);
	if (s == -1) {
		perror("socket");
		return -1;
	}

	l_local.nl_family = AF_NETLINK;
	l_local.nl_groups = 0xabcd;
	l_local.nl_pid = getpid();

	if (bind(s, (struct sockaddr *)&l_local, sizeof(struct sockaddr_nl)) == -1) {
		perror("bind");
		close(s);
		return -1;
	}

	pfd.fd = s;

	while (!need_exit) {
		pfd.events = POLLIN;
		pfd.revents = 0;
		switch (poll(&pfd, 1, -1)) 
		{
			case 0:
				need_exit = 1;
				break;
			case -1:
				if (errno != EINTR) 
				{
					need_exit = 1;
					break;
				}
			continue;
		}
		if (need_exit)
			break;

		memset(buf, 0, sizeof(buf));
		len = recv(s, buf, sizeof(buf), 0);
		if (len == -1) {
			perror("recv buf");
			close(s);
			return -1;
		}
		reply = (struct nlmsghdr *)buf;

		switch (reply->nlmsg_type) {
		case NLMSG_ERROR:
			fprintf(out, "Error message received.\n");
			fflush(out);
			break;
		case NLMSG_DONE:
			data = (struct cn_msg *)NLMSG_DATA(reply);
			m = (char *)(data + 1);

			time(&tm);
			fprintf(out,
				"%.24s : [%x.%x] [seq=%u, ack=%u], %s.\n",
				ctime(&tm), data->id.idx, data->id.val,
				data->seq, data->ack, m);
			fflush(out);
			break;
		default:
			break;
		}

		//sleep(1);
	}

	close(s);
	return 0;
}
#12 lore raw

Kernel conector. Reincarnation #2. GPL issues.

In reply to Evgeniy Polyakov

Export connectors callbacks as GPL only.

drivers/Makefile renamed from drivers/Makefile.orig +2 -0
@@ -17,6 +17,8 @@
 # default.
 obj-y				+= char/
 
+obj-$(CONFIG_CONNECTOR)	+= connector/
+
 # i810fb and intelfb depend on char/agp/
 obj-$(CONFIG_FB_I810)           += video/i810/
 obj-$(CONFIG_FB_INTEL)          += video/intelfb/
drivers/connector/Kconfig renamed from tmp/empty/Kconfig +13 -0
diff -Nru /tmp/empty/Kconfig linux-2.6/drivers/connector/Kconfig
@@ -0,0 +1,13 @@
+menu "Connector - unified userspace <-> kernelspace linker"
+
+config CONNECTOR
+	tristate "Connector - unified userspace <-> kernelspace linker"
+	depends on NET
+	---help---
+	  This is unified userspace <-> kernelspace connector working on top
+	  of the netlink socket protocol.
+
+	  Connector support can also be built as a module.  If so, the module
+	  will be called cn.ko.
+
+endmenu
drivers/connector/Makefile renamed from tmp/empty/Makefile +2 -0
diff -Nru /tmp/empty/Makefile linux-2.6/drivers/connector/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_CONNECTOR)		+= cn.o
+cn-objs		:= cn_queue.o connector.o
drivers/connector/cn_queue.c renamed from tmp/empty/cn_queue.c +218 -0

218 lines not on this page · raw message

drivers/connector/connector.c renamed from tmp/empty/connector.c +509 -0

509 lines not on this page · raw message

include/linux/connector.h new file +147 -0

147 lines not on this page · raw message

drivers/Kconfig renamed from drivers/Kconfig.orig +2 -0
@@ -4,6 +4,8 @@
 
 source "drivers/base/Kconfig"
 
+source "drivers/connector/Kconfig"
+
 source "drivers/mtd/Kconfig"
 
 source "drivers/parport/Kconfig"

Evgeniy Polyakov

Only failure makes us experts. -- Theo de Raadt

#9 lore raw
In reply to Evgeniy Polyakov
Quoted 2 lines · Evgeniy Polyakov

Sorry, forget about nasty typo.
Current one is right.

<snip>

Quoted 3 lines

diff -Nru /tmp/empty/cn_queue.c linux-2.6.9/drivers/connector/cn_queue.c

drivers/connector/cn_queue.c 2005-01-12 23:23:45.000000000 +0300 renamed from tmp/empty/cn_queue.c 1970-01-01 03:00:00.000000000 +0300 +0 -0

<snip>

Quoted 12 lines
drivers/connector/cn_queue.c 2005-01-12 23:23:45.000000000 +0300 renamed from tmp/empty/cn_queue.c 1970-01-01 03:00:00.000000000 +0300 +12 -0
+       while (atomic_read(&cbq->cb->refcnt)) {
+               printk(KERN_INFO "Waiting for %s to become free: refcnt=%d.\n",
+                      cbq->pdev->name, atomic_read(&cbq->cb->refcnt));
+               set_current_state(TASK_INTERRUPTIBLE);
+               schedule_timeout(HZ);
+
+               if (current->flags & PF_FREEZE)
+                       refrigerator(PF_FREEZE);
+
+               if (signal_pending(current))
+                       flush_signals(current);
+       }

<snip>

drivers/connector/cn_queue.c 2005-01-12 23:23:45.000000000 +0300

Quoted 12 lines
drivers/connector/cn_queue.c 2005-01-12 23:23:45.000000000 +0300 renamed from tmp/empty/cn_queue.c 1970-01-01 03:00:00.000000000 +0300 +12 -0
+       while (atomic_read(&dev->refcnt)) {
+               printk(KERN_INFO "Waiting for %s to become free: refcnt=%d.\n",
+                      dev->name, atomic_read(&dev->refcnt));
+               set_current_state(TASK_INTERRUPTIBLE);
+               schedule_timeout(HZ);
+
+               if (current->flags & PF_FREEZE)
+                       refrigerator(PF_FREEZE);
+
+               if (signal_pending(current))
+                       flush_signals(current);
+       }

Would it be possible to use msleep_interruptible(1000) in both of these locations? You only seem to be concerned with signals (not wait-queue events) and the time is rather long (1000 msec). signals_pending(current) will still be true upon return from msleep_interruptible(), so it's a minimal change, I think.

Thanks,
Nish

#10 lore raw
Quoted 38 lines · Nish Aravamudan
Quoted 2 lines · Evgeniy Polyakov

Sorry, forget about nasty typo.
Current one is right.

<snip>

Quoted 3 lines

diff -Nru /tmp/empty/cn_queue.c linux-2.6.9/drivers/connector/cn_queue.c

drivers/connector/cn_queue.c 2005-01-12 23:23:45.000000000 +0300 renamed from tmp/empty/cn_queue.c 1970-01-01 03:00:00.000000000 +0300 +0 -0

<snip>

Quoted 12 lines
drivers/connector/cn_queue.c 2005-01-12 23:23:45.000000000 +0300 renamed from tmp/empty/cn_queue.c 1970-01-01 03:00:00.000000000 +0300 +12 -0
+       while (atomic_read(&cbq->cb->refcnt)) {
+               printk(KERN_INFO "Waiting for %s to become free: refcnt=%d.\n",
+                      cbq->pdev->name, atomic_read(&cbq->cb->refcnt));
+               set_current_state(TASK_INTERRUPTIBLE);
+               schedule_timeout(HZ);
+
+               if (current->flags & PF_FREEZE)
+                       refrigerator(PF_FREEZE);
+
+               if (signal_pending(current))
+                       flush_signals(current);
+       }

<snip>

Quoted 10 lines
drivers/connector/cn_queue.c 2005-01-12 23:23:45.000000000 +0300 renamed from tmp/empty/cn_queue.c 1970-01-01 03:00:00.000000000 +0300 +10 -0
+       while (atomic_read(&dev->refcnt)) {
+               printk(KERN_INFO "Waiting for %s to become free: refcnt=%d.\n",
+                      dev->name, atomic_read(&dev->refcnt));
+               set_current_state(TASK_INTERRUPTIBLE);
+               schedule_timeout(HZ);
+
+               if (current->flags & PF_FREEZE)
+                       refrigerator(PF_FREEZE);
+
+               if (signal_pending(current))
Quoted 8 lines

drivers/connector/cn_queue.c 2005-01-12 23:23:45.000000000 +0300

Quoted 2 lines
drivers/connector/cn_queue.c 2005-01-12 23:23:45.000000000 +0300 renamed from tmp/empty/cn_queue.c 1970-01-01 03:00:00.000000000 +0300 +2 -0
+                       flush_signals(current);
+       }

Would it be possible to use msleep_interruptible(1000) in both of these locations? You only seem to be concerned with signals (not wait-queue events) and the time is rather long (1000 msec). signals_pending(current) will still be true upon return from msleep_interruptible(), so it's a minimal change, I think.

Ok, updated patch attached.
Thank you.

Quoted 2 lines

Thanks,
Nish

Signature · 3 lines
        Evgeniy Polyakov

Crash is better than data corruption -- Arthur Grabowski
drivers/Kconfig renamed from drivers/Kconfig.orig +2 -0
@@ -4,6 +4,8 @@
 
 source "drivers/base/Kconfig"
 
+source "drivers/connector/Kconfig"
+
 source "drivers/mtd/Kconfig"
 
 source "drivers/parport/Kconfig"
drivers/Makefile renamed from drivers/Makefile.orig +2 -0
@@ -17,6 +17,8 @@
 # default.
 obj-y				+= char/
 
+obj-$(CONFIG_CONNECTOR)	+= connector/
+
 # i810fb and intelfb depend on char/agp/
 obj-$(CONFIG_FB_I810)           += video/i810/
 obj-$(CONFIG_FB_INTEL)          += video/intelfb/
drivers/connector/Kconfig renamed from tmp/empty/Kconfig +13 -0
diff -Nru /tmp/empty/Kconfig linux-2.6/drivers/connector/Kconfig
@@ -0,0 +1,13 @@
+menu "Connector - unified userspace <-> kernelspace linker"
+
+config CONNECTOR
+	tristate "Connector - unified userspace <-> kernelspace linker"
+	depends on NET
+	---help---
+	  This is unified userspace <-> kernelspace connector working on top
+	  of the netlink socket protocol.
+
+	  Connector support can also be built as a module.  If so, the module
+	  will be called cn.ko.
+
+endmenu
drivers/connector/Makefile renamed from tmp/empty/Makefile +2 -0
diff -Nru /tmp/empty/Makefile linux-2.6/drivers/connector/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_CONNECTOR)		+= cn.o
+cn-objs		:= cn_queue.o connector.o
drivers/connector/cn_queue.c renamed from tmp/empty/cn_queue.c +219 -0

219 lines not on this page · raw message

drivers/connector/connector.c renamed from tmp/empty/connector.c +509 -0

509 lines not on this page · raw message

include/linux/connector.h new file +147 -0

147 lines not on this page · raw message

#17 lore raw

Re: kobject_uevent.c moved to kernel connector.

In reply to Evgeniy Polyakov
Quoted 15 lines · Evgeniy Polyakov
linux/connector.h renamed from linux/connector.h~ +3 -0
@@ -24,6 +24,9 @@
 
 #include <asm/types.h>
 
+#define CONN_IDX_KOBJECT_UEVENT		0xabcd
+#define CONN_VAL_KOBJECT_UEVENT		0x0000
+
 #define CONNECTOR_MAX_MSG_SIZE 	1024
 
 struct cb_id

drivers/connector/connector.c line 49

Quoted 4 lines
drivers/connector/connector.c renamed from drivers/connector/connector.c.orig +1 -0
@@ -46,6 +46,8 @@
 
 static struct cn_dev cdev;
 
+int cn_already_initialized = 0;

<snip>

Hm, this patch needs to be rediffed, now that I've accepted the connector code, right? The connector.c change seems to already be in your last connector patch, and the .h change is there with a different #define spelling, causing the uevent code to need to be changed.

Care to redo it?

thanks,

greg k-h

-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#18 lore raw

Re: kobject_uevent.c moved to kernel connector.

In reply to Greg KH
Quoted 23 lines · Greg KH
Quoted 19 lines · Evgeniy Polyakov
linux/connector.h renamed from linux/connector.h~ +3 -0
@@ -24,6 +24,9 @@
 
 #include <asm/types.h>
 
+#define CONN_IDX_KOBJECT_UEVENT		0xabcd
+#define CONN_VAL_KOBJECT_UEVENT		0x0000
+
 #define CONNECTOR_MAX_MSG_SIZE 	1024
 
 struct cb_id
drivers/connector/connector.c renamed from drivers/connector/connector.c.orig +1 -0
@@ -46,6 +46,8 @@
 
 static struct cn_dev cdev;
 
+int cn_already_initialized = 0;

<snip>

Quoted 6 lines

Hm, this patch needs to be rediffed, now that I've accepted the connector code, right? The connector.c change seems to already be in your last connector patch, and the .h change is there with a different #define spelling, causing the uevent code to need to be changed.

Care to redo it?

Sure. Patch attached.

Thank you.

Quoted 3 lines

thanks,

greg k-h

Signature · 3 lines
        Evgeniy Polyakov

Crash is better than data corruption -- Arthur Grabowski
lib/kobject_uevent.c renamed from lib/kobject_uevent.c.orig +66 -0
@@ -12,6 +12,7 @@
  *	Kay Sievers		<[email protected]>
  *	Arjan van de Ven	<[email protected]>
  *	Greg Kroah-Hartman	<[email protected]>
+ *	Evgeniy Polyakov 	<[email protected]>
  */
 
 #include <linux/spinlock.h>
@@ -21,6 +22,7 @@
 #include <linux/string.h>
 #include <linux/kobject_uevent.h>
 #include <linux/kobject.h>
+#include <linux/connector.h>
 #include <net/sock.h>
 
 #define BUFFER_SIZE	1024	/* buffer for the hotplug env */
@@ -53,6 +55,68 @@
 #ifdef CONFIG_KOBJECT_UEVENT
 static struct sock *uevent_sock;
 
+#ifdef CONFIG_CONNECTOR
+static struct cb_id uid = {CN_IDX_KOBJECT_UEVENT, CN_VAL_KOBJECT_UEVENT};
+static void kobject_uevent_connector_callback(void *data)
+{
+}
+
+static void kobject_uevent_send_connector(const char *signal, const char *obj, char **envp, int gfp_mask)
+{
+	if (cn_already_initialized) {
+		int size;
+		struct cn_msg *msg;
+		static int uevent_connector_initialized;
+		
+		if (!uevent_connector_initialized) {
+			cn_add_callback(&uid, "kobject_uevent", kobject_uevent_connector_callback);
+			uevent_connector_initialized = 1;
+		}
+
+
+		size = strlen(signal) + strlen(obj) + 2 + BUFFER_SIZE + sizeof(*msg);
+		msg = kmalloc(size, gfp_mask);
+		if (msg) {
+			u8 *pos;
+			int len;
+
+			msg->len = size - sizeof(*msg);
+
+			memcpy(&msg->id, &uid, sizeof(msg->id));
+			
+			size -= sizeof(*msg);
+
+			pos = (u8 *)(msg + 1);
+			
+			len = snprintf(pos, size, "%s@%s", signal, obj);
+			len++;
+			size -= len;
+			pos += len;
+			
+			if (envp) {
+				int i;
+
+				for (i = 2; envp[i]; i++) {
+					len = strlen(envp[i]) + 1;
+					snprintf(pos, size, "%s", envp[i]);
+					size -= len;
+					pos += len;
+				}
+			}
+
+			cn_netlink_send(msg, 0);
+
+			kfree(msg);
+		}
+	}
+}
+#else
+static void kobject_uevent_send_connector(const char *signal, const char *obj, char **envp, int gfp_mask)
+{
+}
+#endif
+
+
 /**
  * send_uevent - notify userspace by sending event trough netlink socket
  *
@@ -93,6 +157,8 @@
 		}
 	}
 
+	kobject_uevent_send_connector(signal, obj, envp, gfp_mask);
+
 	return netlink_broadcast(uevent_sock, skb, 0, 1, gfp_mask);
 }
 
Applied
#19 lore raw

Re: kobject_uevent.c moved to kernel connector.

Quoted 24 lines · Evgeniy Polyakov
Quoted 23 lines · Greg KH
Quoted 19 lines · Evgeniy Polyakov
linux/connector.h renamed from linux/connector.h~ +3 -0
@@ -24,6 +24,9 @@
 
 #include <asm/types.h>
 
+#define CONN_IDX_KOBJECT_UEVENT		0xabcd
+#define CONN_VAL_KOBJECT_UEVENT		0x0000
+
 #define CONNECTOR_MAX_MSG_SIZE 	1024
 
 struct cb_id
drivers/connector/connector.c renamed from drivers/connector/connector.c.orig +1 -0
@@ -46,6 +46,8 @@
 
 static struct cn_dev cdev;
 
+int cn_already_initialized = 0;

<snip>

Quoted 8 lines
Quoted 6 lines

Hm, this patch needs to be rediffed, now that I've accepted the connector code, right? The connector.c change seems to already be in your last connector patch, and the .h change is there with a different #define spelling, causing the uevent code to need to be changed.

Care to redo it?

Sure. Patch attached.

Applied, thanks.

greg k-h

-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel