}
#endif
+#if defined(HAVE_KMEM_CACHE_T)
+#define afs_kmem_cache_t kmem_cache_t
+#else
+#define afs_kmem_cache_t struct kmem_cache
+#endif
+
+extern void init_once(void *);
+#if defined(HAVE_KMEM_CACHE_T)
+static inline void
+init_once_func(void * foo, kmem_cache_t * cachep, unsigned long flags) {
+#if defined(SLAB_CTOR_VERIFY)
+ if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
+ SLAB_CTOR_CONSTRUCTOR)
+#endif
+ init_once(foo);
+}
+#elif defined(KMEM_CACHE_INIT)
+static inline void
+init_once_func(struct kmem_cache * cachep, void * foo) {
+ init_once(foo);
+}
+#elif !defined(KMEM_CACHE_CTOR_TAKES_VOID)
+static inline void
+init_once_func(void * foo, struct kmem_cache * cachep, unsigned long flags) {
+#if defined(SLAB_CTOR_VERIFY)
+ if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
+ SLAB_CTOR_CONSTRUCTOR)
+#endif
+ init_once(foo);
+}
+#else
+static inline void
+init_once_func(void * foo) {
+ init_once(foo);
+}
+#endif
+
+#ifndef SLAB_RECLAIM_ACCOUNT
+#define SLAB_RECLAIM_ACCOUNT 0
+#endif
+
+#if defined(SLAB_KERNEL)
+#define KALLOC_TYPE SLAB_KERNEL
+#else
+#define KALLOC_TYPE GFP_KERNEL
+#endif
+
+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)
+ return key_alloc(type, desc, uid, gid, current, perm, flags);
+#elif defined(KEY_ALLOC_NEEDS_CRED)
+ return key_alloc(type, desc, uid, gid, current_cred(), perm, flags);
+#else
+ return key_alloc(type, desc, uid, gid, perm, flags);
+#endif
+}
+
+#if defined(STRUCT_TASK_HAS_CRED)
+static inline struct key*
+afs_linux_search_keyring(afs_ucred_t *cred, struct key_type *type)
+{
+ key_ref_t key_ref;
+
+ if (cred->tgcred->session_keyring) {
+ key_ref = keyring_search(
+ make_key_ref(cred->tgcred->session_keyring, 1),
+ type, "_pag");
+ if (IS_ERR(key_ref))
+ return ERR_CAST(key_ref);
+
+ return key_ref_to_ptr(key_ref);
+ }
+
+ return ERR_PTR(-ENOKEY);
+}
+
+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, cred)
+{
+ return 1;
+}
+#endif
+
#endif