From: Jens Axboe Date: Fri, 8 Oct 2010 12:35:48 +0000 (+0200) Subject: Make slab bits compile on 2.6.18 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=fefac21422fe9a655686427300a55f33a01e9179;p=binject.git Make slab bits compile on 2.6.18 Signed-off-by: Jens Axboe --- diff --git a/kcompat.h b/kcompat.h index 8828652..2e727ea 100644 --- a/kcompat.h +++ b/kcompat.h @@ -52,11 +52,14 @@ static inline ktime_t ktime_get(void) static inline struct kmem_cache * binject_create_slab(const char *name, size_t obj_size, unsigned long flags, +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 26) void (*init_once)(void *)) { -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 26) return kmem_cache_create(name, obj_size, 0, flags, NULL); #else +#define KCOMPAT_OLD_SLAB + void (*init_once)(void *, kmem_cache_t *, unsigned long)) +{ return kmem_cache_create(name, obj_size, 0, flags, init_once, NULL); #endif } diff --git a/main.c b/main.c index 2251523..8984d0a 100644 --- a/main.c +++ b/main.c @@ -708,13 +708,25 @@ static void __exit b_exit(void) misc_deregister(&b_misc_dev); } -static void b_cmd_init_once(void *data) +static void __b_cmd_init_once(struct b_cmd *bc) { - struct b_cmd *bc = data; - INIT_LIST_HEAD(&bc->list); } +#ifdef KCOMPAT_OLD_SLAB +static void b_cmd_init_once(void *data, kmem_cache_t *slab, unsigned long flags) +{ + if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == + SLAB_CTOR_CONSTRUCTOR) + __b_cmd_init_once(data); +} +#else +static void b_cmd_init_once(void *data) +{ + __b_cmd_init_once(data); +} +#endif + static int __init b_init(void) { int ret;