From 358f2a23079f940e9adb741d2526895d620d1ced Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 17 Feb 2011 11:57:53 -0600 Subject: [PATCH] LINUX: Include key-related headers in osi_compat.h Include keyring-related headers in osi_compat.h, so we get the proper types defined for keyring-related functions. Also only define keyring-related functions if we have keyring support. Change-Id: Ie7d748f1426ce883c61ae8f30dbce1f0a1bf6bab Reviewed-on: http://gerrit.openafs.org/3895 Reviewed-by: Marc Dionne Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/LINUX/osi_compat.h | 41 +++++++++++++++++++++++++++----------- src/afs/LINUX/osi_groups.c | 14 ------------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h index 0b0ffe87a..cee3ade6f 100644 --- a/src/afs/LINUX/osi_compat.h +++ b/src/afs/LINUX/osi_compat.h @@ -13,6 +13,20 @@ # include #endif +#if defined(LINUX_KEYRING_SUPPORT) +# include +# include +# if defined(HAVE_LINUX_KEY_TYPE_H) +# include +# endif +# ifndef KEY_ALLOC_IN_QUOTA +/* Before these flags were added in Linux commit v2.6.18-rc1~816, + * key_alloc just took a boolean not_in_quota */ +# define KEY_ALLOC_IN_QUOTA 0 +# define KEY_ALLOC_NOT_IN_QUOTA 1 +# endif +#endif + #ifndef HAVE_LINUX_DO_SYNC_READ static inline int do_sync_read(struct file *fp, char *buf, size_t count, loff_t *offp) { @@ -147,20 +161,21 @@ init_once_func(void * foo) { #define KALLOC_TYPE GFP_KERNEL #endif +#ifdef LINUX_KEYRING_SUPPORT static inline struct key * afs_linux_key_alloc(struct key_type *type, const char *desc, uid_t uid, gid_t gid, key_perm_t perm, unsigned long flags) { -#if defined(KEY_ALLOC_NEEDS_STRUCT_TASK) +# if defined(KEY_ALLOC_NEEDS_STRUCT_TASK) return key_alloc(type, desc, uid, gid, current, perm, flags); -#elif defined(KEY_ALLOC_NEEDS_CRED) +# elif defined(KEY_ALLOC_NEEDS_CRED) return key_alloc(type, desc, uid, gid, current_cred(), perm, flags); -#else +# else return key_alloc(type, desc, uid, gid, perm, flags); -#endif +# endif } -#if defined(STRUCT_TASK_STRUCT_HAS_CRED) +# if defined(STRUCT_TASK_STRUCT_HAS_CRED) static inline struct key* afs_linux_search_keyring(afs_ucred_t *cred, struct key_type *type) { @@ -178,20 +193,22 @@ afs_linux_search_keyring(afs_ucred_t *cred, struct key_type *type) return ERR_PTR(-ENOKEY); } +# else +static inline struct key* +afs_linux_search_keyring(afs_ucred_t *cred, struct key_type *type) +{ + return request_key(type, "_pag", NULL); +} +# endif /* STRUCT_TASK_STRUCT_HAS_CRED */ +#endif /* LINUX_KEYRING_SUPPORT */ +#ifdef STRUCT_TASK_STRUCT_HAS_CRED static inline int afs_linux_cred_is_current(afs_ucred_t *cred) { return (cred == current_cred()); } - #else -static inline struct key* -afs_linux_search_keyring(afs_ucred_t *cred, struct key_type *type) -{ - return request_key(type, "_pag", NULL); -} - static inline int afs_linux_cred_is_current(afs_ucred_t *cred) { diff --git a/src/afs/LINUX/osi_groups.c b/src/afs/LINUX/osi_groups.c index 9b97103e7..943c6b651 100644 --- a/src/afs/LINUX/osi_groups.c +++ b/src/afs/LINUX/osi_groups.c @@ -28,20 +28,6 @@ #include -#if defined(LINUX_KEYRING_SUPPORT) -# include -# include -# if defined(HAVE_LINUX_KEY_TYPE_H) -# include -# endif -# ifndef KEY_ALLOC_IN_QUOTA -/* Before these flags were added in Linux commit v2.6.18-rc1~816, - * key_alloc just took a boolean not_in_quota */ -# define KEY_ALLOC_IN_QUOTA 0 -# define KEY_ALLOC_NOT_IN_QUOTA 1 -# endif -#endif - #ifdef AFS_LINUX26_ONEGROUP_ENV # define NUMPAGGROUPS 1 -- 2.39.5