kdbus: the driver, original and non-working
[platform/kernel/linux-exynos.git] / ipc / kdbus / policy.h
1 /*
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  *
8  * kdbus is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU Lesser General Public License as published by the
10  * Free Software Foundation; either version 2.1 of the License, or (at
11  * your option) any later version.
12  */
13
14 #ifndef __KDBUS_POLICY_H
15 #define __KDBUS_POLICY_H
16
17 #include <linux/hashtable.h>
18 #include <linux/rwsem.h>
19
20 struct kdbus_conn;
21 struct kdbus_item;
22
23 /**
24  * struct kdbus_policy_db - policy database
25  * @entries_hash:       Hashtable of entries
26  * @entries_rwlock:     Mutex to protect the database's access entries
27  */
28 struct kdbus_policy_db {
29         DECLARE_HASHTABLE(entries_hash, 6);
30         struct rw_semaphore entries_rwlock;
31 };
32
33 void kdbus_policy_db_init(struct kdbus_policy_db *db);
34 void kdbus_policy_db_clear(struct kdbus_policy_db *db);
35
36 int kdbus_policy_query_unlocked(struct kdbus_policy_db *db,
37                                 const struct cred *cred, const char *name,
38                                 unsigned int hash);
39 int kdbus_policy_query(struct kdbus_policy_db *db, const struct cred *cred,
40                        const char *name, unsigned int hash);
41
42 void kdbus_policy_remove_owner(struct kdbus_policy_db *db,
43                                const void *owner);
44 int kdbus_policy_set(struct kdbus_policy_db *db,
45                      const struct kdbus_item *items,
46                      size_t items_size,
47                      size_t max_policies,
48                      bool allow_wildcards,
49                      const void *owner);
50
51 #endif