diff options
-rw-r--r-- | bus.c | 4 | ||||
-rw-r--r-- | bus.h | 1 | ||||
-rw-r--r-- | connection.c | 4 | ||||
-rw-r--r-- | connection.h | 2 | ||||
-rw-r--r-- | endpoint.c | 8 | ||||
-rw-r--r-- | endpoint.h | 1 | ||||
-rw-r--r-- | handle.c | 4 | ||||
-rw-r--r-- | handle.h | 17 | ||||
-rw-r--r-- | internal.h | 49 | ||||
-rw-r--r-- | main.c | 21 | ||||
-rw-r--r-- | match.c | 2 | ||||
-rw-r--r-- | match.h | 1 | ||||
-rw-r--r-- | memfd.c | 4 | ||||
-rw-r--r-- | memfd.h | 2 | ||||
-rw-r--r-- | message.c | 2 | ||||
-rw-r--r-- | message.h | 1 | ||||
-rw-r--r-- | metadata.c | 2 | ||||
-rw-r--r-- | metadata.h | 1 | ||||
-rw-r--r-- | names.c | 2 | ||||
-rw-r--r-- | names.h | 1 | ||||
-rw-r--r-- | namespace.c | 24 | ||||
-rw-r--r-- | namespace.h | 4 | ||||
-rw-r--r-- | notify.c | 2 | ||||
-rw-r--r-- | notify.h | 1 | ||||
-rw-r--r-- | policy.c | 2 | ||||
-rw-r--r-- | policy.h | 1 | ||||
-rw-r--r-- | pool.c | 4 | ||||
-rw-r--r-- | pool.h | 2 |
28 files changed, 102 insertions, 67 deletions
@@ -1,7 +1,7 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - * Copyright (C) 2013 Daniel Mack + * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under @@ -10,8 +10,6 @@ * your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/module.h> #include <linux/device.h> #include <linux/fs.h> @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> + * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under diff --git a/connection.c b/connection.c index f3994b1f7ea..f2b85bab924 100644 --- a/connection.c +++ b/connection.c @@ -1,8 +1,8 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - * Copyright (C) 2013 Linux Foundation * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> + * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the @@ -10,8 +10,6 @@ * your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/module.h> #include <linux/device.h> #include <linux/idr.h> diff --git a/connection.h b/connection.h index f8ac5e1f071..da73741d5ba 100644 --- a/connection.h +++ b/connection.h @@ -1,8 +1,8 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - * Copyright (C) 2013 Linux Foundation * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> + * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the diff --git a/endpoint.c b/endpoint.c index cc7dc99a9ac..1b7681343b3 100644 --- a/endpoint.c +++ b/endpoint.c @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> + * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under @@ -9,8 +10,6 @@ * your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/module.h> #include <linux/device.h> #include <linux/idr.h> @@ -43,6 +42,11 @@ static char *kdbus_devnode_ep(struct device *dev, umode_t *mode, return NULL; } +static void kdbus_dev_release(struct device *dev) +{ + kfree(dev); +} + static struct device_type kdbus_devtype_ep = { .name = "ep", .release = kdbus_dev_release, diff --git a/endpoint.h b/endpoint.h index c4179e262f1..0201f509cd1 100644 --- a/endpoint.h +++ b/endpoint.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> + * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under @@ -1,8 +1,8 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - * Copyright (C) 2013 Linux Foundation * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> + * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the @@ -10,8 +10,6 @@ * your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/module.h> #include <linux/device.h> #include <linux/idr.h> diff --git a/handle.h b/handle.h new file mode 100644 index 00000000000..0eb409e5064 --- /dev/null +++ b/handle.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2013 Kay Sievers + * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> + * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> + * Copyright (C) 2013 Linux Foundation + * + * kdbus is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, or (at + * your option) any later version. + */ + +#ifndef __KDBUS_HANDLE_H +#define __KDBUS_HANDLE_H + +extern const struct file_operations kdbus_device_ops; +#endif diff --git a/internal.h b/internal.h index 490e1b68384..1fd439263ec 100644 --- a/internal.h +++ b/internal.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> + * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under @@ -12,9 +13,9 @@ #ifndef __KDBUS_INTERNAL_H #define __KDBUS_INTERNAL_H -//#include <uapi/kdbus/kdbus.h> #include "kdbus.h" +/* limits enforced by the interfaces */ #define KDBUS_MSG_MAX_SIZE SZ_8K /* maximum size of message header and items */ #define KDBUS_MSG_MAX_ITEMS 128 /* maximum number of message items */ #define KDBUS_MSG_MAX_FDS 256 /* maximum number of passed file descriptors */ @@ -33,13 +34,14 @@ #define KDBUS_CONN_MAX_NAMES 64 /* maximum number of well-known names */ #define KDBUS_CONN_MAX_ALLOCATED_BYTES SZ_64K /* maximum number of allocated bytes on the bus */ -/* exported addresses are 64bit */ +/* all exported addresses are 64 bit */ #define KDBUS_PTR(addr) ((void __user *)(uintptr_t)(addr)) -/* exported sizes are 64bit and data aligned to 64 bit */ +/* all exported sizes are 64 bit and data aligned to 64 bit */ #define KDBUS_ALIGN8(s) ALIGN((s), 8) #define KDBUS_IS_ALIGNED8(s) (IS_ALIGNED(s, 8)) +/* generic access and iterators over a stream of items/parts */ #define KDBUS_PART_HEADER_SIZE sizeof(KDBUS_PART_HEADER) #define KDBUS_PART_SIZE(s) KDBUS_ALIGN8(KDBUS_PART_HEADER_SIZE + (s)) #define KDBUS_PART_NEXT(part) \ @@ -56,34 +58,57 @@ #define KDBUS_MSG_HEADER_SIZE offsetof(struct kdbus_msg, items) -/* read 64bit .size in struct */ +/** + * kdbus_size_get_user - read the size variable from user memory + * @_s: Size variable + * @_b: Buffer to read from + * @_t: Structure "size" is embedded in + * + * Returns: the result of copy_from_user() + */ #define kdbus_size_get_user(_s, _b, _t) \ ({ \ u64 __user *_sz = (void __user *)(_b) + offsetof(typeof(_t), size); \ copy_from_user(_s, _sz, sizeof(__u64)); \ }) -/* set 64bit .offset in struct */ +/** + * kdbus_offset_set_user - write the offset variable to user memory + * @_s: Offset variable + * @_b: Buffer to write to + * @_t: Structure "offset" is embedded in + * + * Returns: the result of copy_to_user() + */ #define kdbus_offset_set_user(_s, _b, _t) \ ({ \ u64 __user *_sz = (void __user *)(_b) + offsetof(typeof(_t), offset); \ copy_to_user(_sz, _s, sizeof(__u64)); \ }) +/** + * kdbus_validate_nul - check the validity of a sized string + * @s: String + * @l: Length of string + * + * Validate that a given string matches the given size, and the + * string is \0 terminated. + * + * Returns: true if the given string is valid + */ static inline bool kdbus_validate_nul(const char *s, size_t l) { return l > 0 && memchr(s, '\0', l) == s + l - 1; } +/** + * kdbus_str_hash - calculate a hash + * @str: String + * + * Returns: hash value + */ static inline unsigned int kdbus_str_hash(const char *str) { return full_name_hash(str, strlen(str)); } - -extern const struct file_operations kdbus_device_ops; -extern struct bus_type kdbus_subsys; -void kdbus_dev_release(struct device *dev); -extern struct mutex kdbus_subsys_lock; -extern struct idr kdbus_ns_major_idr; -extern struct kdbus_ns *kdbus_ns_init; #endif @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> + * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under @@ -9,8 +10,6 @@ * your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/module.h> #include <linux/device.h> #include <linux/idr.h> @@ -25,22 +24,6 @@ #include "internal.h" #include "namespace.h" -/* kdbus sysfs subsystem */ -struct bus_type kdbus_subsys = { - .name = "kdbus", -}; - -/* kdbus initial namespace */ -struct kdbus_ns *kdbus_ns_init; - -/* map of majors to namespaces */ -DEFINE_IDR(kdbus_ns_major_idr); - -void kdbus_dev_release(struct device *dev) -{ - kfree(dev); -} - static int __init kdbus_init(void) { int ret; @@ -60,7 +43,7 @@ static int __init kdbus_init(void) return ret; } - pr_info("initialized\n"); + pr_info("kdbus initialized\n"); return 0; } @@ -10,8 +10,6 @@ * your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/fs.h> #include <linux/slab.h> #include <linux/sched.h> @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> + * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under @@ -1,8 +1,8 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - * Copyright (C) 2013 Linux Foundation * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> + * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the @@ -10,8 +10,6 @@ * your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/module.h> #include <linux/slab.h> #include <linux/sizes.h> @@ -1,8 +1,8 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - * Copyright (C) 2013 Linux Foundation * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> + * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the diff --git a/message.c b/message.c index 61b059e50e9..bb21341e1f6 100644 --- a/message.c +++ b/message.c @@ -10,8 +10,6 @@ * your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/module.h> #include <linux/device.h> #include <linux/idr.h> diff --git a/message.h b/message.h index 0df82400e35..8f5916f3217 100644 --- a/message.h +++ b/message.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> + * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under diff --git a/metadata.c b/metadata.c index 55b86a6eb1a..3ef3a651cca 100644 --- a/metadata.c +++ b/metadata.c @@ -10,8 +10,6 @@ * your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/slab.h> #include <linux/file.h> #include <linux/sched.h> diff --git a/metadata.h b/metadata.h index e464f01e2d7..610b4fd12bd 100644 --- a/metadata.h +++ b/metadata.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> + * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under @@ -10,8 +10,6 @@ * your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/module.h> #include <linux/device.h> #include <linux/idr.h> @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> + * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under diff --git a/namespace.c b/namespace.c index a2c508249e0..d4baf438379 100644 --- a/namespace.c +++ b/namespace.c @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> + * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under @@ -9,8 +10,6 @@ * your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/module.h> #include <linux/device.h> #include <linux/idr.h> @@ -22,18 +21,30 @@ #include <linux/sizes.h> #include <uapi/linux/major.h> +#include "handle.h" #include "namespace.h" #include "bus.h" /* global list of all namespaces */ static LIST_HEAD(namespace_list); -/* namespace list lock */ -DEFINE_MUTEX(kdbus_subsys_lock); +/* map of majors to namespaces */ +static DEFINE_IDR(kdbus_ns_major_idr); /* next namespace id sequence number */ static u64 kdbus_ns_id_next; +/* kdbus initial namespace */ +struct kdbus_ns *kdbus_ns_init; + +/* kdbus subsystem lock */ +static DEFINE_MUTEX(kdbus_subsys_lock); + +/* kdbus sysfs subsystem */ +struct bus_type kdbus_subsys = { + .name = "kdbus", +}; + /* control nodes are world accessible */ static char *kdbus_devnode_control(struct device *dev, umode_t *mode, kuid_t *uid, kgid_t *gid) @@ -46,6 +57,11 @@ static char *kdbus_devnode_control(struct device *dev, umode_t *mode, return NULL; } +static void kdbus_dev_release(struct device *dev) +{ + kfree(dev); +} + static struct device_type kdbus_devtype_control = { .name = "control", .release = kdbus_dev_release, diff --git a/namespace.h b/namespace.h index 191a8dc8918..e4332b9e824 100644 --- a/namespace.h +++ b/namespace.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> + * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under @@ -58,6 +59,9 @@ struct kdbus_ns { struct list_head bus_list; }; +extern struct kdbus_ns *kdbus_ns_init; +extern struct bus_type kdbus_subsys; + struct kdbus_ns *kdbus_ns_ref(struct kdbus_ns *ns); void kdbus_ns_unref(struct kdbus_ns *ns); void kdbus_ns_disconnect(struct kdbus_ns *ns); @@ -10,8 +10,6 @@ * your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/module.h> #include <linux/device.h> #include <linux/idr.h> @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> + * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under @@ -10,8 +10,6 @@ * your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/module.h> #include <linux/device.h> #include <linux/idr.h> @@ -1,6 +1,7 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> + * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under @@ -1,8 +1,8 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - * Copyright (C) 2013 Linux Foundation * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> + * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the @@ -10,8 +10,6 @@ * your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include <linux/module.h> #include <linux/fs.h> #include <linux/slab.h> @@ -1,8 +1,8 @@ /* * Copyright (C) 2013 Kay Sievers * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - * Copyright (C) 2013 Linux Foundation * Copyright (C) 2013 Daniel Mack <daniel@zonque.org> + * Copyright (C) 2013 Linux Foundation * * kdbus is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the |