summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bus.c4
-rw-r--r--bus.h1
-rw-r--r--connection.c4
-rw-r--r--connection.h2
-rw-r--r--endpoint.c8
-rw-r--r--endpoint.h1
-rw-r--r--handle.c4
-rw-r--r--handle.h17
-rw-r--r--internal.h49
-rw-r--r--main.c21
-rw-r--r--match.c2
-rw-r--r--match.h1
-rw-r--r--memfd.c4
-rw-r--r--memfd.h2
-rw-r--r--message.c2
-rw-r--r--message.h1
-rw-r--r--metadata.c2
-rw-r--r--metadata.h1
-rw-r--r--names.c2
-rw-r--r--names.h1
-rw-r--r--namespace.c24
-rw-r--r--namespace.h4
-rw-r--r--notify.c2
-rw-r--r--notify.h1
-rw-r--r--policy.c2
-rw-r--r--policy.h1
-rw-r--r--pool.c4
-rw-r--r--pool.h2
28 files changed, 102 insertions, 67 deletions
diff --git a/bus.c b/bus.c
index 58035a90366..c58b2834da1 100644
--- a/bus.c
+++ b/bus.c
@@ -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>
diff --git a/bus.h b/bus.h
index 0ad2df6f603..103032fd185 100644
--- a/bus.h
+++ b/bus.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
diff --git a/handle.c b/handle.c
index e0de0c87214..97592e6ed54 100644
--- a/handle.c
+++ b/handle.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/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
diff --git a/main.c b/main.c
index 4f27caf0c24..7e9ed4641e9 100644
--- a/main.c
+++ b/main.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>
@@ -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;
}
diff --git a/match.c b/match.c
index d653b39219b..362703340f4 100644
--- a/match.c
+++ b/match.c
@@ -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>
diff --git a/match.h b/match.h
index 1ff23111965..47a4c678bcf 100644
--- a/match.h
+++ b/match.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/memfd.c b/memfd.c
index ec4494a5ab7..5351219baa7 100644
--- a/memfd.c
+++ b/memfd.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/slab.h>
#include <linux/sizes.h>
diff --git a/memfd.h b/memfd.h
index 92929dc5d0d..7fc327a5dc3 100644
--- a/memfd.h
+++ b/memfd.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
diff --git a/names.c b/names.c
index 0e34b283af4..14767ae4eed 100644
--- a/names.c
+++ b/names.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/names.h b/names.h
index 7ddab54a69b..7590c844345 100644
--- a/names.h
+++ b/names.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);
diff --git a/notify.c b/notify.c
index 233bc726f4f..eaa8fd23732 100644
--- a/notify.c
+++ b/notify.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/notify.h b/notify.h
index 36305fc18a2..82ceffae91a 100644
--- a/notify.h
+++ b/notify.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/policy.c b/policy.c
index b83a25a310e..abef86e13d4 100644
--- a/policy.c
+++ b/policy.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/policy.h b/policy.h
index 0bfc5817c7b..627b95b1007 100644
--- a/policy.h
+++ b/policy.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/pool.c b/pool.c
index 99abefa0054..f0aa6fdcd82 100644
--- a/pool.c
+++ b/pool.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/fs.h>
#include <linux/slab.h>
diff --git a/pool.h b/pool.h
index a6d116e7769..f32df7a73bc 100644
--- a/pool.h
+++ b/pool.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