Patch to build TrueCrypt v4.3a modules on 2.6.23+ kernels

Saturday, December 29th, 2007 at 11:46 pm | 3,568 views | trackback url
Tags:

I run kernels directly from Linus’ git tree on my Thinkpad T42p laptop. As such, things like wireless drivers (madwifi-ng in my case), VMware modules and TrueCrypt require patching of the various bits of code to get it all working.

A lot of people are having trouble building TrueCrypt on 2.6.23, 2.6.24 and later kernels… and nobody has a solution, but there are a lot of people posting on the various Gentoo, Slackware and other forums with the issues.

The errors you’ll see will look like this:

Checking build requirements...
Building kernel module... /src/truecrypt-4.3a-source-code/Linux/Kernel/Dm-target.c: In function ‘dereference_bio_ctx’:
/src/truecrypt-4.3a-source-code/Linux/Kernel/Dm-target.c:378: error: too many arguments to function ‘bio_endio’
/src/truecrypt-4.3a-source-code/Linux/Kernel/Dm-target.c: In function ‘dm_truecrypt_init’:
/src/truecrypt-4.3a-source-code/Linux/Kernel/Dm-target.c:659: error: too many arguments to function ‘kmem_cache_create’
make[2]: *** [/src/truecrypt-4.3a-source-code/Linux/Kernel/Dm-target.o] Error 1
make[1]: *** [_module_/src/truecrypt-4.3a-source-code/Linux/Kernel] Error 2
make: *** [truecrypt] Error 2
Error: Failed to build kernel module

And here’s the patch I just wrote to allow this to build cleanly against 2.6.23 and 2.6.24 kernels:

--- /src/Dm-target.c.orig    2007-04-24 12:32:06.000000000 -0400
+++ Kernel/Dm-target.c  2007-12-29 22:34:21.502087564 -0500
@@ -375,7 +375,7 @@
        if (!atomic_dec_and_test (&bc->ref_count))
                return;
 
-       bio_endio (bc->orig_bio, bc->orig_bio->bi_size, bc->error);
+       bio_endio (bc->orig_bio, bc->error);
        mempool_free (bc, tc->bio_ctx_pool);
 }
 
@@ -656,7 +656,12 @@
                goto err;
        }
 
-       bio_ctx_cache = kmem_cache_create ("truecrypt-bioctx", sizeof (struct bio_ctx), 0, 0, NULL, NULL);
+       #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+               bio_ctx_cache = kmem_cache_create ("truecrypt-bioctx", sizeof (struct bio_ctx), 0, 0, NULL, NULL);
+       #else
+               bio_ctx_cache = kmem_cache_create ("truecrypt-bioctx", sizeof (struct bio_ctx), 0, 0, NULL);
+       #endif
+
        if (!bio_ctx_cache)
        {
                error ("kmem_cache_create failed");

And away you go!

Last Modified: Saturday, December 29th, 2007 @ 23:46

Leave a Reply

You must be logged in to post a comment.

Bad Behavior has blocked 903 access attempts in the last 7 days.