2 * Copyright (C) 2013-2015 Kay Sievers
3 * Copyright (C) 2013-2015 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 * Copyright (C) 2013-2015 Daniel Mack <daniel@zonque.org>
5 * Copyright (C) 2013-2015 David Herrmann <dh.herrmann@gmail.com>
6 * Copyright (C) 2013-2015 Linux Foundation
7 * Copyright (C) 2014-2015 Djalal Harouni <tixxdz@opendz.org>
9 * kdbus is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU Lesser General Public License as published by the
11 * Free Software Foundation; either version 2.1 of the License, or (at
12 * your option) any later version.
15 #ifndef __KDBUS_DOMAIN_H
16 #define __KDBUS_DOMAIN_H
19 #include <linux/idr.h>
20 #include <linux/kref.h>
21 #include <linux/user_namespace.h>
26 * struct kdbus_domain - domain for buses
27 * @node: Underlying API node
28 * @lock: Domain data lock
29 * @last_id: Last used object id
30 * @user_idr: Set of all users indexed by UID
31 * @user_ida: Set of all users to compute small indices
32 * @user_namespace: User namespace, pinned at creation time
33 * @dentry: Root dentry of VFS mount (don't use outside of kdbusfs)
36 struct kdbus_node node;
41 struct user_namespace *user_namespace;
42 struct dentry *dentry;
46 * struct kdbus_user - resource accounting for users
47 * @kref: Reference counter
48 * @domain: Domain of the user
49 * @id: Index of this user
50 * @uid: UID of the user
51 * @buses: Number of buses the user has created
52 * @connections: Number of connections the user has created
56 struct kdbus_domain *domain;
63 #define kdbus_domain_from_node(_node) \
64 container_of((_node), struct kdbus_domain, node)
66 struct kdbus_domain *kdbus_domain_new(unsigned int access);
67 struct kdbus_domain *kdbus_domain_ref(struct kdbus_domain *domain);
68 struct kdbus_domain *kdbus_domain_unref(struct kdbus_domain *domain);
69 int kdbus_domain_populate(struct kdbus_domain *domain, unsigned int access);
71 #define KDBUS_USER_KERNEL_ID 0 /* ID 0 is reserved for kernel accounting */
73 struct kdbus_user *kdbus_user_lookup(struct kdbus_domain *domain, kuid_t uid);
74 struct kdbus_user *kdbus_user_ref(struct kdbus_user *u);
75 struct kdbus_user *kdbus_user_unref(struct kdbus_user *u);