summaryrefslogtreecommitdiffstats
path: root/truecrypt/build/truecrypt-4.2a-Dm-target.c--kernel-2.6.18-and-2.6.19.patch
blob: f88a79abe7ab0cee70e6b9a326567737dc88b9f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
--- truecrypt-4.2a/Linux/Kernel/Dm-target.c	2006-12-11 17:50:46.000000000 +0200
+++ truecrypt-4.2a.new/Linux/Kernel/Dm-target.c	2006-12-10 19:32:43.000000000 +0200
@@ -22,6 +22,35 @@
 #include "Tests.h"
 #include "Dm-target.h"
 
+/* http://kernel.org/pub/linux/kernel/v2.6/testing/ChangeLog-2.6.17-rc1
+ *
+ * commit 4ee218cd67b385759993a6c840ea45f0ee0a8b30
+ * Author: Andrew Morton <akpm@osdl.org>
+ * Date: Mon Mar 27 01:17:48 2006 -0800
+ *
+ * [PATCH] dm: remove SECTOR_FORMAT
+ *
+ * We don't know what type sector_t has. Sometimes it's unsigned long, sometimes
+ * it's unsigned long long. For example on ppc64 it's unsigned long with
+ * CONFIG_LBD=n and on x86_64 it's unsigned long long with CONFIG_LBD=n.
+ *
+ * The way to handle all of this is to always use unsigned long long and to
+ * always typecast the sector_t when printing it.
+ *
+ * Acked-by: Alasdair G Kergon <agk@redhat.com>
+ * Signed-off-by: Andrew Morton <akpm@osdl.org>
+ * Signed-off-by: Linus Torvalds <torvalds@osdl.org>
+ *
+ */
+
+#ifndef SECTOR_FORMAT
+#   ifndef CONFIG_LBD /* Large Block Device defined*/
+#     define SECTOR_FORMAT "%lu" /* No 32Bit uint */
+#   else
+#     define SECTOR_FORMAT "%llu" /* Yes 64Bit uint */
+#   endif
+#endif
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,5)
 #error Linux kernel 2.6.5 or later required
 #endif
@@ -29,6 +58,11 @@
 int trace_level = 0;
 
 #define MSG_PREFIX "truecrypt: "
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
+#  define DM_MSG_PREFIX MSG_PREFIX
+#endif
+
 #define error(fmt, args...) printk(KERN_ERR MSG_PREFIX fmt, ## args)
 #define trace(level, fmt, args...) level <= trace_level && printk(KERN_DEBUG MSG_PREFIX fmt, ## args)
 #define dbg(fmt, args...) printk(KERN_DEBUG MSG_PREFIX fmt, ## args)
@@ -125,7 +159,11 @@
 			return p;
 
 		trace (3, "blk_congestion_wait\n");
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
+		congestion_wait (direction, HZ / 50);
+#else
 		blk_congestion_wait (direction, HZ / 50);
+#endif
 	}
 }
 
@@ -497,7 +535,11 @@
 	while (!(bion = bio_alloc (GFP_NOIO | __GFP_NOMEMALLOC, bio_segments (bio))))
 	{
 		trace (3, "blk_congestion_wait\n");
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
+		congestion_wait (bio_data_dir (bio), HZ / 50);
+#else
 		blk_congestion_wait (bio_data_dir (bio), HZ / 50);
+#endif
 	}
 
 	bion->bi_bdev = tc->dev->bdev;
@@ -699,6 +741,12 @@
 module_param_named(trace, trace_level, int, 0);
 
 MODULE_AUTHOR("TrueCrypt Foundation");
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
+MODULE_DESCRIPTION(DM_MSG_PREFIX " target for encryption and decryption of TrueCrypt volumes");
+#else
 MODULE_DESCRIPTION(DM_NAME " target for encryption and decryption of TrueCrypt volumes");
+#endif
+
 MODULE_PARM_DESC(trace, "Trace level");
 MODULE_LICENSE("GPL and additional rights"); // Kernel thinks only GPL/BSD/MPL != closed-source code