/* * Copyright (C) 2013-2014 Kay Sievers * Copyright (C) 2013-2014 Greg Kroah-Hartman * Copyright (C) 2013-2014 Daniel Mack * Copyright (C) 2013-2014 David Herrmann * Copyright (C) 2013-2014 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_BUS_H #define __KDBUS_BUS_H #include #include #include #include #include "policy.h" #include "util.h" /** * struct kdbus_bus - bus in a domain * @kref: Reference count * @disconnected: Invalidated data * @uid_owner: The uid of the owner of the bus * @domain: Domain of this bus * @name: The bus name * @id: ID of this bus in the domain * @lock: Bus data lock * @ep: Default "bus" endpoint * @ep_seq_last: Last used endpoint id sequence number * @conn_seq_last: Last used connection id sequence number * @ep_list: Endpoints on this bus * @bus_flags: Simple pass-through flags from userspace to userspace * @name_registry: Name registry of this bus * @domain_entry: Entry in domain * @bloom: Bloom parameters * @id128: Unique random 128 bit ID of this bus * @user: Owner of the bus * @policy_db: Policy database for this bus * @notify_list: List of pending kernel-generated messages * @notify_lock: Notification list lock * @notify_flush_lock: Notification flushing lock * @conn_rwlock: Read/Write lock for all lists of child connections * @conn_hash: Map of connection IDs * @monitors_list: Connections that monitor this bus * @meta: Meta information about the bus creator * * A bus provides a "bus" endpoint / device node. * * A bus is created by opening the control node and issuing the * KDBUS_CMD_BUS_MAKE iotcl. Closing this file immediately destroys * the bus. */ struct kdbus_bus { struct kref kref; bool disconnected; kuid_t uid_owner; struct kdbus_domain *domain; const char *name; u64 id; struct mutex lock; struct kdbus_ep *ep; u64 ep_seq_last; atomic64_t conn_seq_last; struct list_head ep_list; u64 bus_flags; struct kdbus_name_registry *name_registry; struct list_head domain_entry; struct kdbus_bloom_parameter bloom; u8 id128[16]; struct kdbus_domain_user *user; struct kdbus_policy_db policy_db; struct list_head notify_list; spinlock_t notify_lock; struct mutex notify_flush_lock; struct rw_semaphore conn_rwlock; DECLARE_HASHTABLE(conn_hash, 8); struct list_head monitors_list; struct kdbus_meta *meta; }; int kdbus_bus_make_user(const struct kdbus_cmd_make *make, char **name, struct kdbus_bloom_parameter *bloom); struct kdbus_bus *kdbus_bus_new(struct kdbus_domain *domain, const struct kdbus_cmd_make *make, const char *name, const struct kdbus_bloom_parameter *bloom, umode_t mode, kuid_t uid, kgid_t gid); int kdbus_cmd_bus_creator_info(struct kdbus_conn *conn, struct kdbus_cmd_info *cmd_info); struct kdbus_bus *kdbus_bus_ref(struct kdbus_bus *bus); struct kdbus_bus *kdbus_bus_unref(struct kdbus_bus *bus); void kdbus_bus_disconnect(struct kdbus_bus *bus); bool kdbus_bus_cred_is_privileged(const struct kdbus_bus *bus, const struct cred *cred); bool kdbus_bus_uid_is_privileged(const struct kdbus_bus *bus); struct kdbus_conn *kdbus_bus_find_conn_by_id(struct kdbus_bus *bus, u64 id); #endif