aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/cred.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/cred.h')
-rw-r--r--include/linux/cred.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/linux/cred.h b/include/linux/cred.h
index 3e65587a72e5..a7a686074cb0 100644
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -158,4 +158,33 @@ do { \
158 *(_gid) = current->cred->fsgid; \ 158 *(_gid) = current->cred->fsgid; \
159} while(0) 159} while(0)
160 160
161extern void __put_cred(struct cred *);
162extern int copy_creds(struct task_struct *, unsigned long);
163
164/**
165 * get_cred - Get a reference on a set of credentials
166 * @cred: The credentials to reference
167 *
168 * Get a reference on the specified set of credentials. The caller must
169 * release the reference.
170 */
171static inline struct cred *get_cred(struct cred *cred)
172{
173 atomic_inc(&cred->usage);
174 return cred;
175}
176
177/**
178 * put_cred - Release a reference to a set of credentials
179 * @cred: The credentials to release
180 *
181 * Release a reference to a set of credentials, deleting them when the last ref
182 * is released.
183 */
184static inline void put_cred(struct cred *cred)
185{
186 if (atomic_dec_and_test(&(cred)->usage))
187 __put_cred(cred);
188}
189
161#endif /* _LINUX_CRED_H */ 190#endif /* _LINUX_CRED_H */