diff options
author | Djalal Harouni <tixxdz@opendz.org> | 2014-07-30 21:11:54 +0100 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2014-07-31 16:29:54 +0200 |
commit | 4ff47b39b30671ccca96cef951a2af12a02cb7df (patch) | |
tree | 976cb558842aa51d9741dfef0e8ff9406e2e598d /domain.c | |
parent | 9a1bd42e36046e289d4c16350a15e1e2ea34e299 (diff) | |
download | kdbus-bus-4ff47b39b30671ccca96cef951a2af12a02cb7df.tar.gz kdbus-bus-4ff47b39b30671ccca96cef951a2af12a02cb7df.tar.bz2 kdbus-bus-4ff47b39b30671ccca96cef951a2af12a02cb7df.zip |
domain: add kdbus_domain_user_account()
Add kdbus_domain_user_account() to account and link users into a
domain.
This function will take the domain lock, and it will be used as a
replacement for kdbus_domain_user_find_or_new().
Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
Diffstat (limited to 'domain.c')
-rw-r--r-- | domain.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -522,6 +522,42 @@ exit_free: } /** + * kdbus_domain_user_account() - account a kdbus_domain_user object + * into the specified domain + * @domain: The domain of the user + * @uid: The uid of the user; INVALID_UID for an + * anonymous user like a custom endpoint + * @user Pointer to a reference where the accounted + * domain user will be stored. + * + * Return: 0 on success, negative errno on failure. + * + * On success: if there is a uid matching, then use the already + * accounted kdbus_domain_user, increment its reference counter and + * return it in the 'user' argument. Otherwise, allocate a new one, + * link it into the domain, then return it. + * + * On failure: the 'user' argument is not updated. + * + * This function will first check if the domain was not disconnected. + */ +int kdbus_domain_user_account(struct kdbus_domain *domain, + kuid_t uid, + struct kdbus_domain_user **user) +{ + int ret = -ESHUTDOWN; + + mutex_lock(&domain->lock); + + if (!domain->disconnected) + ret = __kdbus_domain_user_account(domain, uid, user); + + mutex_unlock(&domain->lock); + + return ret; +} + +/** * kdbus_domain_user_find_or_new() - get a kdbus_domain_user object in a domain * @domain: The domain * @uid: The uid of the user; INVALID_UID for an anonymous |