diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-22 13:44:31 -0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-22 13:44:31 -0800 |
| commit | 7f23b49c7d696ac1f17965c22c8770a97ab90287 (patch) | |
| tree | 0d44eb6643272a1bb43015db020deccc2ffd7fae | |
| parent | c92cc90b8077f3b1484ae63846e62da60447c316 (diff) | |
| download | patches-7f23b49c7d696ac1f17965c22c8770a97ab90287.tar.gz | |
add ability to remove namespaces
| -rw-r--r-- | 0001-kdbus-interprocess-message-router.patch | 117 |
1 files changed, 103 insertions, 14 deletions
diff --git a/0001-kdbus-interprocess-message-router.patch b/0001-kdbus-interprocess-message-router.patch index 5ff064b8a243a3..c559a7b15800d2 100644 --- a/0001-kdbus-interprocess-message-router.patch +++ b/0001-kdbus-interprocess-message-router.patch @@ -9,14 +9,14 @@ Nothing to see here, move along... drivers/kdbus/Kconfig | 5 drivers/kdbus/Makefile | 4 drivers/kdbus/bus.c | 115 ++++++++++++ - drivers/kdbus/ep.c | 189 ++++++++++++++++++++ - drivers/kdbus/kdbus.c | 413 +++++++++++++++++++++++++++++++++++++++++++++ - drivers/kdbus/kdbus.h | 157 +++++++++++++++++ - drivers/kdbus/ns.c | 174 ++++++++++++++++++ - include/uapi/kdbus/kdbus.h | 50 +++++ + drivers/kdbus/ep.c | 189 +++++++++++++++++++ + drivers/kdbus/kdbus.c | 429 +++++++++++++++++++++++++++++++++++++++++++++ + drivers/kdbus/kdbus.h | 160 ++++++++++++++++ + drivers/kdbus/ns.c | 208 +++++++++++++++++++++ + include/uapi/kdbus/kdbus.h | 86 +++++++++ include/uapi/linux/major.h | 2 kdbus.c | 77 ++++++++ - 12 files changed, 1189 insertions(+) + 12 files changed, 1278 insertions(+) --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -258,7 +258,7 @@ Nothing to see here, move along... +/* Find the endpoint for a specific bus */ +struct kdbus_ep *kdbus_ep_find(struct kdbus_bus *bus, const char *name) +{ -+ struct kdbus_ep *ep = NULL; ++ struct kdbus_ep *ep; + + mutex_lock(&bus->lock); + list_for_each_entry(ep, &bus->ep_list, bus_entry) { @@ -361,7 +361,7 @@ Nothing to see here, move along... + --- /dev/null +++ b/drivers/kdbus/kdbus.c -@@ -0,0 +1,413 @@ +@@ -0,0 +1,429 @@ +/* + * kdbus - interprocess message routing + * @@ -590,6 +590,22 @@ Nothing to see here, move along... + } + break; + ++ case KDBUS_CMD_NS_REMOVE: ++ if (copy_from_user(&name, argp, sizeof(struct kdbus_cmd_name))) ++ return -EFAULT; ++ ++ ns = kdbus_ns_find(name.name); ++ if (!ns) ++ return -EINVAL; ++ ++ /* we can not remove the "default" namespace */ ++ if (ns == kdbus_ns_init) ++ return -EINVAL; ++ ++ kdbus_ns_unref(ns); ++ return 0; ++ break; ++ + default: + return -ENOTTY; + } @@ -777,7 +793,7 @@ Nothing to see here, move along... +MODULE_ALIAS("devname:kdbus/control"); --- /dev/null +++ b/drivers/kdbus/kdbus.h -@@ -0,0 +1,157 @@ +@@ -0,0 +1,160 @@ + + +#ifndef __INTERNAL_KDBUS_H @@ -795,6 +811,7 @@ Nothing to see here, move along... + */ +struct kdbus_ns { + unsigned int ref; /* reference count */ ++ const char *name; /* name of the namespace */ + bool disconnected; /* invalidated data */ + struct kdbus_ns *parent;/* parent namespace */ + __u64 id; /* global id of this namespace */ @@ -804,6 +821,7 @@ Nothing to see here, move along... + struct device *dev; /* control device node, minor == 0 */ + struct mutex lock; /* ns data lock */ + __u64 bus_id_next; /* next bus id sequence number */ ++ struct list_head list_entry; +}; + +/* @@ -909,6 +927,7 @@ Nothing to see here, move along... +void kdbus_ns_disconnect(struct kdbus_ns *ns); +struct kdbus_ns *kdbus_ns_unref(struct kdbus_ns *ns); +int kdbus_ns_new(struct kdbus_ns *parent, const char *name, struct kdbus_ns **ns); ++struct kdbus_ns *kdbus_ns_find(const char *name); + + +/* bus stuff */ @@ -937,7 +956,7 @@ Nothing to see here, move along... +#endif --- /dev/null +++ b/drivers/kdbus/ns.c -@@ -0,0 +1,174 @@ +@@ -0,0 +1,208 @@ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include <linux/module.h> @@ -955,6 +974,9 @@ Nothing to see here, move along... + +#include "kdbus.h" + ++/* global list of all namespaces */ ++static LIST_HEAD(namespace_list); ++ +/* next namespace id sequence number */ +static __u64 kdbus_ns_id_next; + @@ -1011,6 +1033,8 @@ Nothing to see here, move along... + + kdbus_ns_disconnect(ns); + pr_info("clean up namespace %s\n", ns->devpath); ++ list_del(&ns->list_entry); ++ kfree(ns->name); + kfree(ns->devpath); + kfree(ns); + return NULL; @@ -1019,6 +1043,7 @@ Nothing to see here, move along... +int kdbus_ns_new(struct kdbus_ns *parent, const char *name, struct kdbus_ns **ns) +{ + struct kdbus_ns *n; ++ const char *ns_name = NULL; + int i; + int err; + @@ -1031,6 +1056,14 @@ Nothing to see here, move along... + if (!n) + return -ENOMEM; + ++ if (name) { ++ ns_name = kstrdup(name, GFP_KERNEL); ++ if (!ns_name) { ++ kfree(n); ++ return -ENOMEM; ++ } ++ } ++ + n->ref = 1; + idr_init(&n->idr); + mutex_init(&n->lock); @@ -1051,8 +1084,8 @@ Nothing to see here, move along... + n->major = KDBUS_CHAR_MAJOR; + } else { + n->parent = parent; -+// n->devpath = kasprintf(GFP_KERNEL, "kdbus/ns/%s/%s", parent->devpath, name); -+ n->devpath = kasprintf(GFP_KERNEL, "kdbus/ns/%s", name); ++ n->devpath = kasprintf(GFP_KERNEL, "kdbus/ns/%s/%s", parent->devpath, name); ++// n->devpath = kasprintf(GFP_KERNEL, "kdbus/ns/%s", name); + if (!n->devpath) { + err = -ENOMEM; + goto err; @@ -1064,6 +1097,7 @@ Nothing to see here, move along... + err = n->major; + goto err; + } ++ n->name = ns_name; + } + + /* register major in our namespace map */ @@ -1097,6 +1131,10 @@ Nothing to see here, move along... + n->dev = NULL; + goto err_unlock; + } ++ ++ /* Add to global list of namespaces so we can find it again */ ++ list_add_tail(&n->list_entry, &namespace_list); ++ + mutex_unlock(&kdbus_subsys_lock); + + *ns = n; @@ -1111,10 +1149,25 @@ Nothing to see here, move along... + return err; +} + ++struct kdbus_ns *kdbus_ns_find(const char *name) ++{ ++ struct kdbus_ns *ns; ++ ++ mutex_lock(&kdbus_subsys_lock); ++ list_for_each_entry(ns, &namespace_list, list_entry) { ++ if (!strcmp(ns->name, name)) ++ goto exit; ++ } ++ /* namespace not found so return NULL */ ++ ns = NULL; ++exit: ++ mutex_unlock(&kdbus_subsys_lock); ++ return ns; ++} + --- /dev/null +++ b/include/uapi/kdbus/kdbus.h -@@ -0,0 +1,50 @@ +@@ -0,0 +1,86 @@ +/* + * kdbus - interprocess message routing + * @@ -1143,14 +1196,50 @@ Nothing to see here, move along... + char msg[256]; /* FIXME obviously... */ +}; + ++ ++#if 0 ++/* Old-style dbus had the following message type: */ ++struct old_dbus_header { ++ u8 endianness; /* 'l' for little endian, 'B' for big endian */ ++ u8 type; /* message type */ ++ u8 flags; ++ u8 protocol_version; ++ u32 message_length ++ u32 cookie; ++} ++ ++#define DBUS_TYPE_INVALID 0 ++#define DBUS_TYPE_METHOD_CALL 1 ++#define DBUS_TYPE_METHOD_RETURN 2 ++#define DBUS_TYPE_ERROR 3 ++#define DBUS_TYPE_SIGNAL 4 ++ ++#define DBUS_FLAG_NO_REPLY_EXPECTED 0x01 ++#define DBUS_FLAG_NO_AUTO_START 0x02 ++ ++#define DBUS_FIELD_INVALID 0 ++#define DBUS_FIELD_PATH 1 ++#define DBUS_FIELD_INTERFACE 2 ++#define DBUS_FIELD_MEMBER 3 ++#define DBUS_FIELD_ERROR_NAME 4 ++#define DBUS_FIELD_REPLY_SERIAL 5 ++#define DBUS_FIELD_DESTINATION 6 ++#define DBUS_FIELD_SENDER 7 ++#define DBUS_FIELD_SIGNATURE 8 ++#define DBUS_FIELD_UNIX_FDS 9 ++ ++#endif ++ +enum kdbus_cmd { + /* kdbus control commands */ + KDBUS_CMD_BUS_CREATE = _IOW(KDBUS_IOC_MAGIC, 0x00, struct kdbus_cmd_name), ++ KDBUS_CMD_BUS_REMOVE = _IOW(KDBUS_IOC_MAGIC, 0x01, struct kdbus_cmd_name), + KDBUS_CMD_NS_CREATE = _IOW(KDBUS_IOC_MAGIC, 0x10, struct kdbus_cmd_name), ++ KDBUS_CMD_NS_REMOVE = _IOW(KDBUS_IOC_MAGIC, 0x11, struct kdbus_cmd_name), + + /* kdbus endpoint commands */ + KDBUS_CMD_EP_CREATE = _IOWR(KDBUS_IOC_MAGIC, 0x30, struct kdbus_cmd_name), -+ KDBUS_CMD_EP_REMOVE = _IOWR(KDBUS_IOC_MAGIC, 0x31, int), ++ KDBUS_CMD_EP_REMOVE = _IOWR(KDBUS_IOC_MAGIC, 0x31, struct kdbus_cmd_name), + KDBUS_CMD_EP_POLICY_SET = _IOWR(KDBUS_IOC_MAGIC, 0x32, int), + + KDBUS_CMD_NAME_ACQUIRE = _IOWR(KDBUS_IOC_MAGIC, 0x50, int), |
