summaryrefslogtreecommitdiff
blob: ae31588e3dfd7fc283e14a48b17c11903475d93c (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
diff -ruN linux-2.6.0-mm2/crypto/Kconfig linux-2.6.0-mm2.new/crypto/Kconfig
--- linux-2.6.0-mm2/crypto/Kconfig	2004-01-01 13:23:42.000000000 +0100
+++ linux-2.6.0-mm2.new/crypto/Kconfig	2004-01-01 13:18:05.000000000 +0100
@@ -151,6 +151,12 @@
 	  
 	  You will most probably want this if using IPSec.
 
+config CRYPTO_UCL
+	tristate "UCL nrv2e compression algorithm"
+	depends on CRYPTO
+	help
+	  UCL nrv2e kernel module used mainly for gcloop.
+
 config CRYPTO_TEST
 	tristate "Testing module"
 	depends on CRYPTO
diff -ruN linux-2.6.0-mm2/crypto/Makefile linux-2.6.0-mm2.new/crypto/Makefile
--- linux-2.6.0-mm2/crypto/Makefile	2004-01-01 13:23:42.000000000 +0100
+++ linux-2.6.0-mm2.new/crypto/Makefile	2004-01-01 13:18:05.000000000 +0100
@@ -1,6 +1,7 @@
 #
 # Cryptographic API
 #
+CFLAGS_ucl_compress.o = -I /usr/include
 
 proc-crypto-$(CONFIG_PROC_FS) = proc.o
 
@@ -22,5 +23,10 @@
 obj-$(CONFIG_CRYPTO_CAST5) += cast5.o
 obj-$(CONFIG_CRYPTO_CAST6) += cast6.o
 obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o
+ucl-objs := ucl_compress.o libucl.a
+obj-${CONFIG_CRYPTO_UCL} += ucl.o
+#dirty
+$(obj)/libucl.a:
+	cp /usr/lib/libucl.a $(obj)/
 
 obj-$(CONFIG_CRYPTO_TEST) += tcrypt.o
diff -ruN linux-2.6.0-mm2/crypto/ucl_compress.c linux-2.6.0-mm2.new/crypto/ucl_compress.c
--- linux-2.6.0-mm2/crypto/ucl_compress.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.0-mm2.new/crypto/ucl_compress.c	2004-01-01 13:18:05.000000000 +0100
@@ -0,0 +1,122 @@
+/* 
+ * Cryptographic API.
+ *
+ * ucl/nrv2e, implemented here primarily for use
+ * by gcloop
+ *
+ * Copyright (c) 2003 James Morris <jmorris@intercode.com.au>
+ * Copyright (c) 2003 Luca Barbato <lu_zero@gentoo.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option) 
+ * any later version.
+ *
+ *
+ * Just an hack to use ucl instead of zlib
+ *
+ */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/crypto.h>
+#include <ucl/ucl.h>
+#include <linux/vmalloc.h>
+#include <linux/interrupt.h>
+#include <linux/mm.h>
+#include <linux/net.h>
+
+/*#define DEFLATE_DEF_LEVEL		Z_DEFAULT_COMPRESSION
+#define DEFLATE_DEF_WINBITS		11
+#define DEFLATE_DEF_MEMLEVEL		MAX_MEM_LEVEL
+*/
+
+
+/*better build the compressor w/out malloc but that is ok for a try*/
+void* malloc(unsigned long size)
+{
+return vmalloc(size);
+}
+
+void free(void *data)
+{
+vfree(data);
+}
+
+
+struct uclcomp_ctx {
+	struct ucl_compress_config_t config;
+	int level;
+};
+
+static inline int uclcomp_gfp(void)
+{
+	return in_softirq() ? GFP_ATOMIC : GFP_KERNEL;
+}
+
+static int uclcomp_init(void *ctx)
+{
+	return ucl_init();
+}
+
+static void uclcomp_exit(void *ctx)
+{
+/*	struct deflate_ctx *dctx = ctx;
+
+	if (dctx->comp_initialized)
+		vfree(dctx->comp_stream.workspace);
+	if (dctx->decomp_initialized)
+		kfree(dctx->decomp_stream.workspace);*/
+}
+
+static int uclcomp_compress(void *ctx, const u8 *src, unsigned int slen,
+	                    u8 *dst, unsigned int *dlen)
+{
+/* FIXME : I should use the ctx to store the configuration data for the 
+ * compressor, now we are just using the default.
+ */
+	int ret = 0;
+	ret =ucl_nrv2e_99_compress (src, slen, dst, dlen,
+					NULL,10,NULL,NULL);
+	return (ret == UCL_E_OK) ? 0 : -EINVAL;
+}
+ 
+static int uclcomp_decompress(void *ctx, const u8 *src, unsigned int slen,
+                              u8 *dst, unsigned int *dlen)
+{
+	
+	int ret = 0;
+	ret = ucl_nrv2e_decompress_8 (src, slen, dst, 
+					(ucl_uintp) dlen, NULL);
+	return (ret == UCL_E_OK) ? 0 : -EINVAL;
+}
+
+static struct crypto_alg alg = {
+	.cra_name		= "ucl",
+	.cra_flags		= CRYPTO_ALG_TYPE_COMPRESS,
+	.cra_ctxsize		= sizeof(struct uclcomp_ctx),
+	.cra_module		= THIS_MODULE,
+	.cra_list		= LIST_HEAD_INIT(alg.cra_list),
+	.cra_u			= { .compress = {
+	.coa_init		= uclcomp_init,
+	.coa_exit		= uclcomp_exit,
+	.coa_compress 		= uclcomp_compress,
+	.coa_decompress  	= uclcomp_decompress } }
+};
+
+static int __init init(void)
+{
+	return crypto_register_alg(&alg);
+}
+
+static void __exit fini(void)
+{
+	crypto_unregister_alg(&alg);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Ucl compression/decompression");
+MODULE_AUTHOR("Luca Barbato <lu_zero@gentoo.org>");
+
Files linux-2.6.0-mm2/drivers/block/.compressloop.c.swp and linux-2.6.0-mm2.new/drivers/block/.compressloop.c.swp differ
diff -ruN linux-2.6.0-mm2/drivers/block/Kconfig linux-2.6.0-mm2.new/drivers/block/Kconfig
--- linux-2.6.0-mm2/drivers/block/Kconfig	2004-01-01 13:23:42.000000000 +0100
+++ linux-2.6.0-mm2.new/drivers/block/Kconfig	2004-01-01 13:18:05.000000000 +0100
@@ -257,6 +257,14 @@
 	  provided by the CryptoAPI as loop transformation. This might be
 	  used as hard disk encryption.
 
+config BLK_DEV_COMPRESSLOOP
+	tristate "Compressloop Support (EXPERIMENTAL)"
+	select CRYPTO
+	depends on BLK_DEV_CRYPTOLOOP && EXPERIMENTAL
+	---help---
+	  Cryptoloop workalike, supports comp cyphers from CryptoAPI
+
+
 config BLK_DEV_NBD
 	tristate "Network block device support"
 	depends on NET
diff -ruN linux-2.6.0-mm2/drivers/block/Makefile linux-2.6.0-mm2.new/drivers/block/Makefile
--- linux-2.6.0-mm2/drivers/block/Makefile	2004-01-01 13:23:42.000000000 +0100
+++ linux-2.6.0-mm2.new/drivers/block/Makefile	2004-01-01 13:18:05.000000000 +0100
@@ -12,6 +12,7 @@
 # NOTE that ll_rw_blk.c must come early in linkage order - it starts the
 # kblockd threads
 #
+#CFLAGS_compressloop.o = -I /usr/include
 
 obj-y	:= elevator.o ll_rw_blk.o ioctl.o genhd.o scsi_ioctl.o
 
@@ -39,3 +40,7 @@
 obj-$(CONFIG_BLK_DEV_UMEM)	+= umem.o
 obj-$(CONFIG_BLK_DEV_NBD)	+= nbd.o
 obj-$(CONFIG_BLK_DEV_CRYPTOLOOP) += cryptoloop.o
+
+#compressloop1-objs := compressloop.o libucl.a
+
+obj-$(CONFIG_BLK_DEV_COMPRESSLOOP) +=compressloop.o
diff -ruN linux-2.6.0-mm2/drivers/block/compressloop.c linux-2.6.0-mm2.new/drivers/block/compressloop.c
--- linux-2.6.0-mm2/drivers/block/compressloop.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.0-mm2.new/drivers/block/compressloop.c	2004-01-01 14:18:56.000000000 +0100
@@ -0,0 +1,400 @@
+/*
+   Linux loop decompression enabling module, based on cryptoloop.c
+
+   Copyright (C)  2002 Herbert Valerio Riedel <hvr@gnu.org>
+   Copyright (C)  2003 Fruhwirth Clemens <clemens@endorphin.org>
+   Copyright (C)  2004 Luca Barbato <lu_zero@gentoo.org>
+
+   This module is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This module is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this module; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/module.h>
+
+#include <linux/init.h>
+#include <linux/string.h>
+#include <linux/crypto.h>
+#include <linux/blkdev.h>
+#include <linux/loop.h>
+#include <asm/semaphore.h>
+#include <asm/uaccess.h>
+#include <linux/cloop.h>
+#include <linux/vmalloc.h>
+#include <linux/slab.h>
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("loop blockdevice transfer function adaptor"
+		"/ CryptoAPI (compressors)");
+MODULE_AUTHOR("Luca Barbato <lu_zero@gentoo.org>");
+
+#define CLOOP_NAME "gcloop"
+
+#define LOOP_IV_SECTOR_BITS 9
+#define LOOP_IV_SECTOR_SIZE (1 << LOOP_IV_SECTOR_BITS)
+
+#ifndef MIN
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+#endif
+
+/* 
+ * The loop-AES way to access file is working, the former I used isn't
+ * anymore - lu*/
+
+static int cloop_file_io(struct file *file, char *buf, int size, loff_t *ppos)
+{
+	mm_segment_t fs;
+	int x, y, z;
+
+	y = 0;
+	do {
+		z = size - y;
+		fs = get_fs();
+		set_fs(get_ds());
+		x = file->f_op->read(file, buf + y, z, ppos);
+		set_fs(fs);
+		if (!x)
+			return 1;
+		
+		if (x < 0) {
+			if ((x == -EAGAIN) || (x == -ENOMEM) || (x == -ERESTART) || (x == -EINTR)) {
+				blk_run_queues();
+				set_current_state(TASK_INTERRUPTIBLE);
+				schedule_timeout(HZ / 2);
+				continue;
+			}
+			return 1;
+		}
+		y += x;
+	} while (y < size);
+	return 0;
+}
+
+
+
+static int
+load_compressed_head(struct loop_device *lo, struct compressloop_data *data)
+{
+	struct file *file = lo->lo_backing_file;
+	char *buf = NULL;
+	int total_offsets = 1, offsets_read ,i;
+	loff_t pos=0;
+	ssize_t bsize = lo->lo_blocksize;
+	int size = sizeof(struct cloop_head);
+	char *fbuf = (char *) &data->head;
+	
+	
+	
+	printk(KERN_INFO "%s: loading compressed headers \n",
+		CLOOP_NAME);
+	
+	buf = kmalloc(bsize,GFP_KERNEL);
+	if(buf == NULL) {
+		printk(KERN_ERR "%s: can't alloc %i bytes \n",
+			CLOOP_NAME,bsize);
+		return -EINVAL;
+	}
+ 	data->buffered_blocknum=-1;
+	
+	/* first load the head */
+
+	if (cloop_file_io(file, fbuf, size, &pos)) {
+		printk(KERN_ERR "%s: I/O Error\n",
+			CLOOP_NAME);
+	}
+		
+	if (ntohl(data->head.block_size) % 512 != 0) {
+		printk(KERN_ERR "%s: bsize %u not multiple of 512\n",
+			CLOOP_NAME, ntohl(data->head.block_size));
+		goto error_release;
+	}
+	
+	total_offsets=ntohl(data->head.num_blocks)+1;
+	data->offsets = kmalloc(sizeof(u_int32_t) * total_offsets, GFP_KERNEL);
+	if (!data->offsets) {
+		printk(KERN_ERR "%s: out of kernel mem for offsets\n",
+			CLOOP_NAME);
+		goto error_release;
+        }
+	
+	data->buffer = kmalloc(ntohl(data->head.block_size), GFP_KERNEL);
+        if (!data->buffer) {
+		printk(KERN_ERR "%s: out of kernel mem for buffer\n",
+			CLOOP_NAME);
+		goto error_release;
+	}
+
+
+	data->compressed_buffer = kmalloc(ntohl(data->head.block_size), GFP_KERNEL);
+        if (!data->compressed_buffer) {
+		printk(KERN_ERR "%s: out of kernel mem for compressed_buffer\n",			CLOOP_NAME);
+		goto error_release;
+	}
+
+	
+	/* then load the offset */
+	
+	for (i = 0, offsets_read = 0; offsets_read < total_offsets; i++) {
+		int toread=MIN(bsize,(total_offsets-offsets_read)*sizeof(uint32_t));
+		if(cloop_file_io(file, buf, bsize, &pos)) {
+			printk(KERN_ERR "%s: can't read the image\n",
+				CLOOP_NAME);
+			return -EINVAL;
+		}
+		
+		memcpy(&data->offsets[offsets_read], buf, toread);
+		offsets_read += toread/sizeof(uint32_t);
+	}
+#ifdef CLOOP_DEBUG
+	for (i=0; i< ntohl(data->head.num_blocks); i++) {
+		printk(KERN_ERR "Block %u pos %u length %u \n", i,ntohl(data->offsets[i]),ntohl(data->offsets[i+1])-ntohl(data->offsets[i]));
+	}
+#endif
+	/*FIXME it needs some more checks*/
+	lo->lo_sizelimit=ntohl(data->head.num_blocks) 
+			 * ntohl(data->head.block_size)/512;
+
+	printk(KERN_ERR "loading complete: total size %llu, %u blocks \n",
+			lo->lo_sizelimit, ntohl(data->head.num_blocks) );
+	
+	init_MUTEX(&data->mutex);
+	kfree(buf);
+	return 0;
+
+error_release:
+	if(buf) kfree(buf);
+	if(data->offsets) kfree(data->offsets);
+	if(data->compressed_buffer) kfree(data->compressed_buffer);
+	if(data->buffer) kfree(data->buffer);
+	printk(KERN_ERR "%s: loading failed\n",
+		CLOOP_NAME);
+	return -EINVAL;
+}
+
+static int
+compressloop_init(struct loop_device *lo, const struct loop_info64 *info)
+{
+	int err = -EINVAL;
+	char cms[LO_NAME_SIZE];			/* cipher-mode string */
+	char *cipher;
+	char *mode;
+	char *cmsp = cms;			/* c-m string pointer */
+	struct compressloop_data *data = NULL;
+	
+	strncpy(cms, info->lo_crypt_name, LO_NAME_SIZE);
+	cms[LO_NAME_SIZE - 1] = 0;
+	cipher = strsep(&cmsp, "-");
+	mode = strsep(&cmsp, "-");
+	
+	printk(KERN_INFO "%s: loading %s cipher, %s mode\n",CLOOP_NAME,
+			cipher,(mode)?mode:"standard");
+	
+	data = kmalloc(sizeof(struct compressloop_data), GFP_KERNEL);
+	if (data == NULL)
+		return -EINVAL;
+	
+	memset (data,0,sizeof(struct compressloop_data));
+	
+	if (mode == NULL || strcmp(mode, "comp") == 0)
+		data->tfm = crypto_alloc_tfm(cipher,0);
+	if (data->tfm == NULL)
+		goto out_free_data;
+
+	err = load_compressed_head(lo,data);
+	
+	if (err !=0)
+		goto out_free_tfm;
+	
+	lo->key_data = data;
+	lo->lo_flags |= LO_FLAGS_READ_ONLY;
+	return 0;
+
+ out_free_tfm:
+	crypto_free_tfm(data->tfm);
+ 
+ out_free_data:
+ 	kfree(data);
+ 	return err;
+}
+
+static int
+compressloop_ioctl(struct loop_device *lo, int cmd, unsigned long arg)
+{
+	return -EINVAL;
+}
+
+static int
+compressloop_release(struct loop_device *lo)
+{
+	struct  compressloop_data *data= (struct compressloop_data *) lo->key_data;
+	
+	if (data != NULL) {
+		if(data->tfm) crypto_free_tfm(data->tfm);
+		if(data->offsets) kfree(data->offsets);
+		if(data->compressed_buffer) kfree(data->compressed_buffer);
+		if(data->buffer) kfree(data->buffer);
+		kfree(data);
+		lo->key_data = NULL;
+		return 0;
+	}
+	printk(KERN_ERR "compressloop_release(): data == NULL?\n");
+	return -EINVAL;
+}
+
+
+
+static inline int 
+load_buffer(loff_t blocknum, struct loop_device *lo)
+{
+	unsigned int buf_done = 0;
+	unsigned long buflen;
+	unsigned int buf_length;
+	loff_t pos;
+	int ret = 0;
+	struct file *file = lo->lo_backing_file;
+	struct compressloop_data *data = (struct compressloop_data *) lo->key_data;
+
+	if( blocknum > ntohl(data->head.num_blocks) || blocknum < 0) {
+		printk(KERN_WARNING "%s: Invalid block number %llu requested.\n",
+			CLOOP_NAME, blocknum);
+	 	data->buffered_blocknum = -1;
+	 	return 0;
+  	}
+	
+	if (blocknum == data->buffered_blocknum ) return 1;
+
+	/* Get the compressed blocksize*/
+	buf_length = ntohl(data->offsets[blocknum+1])
+			- ntohl(data->offsets[blocknum]);
+	/* Get the uncompressed blocksize*/
+	buflen = ntohl(data->head.block_size);
+
+	pos = ntohl(data->offsets[blocknum]);
+#ifdef GCLOOP_DEBUG
+	printk (KERN_INFO "load_buffer : block %llu offset %u buf_length %u, %u - %u \n",blocknum, ntohl(data->offsets[blocknum]), buf_length, ntohl(data->offsets[blocknum+1]), ntohl(data->offsets[blocknum]) );
+#endif
+	/*if the block is uncompressible we just memcpy() the block*/
+	if (buf_length==0) {
+		memset(data->buffer,0,buflen);
+		data->buffered_blocknum = blocknum;
+		return 1;
+	}
+
+	if (cloop_file_io(file,(char *)data->compressed_buffer,buf_length, &pos)) {
+		printk(KERN_ERR "%s: I/O Error\n",
+			CLOOP_NAME);
+	}
+
+	if(buf_length>buflen) { /*Not a blocksize we expect*/
+		printk(KERN_ERR "%s; error, corrupted index or old cloop"
+			"format, please update the image", CLOOP_NAME);
+		return 0;
+	}
+	if(buf_length==buflen) /*uncompressed*/
+		memcpy(data->buffer,data->compressed_buffer,
+	 		buflen);
+	else
+	ret = crypto_comp_decompress(data->tfm, data->compressed_buffer,
+			buf_length, data->buffer, (unsigned int *)&buflen);
+
+	if (ret != 0) {
+		printk(KERN_ERR "%s: error %i uncompressing block %llu %u/%lu/%u/%u "
+			"%u-%u\n", CLOOP_NAME, ret, blocknum,
+			ntohl(data->head.block_size), buflen, 
+			buf_length, buf_done, ntohl(data->offsets[blocknum]),
+			ntohl(data->offsets[blocknum+1]));
+	 	data->buffered_blocknum = -1;
+	 	return 0;
+	}
+	
+	data->buffered_blocknum = blocknum;
+	return 1;
+}
+
+
+static int
+do_clo_receive(struct loop_device *lo,
+	       struct bio_vec *bvec, int bsize, loff_t pos)
+{
+	int retval=0;
+	char *dest=kmap(bvec->bv_page) + bvec->bv_offset;
+	struct compressloop_data *data =
+		(struct compressloop_data *) lo->key_data;
+	uint32_t block_size=ntohl(data->head.block_size),
+		len=bvec->bv_len;
+	down_interruptible(& data->mutex);
+#ifdef GCLOOP_DEBUG
+	printk (KERN_INFO "do_clo_receive : bsize %i blocksize %u len %u pos %llu \n",bsize, block_size, len, pos );
+#endif
+	while (len > 0) {
+		unsigned int offset_in_buffer, length_in_buffer;
+		loff_t index = pos;
+
+	/* using div64.h do_div macro*/
+		offset_in_buffer = do_div(index,block_size);
+
+		if (!load_buffer(index,lo)) {
+	 		retval=-EIO;
+	 		break;
+	 	}
+	/* Now, at least part of what we want will be in the buffer. */
+		length_in_buffer = block_size - offset_in_buffer;
+
+		if (length_in_buffer > len)
+			length_in_buffer = len;
+
+		memcpy(dest, data->buffer + offset_in_buffer,length_in_buffer);
+
+		dest += length_in_buffer;
+		len -= length_in_buffer;
+		pos += length_in_buffer;
+	}
+	
+	kunmap(bvec->bv_page);
+	up(&data->mutex);
+	return (retval < 0)? retval: 0;
+}
+
+
+
+
+static struct loop_func_table compressloop_funcs = {
+	.number = LO_CRYPT_CRYPTOAPI,
+	.init = compressloop_init,
+	.ioctl = compressloop_ioctl,
+	.transfer = NULL,
+	.release = compressloop_release,
+	.owner = THIS_MODULE,
+	.do_receive = do_clo_receive
+};
+
+static int __init
+init_compressloop(void)
+{
+	int rc = loop_register_transfer(&compressloop_funcs);
+
+	if (rc)
+		printk(KERN_ERR "compressloop: loop_register_transfer failed\n");
+	return rc;
+}
+
+static void __exit
+cleanup_compressloop(void)
+{
+	if (loop_unregister_transfer(LO_CRYPT_CRYPTOAPI))
+		printk(KERN_ERR
+			"compressloop: loop_unregister_transfer failed\n");
+}
+
+module_init(init_compressloop);
+module_exit(cleanup_compressloop);
diff -ruN linux-2.6.0-mm2/drivers/block/loop.c linux-2.6.0-mm2.new/drivers/block/loop.c
--- linux-2.6.0-mm2/drivers/block/loop.c	2004-01-01 13:23:42.000000000 +0100
+++ linux-2.6.0-mm2.new/drivers/block/loop.c	2004-01-01 13:19:29.000000000 +0100
@@ -335,7 +335,7 @@
 	int i, ret = 0;
 
 	bio_for_each_segment(bvec, bio, i) {
-		ret = do_lo_receive(lo, bvec, bsize, pos);
+		ret = lo->do_receive(lo, bvec, bsize, pos);
 		if (ret < 0)
 			break;
 		pos += bvec->bv_len;
@@ -705,7 +705,17 @@
 	err = loop_init_xfer(lo, xfer, info);
 	if (err)
 		return err;
-
+	/*If you are about to use a compressed loop*/
+	if (!xfer)
+		xfer = &none_funcs;
+		
+	if (xfer->number == LO_CRYPT_CRYPTOAPI &&
+	    xfer->do_receive != NULL){
+	/*believe what is written in the image*/
+	set_capacity(disks[lo->lo_number], lo->lo_sizelimit);
+	}
+	else
+	/*else check for physical limits*/
 	if (lo->lo_offset != info->lo_offset ||
 	    lo->lo_sizelimit != info->lo_sizelimit) {
 		lo->lo_offset = info->lo_offset;
@@ -714,13 +724,14 @@
 			return -EFBIG;
 	}
 
+
 	memcpy(lo->lo_file_name, info->lo_file_name, LO_NAME_SIZE);
 	memcpy(lo->lo_crypt_name, info->lo_crypt_name, LO_NAME_SIZE);
 	lo->lo_file_name[LO_NAME_SIZE-1] = 0;
 	lo->lo_crypt_name[LO_NAME_SIZE-1] = 0;
 
-	if (!xfer)
-		xfer = &none_funcs;
+/*	if (!xfer)
+		xfer = &none_funcs;*/
 	lo->transfer = xfer->transfer;
 	lo->ioctl = xfer->ioctl;
 
@@ -731,8 +742,12 @@
 		memcpy(lo->lo_encrypt_key, info->lo_encrypt_key,
 		       info->lo_encrypt_key_size);
 		lo->lo_key_owner = current->uid;
-	}	
-
+	}
+	
+	if (xfer->do_receive) 
+		lo->do_receive = xfer->do_receive;
+	else 	lo->do_receive=do_lo_receive;
+	
 	return 0;
 }
 
diff -ruN linux-2.6.0-mm2/include/linux/cloop.h linux-2.6.0-mm2.new/include/linux/cloop.h
--- linux-2.6.0-mm2/include/linux/cloop.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.0-mm2.new/include/linux/cloop.h	2004-01-01 13:18:05.000000000 +0100
@@ -0,0 +1,28 @@
+#ifndef _CLOOP_H
+#define _CLOOP_H
+
+
+#define CLOOP_HEADROOM 128
+
+struct cloop_head
+{
+	char preamble[CLOOP_HEADROOM];
+	u_int32_t block_size;
+	u_int32_t num_blocks;
+};
+
+struct compressloop_data 
+{
+	/* data we need to know which block uncompress) */
+	struct cloop_head head;
+	u_int32_t *offsets;
+	/* will hold the uncompressor */
+	struct 	crypto_tfm *tfm;
+	/*workspace/cache*/
+	char 	*buffer;
+	char 	*compressed_buffer;
+	int 	buffered_blocknum;
+	struct semaphore mutex;
+};
+
+#endif /*_CLOOP_H*/
diff -ruN linux-2.6.0-mm2/include/linux/loop.h linux-2.6.0-mm2.new/include/linux/loop.h
--- linux-2.6.0-mm2/include/linux/loop.h	2004-01-01 13:23:42.000000000 +0100
+++ linux-2.6.0-mm2.new/include/linux/loop.h	2004-01-01 13:18:05.000000000 +0100
@@ -64,6 +64,8 @@
 	atomic_t		lo_pending;
 
 	request_queue_t		*lo_queue;
+	int 		(*do_receive)(struct loop_device *lo,
+			struct bio_vec *bvec, int bsize, loff_t pos);
 };
 
 #endif /* __KERNEL__ */
@@ -137,6 +139,9 @@
 	int (*release)(struct loop_device *); 
 	int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
 	struct module *owner;
+	int (*do_receive)(struct loop_device *lo, struct bio_vec *bvec,
+			int bsize, loff_t pos);
+
 }; 
 
 int loop_register_transfer(struct loop_func_table *funcs);
diff -ruN linux-2.6.0-mm2/include/ucl/ucl.h linux-2.6.0-mm2.new/include/ucl/ucl.h
--- linux-2.6.0-mm2/include/ucl/ucl.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.0-mm2.new/include/ucl/ucl.h	2004-01-01 13:18:05.000000000 +0100
@@ -0,0 +1,235 @@
+/* ucl.h -- prototypes for the UCL real-time data compression library
+
+   This file is part of the UCL data compression library.
+
+   Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
+   All Rights Reserved.
+
+   The UCL library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of
+   the License, or (at your option) any later version.
+
+   The UCL library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with the UCL library; see the file COPYING.
+   If not, write to the Free Software Foundation, Inc.,
+   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+   Markus F.X.J. Oberhumer
+   <markus@oberhumer.com>
+   http://www.oberhumer.com/opensource/ucl/
+ */
+
+
+#ifndef __UCL_H
+#define __UCL_H
+
+#ifndef __UCLCONF_H
+#include <ucl/uclconf.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/***********************************************************************
+//
+************************************************************************/
+
+/* note: to use default values pass -1, i.e. initialize
+ * this struct by a memset(x,0xff,sizeof(x)) */
+struct ucl_compress_config_t
+{
+    int bb_endian;
+    int bb_size;
+    ucl_uint max_offset;
+    ucl_uint max_match;
+    int s_level;
+    int h_level;
+    int p_level;
+    int c_flags;
+    ucl_uint m_size;
+};
+
+#define ucl_compress_config_p   ucl_compress_config_t __UCL_MMODEL *
+
+
+/***********************************************************************
+// compressors
+************************************************************************/
+
+UCL_EXTERN(int)
+ucl_nrv2b_99_compress      ( const ucl_bytep src, ucl_uint src_len,
+                                   ucl_bytep dst, ucl_uintp dst_len,
+                                   ucl_progress_callback_p cb,
+                                   int level,
+                             const struct ucl_compress_config_p conf,
+                                   ucl_uintp result );
+
+UCL_EXTERN(int)
+ucl_nrv2d_99_compress      ( const ucl_bytep src, ucl_uint src_len,
+                                   ucl_bytep dst, ucl_uintp dst_len,
+                                   ucl_progress_callback_p cb,
+                                   int level,
+                             const struct ucl_compress_config_p conf,
+                                   ucl_uintp result );
+
+UCL_EXTERN(int)
+ucl_nrv2e_99_compress      ( const ucl_bytep src, ucl_uint src_len,
+                                   ucl_bytep dst, ucl_uintp dst_len,
+                                   ucl_progress_callback_p cb,
+                                   int level,
+                             const struct ucl_compress_config_p conf,
+                                   ucl_uintp result );
+
+
+/***********************************************************************
+// decompressors
+************************************************************************/
+
+UCL_EXTERN(int)
+ucl_nrv2b_decompress_8          ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2b_decompress_le16       ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2b_decompress_le32       ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2b_decompress_safe_8     ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2b_decompress_safe_le16  ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2b_decompress_safe_le32  ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+
+UCL_EXTERN(int)
+ucl_nrv2d_decompress_8          ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2d_decompress_le16       ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2d_decompress_le32       ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2d_decompress_safe_8     ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2d_decompress_safe_le16  ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2d_decompress_safe_le32  ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+
+UCL_EXTERN(int)
+ucl_nrv2e_decompress_8          ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2e_decompress_le16       ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2e_decompress_le32       ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2e_decompress_safe_8     ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2e_decompress_safe_le16  ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2e_decompress_safe_le32  ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+
+
+/***********************************************************************
+// assembler decompressors [TO BE ADDED]
+************************************************************************/
+
+
+/***********************************************************************
+// test an overlapping in-place decompression within a buffer:
+//   - try a virtual decompression from &buf[src_off] -> &buf[0]
+//   - no data is actually written
+//   - only the bytes at buf[src_off .. src_off+src_len] will get accessed
+************************************************************************/
+
+UCL_EXTERN(int)
+ucl_nrv2b_test_overlap_8        ( const ucl_bytep buf, ucl_uint src_off,
+                                        ucl_uint  src_len, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2b_test_overlap_le16     ( const ucl_bytep buf, ucl_uint src_off,
+                                        ucl_uint  src_len, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2b_test_overlap_le32     ( const ucl_bytep buf, ucl_uint src_off,
+                                        ucl_uint  src_len, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+
+UCL_EXTERN(int)
+ucl_nrv2d_test_overlap_8        ( const ucl_bytep buf, ucl_uint src_off,
+                                        ucl_uint  src_len, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2d_test_overlap_le16     ( const ucl_bytep buf, ucl_uint src_off,
+                                        ucl_uint  src_len, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2d_test_overlap_le32     ( const ucl_bytep buf, ucl_uint src_off,
+                                        ucl_uint  src_len, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+
+UCL_EXTERN(int)
+ucl_nrv2e_test_overlap_8        ( const ucl_bytep buf, ucl_uint src_off,
+                                        ucl_uint  src_len, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2e_test_overlap_le16     ( const ucl_bytep buf, ucl_uint src_off,
+                                        ucl_uint  src_len, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+UCL_EXTERN(int)
+ucl_nrv2e_test_overlap_le32     ( const ucl_bytep buf, ucl_uint src_off,
+                                        ucl_uint  src_len, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* already included */
+
diff -ruN linux-2.6.0-mm2/include/ucl/uclconf.h linux-2.6.0-mm2.new/include/ucl/uclconf.h
--- linux-2.6.0-mm2/include/ucl/uclconf.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.0-mm2.new/include/ucl/uclconf.h	2004-01-01 13:18:06.000000000 +0100
@@ -0,0 +1,407 @@
+/* uclconf.h -- configuration for the UCL real-time data compression library
+
+   This file is part of the UCL data compression library.
+
+   Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
+   All Rights Reserved.
+
+   The UCL library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of
+   the License, or (at your option) any later version.
+
+   The UCL library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with the UCL library; see the file COPYING.
+   If not, write to the Free Software Foundation, Inc.,
+   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+   Markus F.X.J. Oberhumer
+   <markus@oberhumer.com>
+   http://www.oberhumer.com/opensource/ucl/
+ */
+
+
+#ifndef __UCLCONF_H
+#define __UCLCONF_H
+
+#define UCL_VERSION             0x010100L
+#define UCL_VERSION_STRING      "1.01"
+#define UCL_VERSION_DATE        "Jan 02 2002"
+
+/* internal Autoconf configuration file - only used when building UCL */
+#if defined(UCL_HAVE_CONFIG_H)
+#  include <config.h>
+#endif
+#include <limits.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/***********************************************************************
+// UCL requires a conforming <limits.h>
+************************************************************************/
+
+#if !defined(CHAR_BIT) || (CHAR_BIT != 8)
+#  error "invalid CHAR_BIT"
+#endif
+#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
+#  error "check your compiler installation"
+#endif
+#if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
+#  error "your limits.h macros are broken"
+#endif
+
+/* workaround a compiler bug under hpux 10.20 */
+#define UCL_0xffffffffL         4294967295ul
+
+#if !defined(UCL_UINT32_C)
+#  if (UINT_MAX < UCL_0xffffffffL)
+#    define UCL_UINT32_C(c)     c ## UL
+#  else
+#    define UCL_UINT32_C(c)     c ## U
+#  endif
+#endif
+
+
+/***********************************************************************
+// architecture defines
+************************************************************************/
+
+#if !defined(__UCL_WIN) && !defined(__UCL_DOS) && !defined(__UCL_OS2)
+#  if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
+#    define __UCL_WIN
+#  elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
+#    define __UCL_WIN
+#  elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__)
+#    define __UCL_WIN
+#  elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS)
+#    define __UCL_DOS
+#  elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2)
+#    define __UCL_OS2
+#  elif defined(__palmos__)
+#    define __UCL_PALMOS
+#  elif defined(__TOS__) || defined(__atarist__)
+#    define __UCL_TOS
+#  endif
+#endif
+
+#if (UINT_MAX < UCL_0xffffffffL)
+#  if defined(__UCL_WIN)
+#    define __UCL_WIN16
+#  elif defined(__UCL_DOS)
+#    define __UCL_DOS16
+#  elif defined(__UCL_PALMOS)
+#    define __UCL_PALMOS16
+#  elif defined(__UCL_TOS)
+#    define __UCL_TOS16
+#  elif defined(__C166__)
+#  else
+#    error "16-bit target not supported - contact me for porting hints"
+#  endif
+#endif
+
+#if !defined(__UCL_i386)
+#  if defined(__UCL_DOS) || defined(__UCL_WIN16)
+#    define __UCL_i386
+#  elif defined(__i386__) || defined(__386__) || defined(_M_IX86)
+#    define __UCL_i386
+#  endif
+#endif
+
+#if defined(__UCL_STRICT_16BIT)
+#  if (UINT_MAX < UCL_0xffffffffL)
+#    include <ucl/ucl16bit.h>
+#  endif
+#endif
+
+/* memory checkers */
+#if !defined(__UCL_CHECKER)
+#  if defined(__BOUNDS_CHECKING_ON)
+#    define __UCL_CHECKER
+#  elif defined(__CHECKER__)
+#    define __UCL_CHECKER
+#  elif defined(__INSURE__)
+#    define __UCL_CHECKER
+#  elif defined(__PURIFY__)
+#    define __UCL_CHECKER
+#  endif
+#endif
+
+
+/***********************************************************************
+// integral and pointer types
+************************************************************************/
+
+/* Integral types with 32 bits or more */
+#if !defined(UCL_UINT32_MAX)
+#  if (UINT_MAX >= UCL_0xffffffffL)
+     typedef unsigned int       ucl_uint32;
+     typedef int                ucl_int32;
+#    define UCL_UINT32_MAX      UINT_MAX
+#    define UCL_INT32_MAX       INT_MAX
+#    define UCL_INT32_MIN       INT_MIN
+#  elif (ULONG_MAX >= UCL_0xffffffffL)
+     typedef unsigned long      ucl_uint32;
+     typedef long               ucl_int32;
+#    define UCL_UINT32_MAX      ULONG_MAX
+#    define UCL_INT32_MAX       LONG_MAX
+#    define UCL_INT32_MIN       LONG_MIN
+#  else
+#    error "ucl_uint32"
+#  endif
+#endif
+
+/* ucl_uint is used like size_t */
+#if !defined(UCL_UINT_MAX)
+#  if (UINT_MAX >= UCL_0xffffffffL)
+     typedef unsigned int       ucl_uint;
+     typedef int                ucl_int;
+#    define UCL_UINT_MAX        UINT_MAX
+#    define UCL_INT_MAX         INT_MAX
+#    define UCL_INT_MIN         INT_MIN
+#  elif (ULONG_MAX >= UCL_0xffffffffL)
+     typedef unsigned long      ucl_uint;
+     typedef long               ucl_int;
+#    define UCL_UINT_MAX        ULONG_MAX
+#    define UCL_INT_MAX         LONG_MAX
+#    define UCL_INT_MIN         LONG_MIN
+#  else
+#    error "ucl_uint"
+#  endif
+#endif
+
+/* Memory model that allows to access memory at offsets of ucl_uint. */
+#if !defined(__UCL_MMODEL)
+#  if (UCL_UINT_MAX <= UINT_MAX)
+#    define __UCL_MMODEL
+#  elif defined(__UCL_DOS16) || defined(__UCL_WIN16)
+#    define __UCL_MMODEL        __huge
+#    define UCL_999_UNSUPPORTED
+#  elif defined(__UCL_PALMOS16) || defined(__UCL_TOS16)
+#    define __UCL_MMODEL
+#  else
+#    error "__UCL_MMODEL"
+#  endif
+#endif
+
+/* no typedef here because of const-pointer issues */
+#define ucl_byte                unsigned char __UCL_MMODEL
+#define ucl_bytep               unsigned char __UCL_MMODEL *
+#define ucl_charp               char __UCL_MMODEL *
+#define ucl_voidp               void __UCL_MMODEL *
+#define ucl_shortp              short __UCL_MMODEL *
+#define ucl_ushortp             unsigned short __UCL_MMODEL *
+#define ucl_uint32p             ucl_uint32 __UCL_MMODEL *
+#define ucl_int32p              ucl_int32 __UCL_MMODEL *
+#define ucl_uintp               ucl_uint __UCL_MMODEL *
+#define ucl_intp                ucl_int __UCL_MMODEL *
+#define ucl_voidpp              ucl_voidp __UCL_MMODEL *
+#define ucl_bytepp              ucl_bytep __UCL_MMODEL *
+
+typedef int ucl_bool;
+
+
+/***********************************************************************
+// function types
+************************************************************************/
+
+/* linkage */
+#if !defined(__UCL_EXTERN_C)
+#  ifdef __cplusplus
+#    define __UCL_EXTERN_C      extern "C"
+#  else
+#    define __UCL_EXTERN_C      extern
+#  endif
+#endif
+
+/* calling conventions */
+#if !defined(__UCL_CDECL)
+#  if defined(__UCL_DOS16) || defined(__UCL_WIN16)
+#    define __UCL_CDECL         __far __cdecl
+#  elif defined(__UCL_i386) && defined(_MSC_VER)
+#    define __UCL_CDECL         __cdecl
+#  elif defined(__UCL_i386) && defined(__WATCOMC__)
+#    define __UCL_CDECL         __near __cdecl
+#  else
+#    define __UCL_CDECL
+#  endif
+#endif
+#if !defined(__UCL_ENTRY)
+#  define __UCL_ENTRY           __UCL_CDECL
+#endif
+
+/* DLL export information */
+#if !defined(__UCL_EXPORT1)
+#  define __UCL_EXPORT1
+#endif
+#if !defined(__UCL_EXPORT2)
+#  define __UCL_EXPORT2
+#endif
+
+/* calling convention for C functions */
+#if !defined(UCL_PUBLIC)
+#  define UCL_PUBLIC(_rettype)  __UCL_EXPORT1 _rettype __UCL_EXPORT2 __UCL_ENTRY
+#endif
+#if !defined(UCL_EXTERN)
+#  define UCL_EXTERN(_rettype)  __UCL_EXTERN_C UCL_PUBLIC(_rettype)
+#endif
+#if !defined(UCL_PRIVATE)
+#  define UCL_PRIVATE(_rettype) static _rettype __UCL_ENTRY
+#endif
+
+/* cdecl calling convention for assembler functions */
+#if !defined(UCL_PUBLIC_CDECL)
+#  define UCL_PUBLIC_CDECL(_rettype) \
+                __UCL_EXPORT1 _rettype __UCL_EXPORT2 __UCL_CDECL
+#endif
+#if !defined(UCL_EXTERN_CDECL)
+#  define UCL_EXTERN_CDECL(_rettype)  __UCL_EXTERN_C UCL_PUBLIC_CDECL(_rettype)
+#endif
+
+/* C++ exception specification for extern "C" function types */
+#if !defined(__cplusplus)
+#  undef UCL_NOTHROW
+#  define UCL_NOTHROW
+#elif !defined(UCL_NOTHROW)
+#  define UCL_NOTHROW
+#endif
+
+
+typedef int
+(__UCL_ENTRY *ucl_compress_t)   ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+
+typedef int
+(__UCL_ENTRY *ucl_decompress_t) ( const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+
+typedef int
+(__UCL_ENTRY *ucl_optimize_t)   (       ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem );
+
+typedef int
+(__UCL_ENTRY *ucl_compress_dict_t)(const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem,
+                                  const ucl_bytep dict, ucl_uint dict_len );
+
+typedef int
+(__UCL_ENTRY *ucl_decompress_dict_t)(const ucl_bytep src, ucl_uint  src_len,
+                                        ucl_bytep dst, ucl_uintp dst_len,
+                                        ucl_voidp wrkmem,
+                                  const ucl_bytep dict, ucl_uint dict_len );
+
+
+/* a progress indicator callback function */
+typedef struct
+{
+    void (__UCL_ENTRY *callback) (ucl_uint, ucl_uint, int, ucl_voidp user);
+    ucl_voidp user;
+}
+ucl_progress_callback_t;
+#define ucl_progress_callback_p ucl_progress_callback_t __UCL_MMODEL *
+
+
+/***********************************************************************
+// error codes and prototypes
+************************************************************************/
+
+/* Error codes for the compression/decompression functions. Negative
+ * values are errors, positive values will be used for special but
+ * normal events.
+ */
+#define UCL_E_OK                    0
+#define UCL_E_ERROR                 (-1)
+#define UCL_E_INVALID_ARGUMENT      (-2)
+#define UCL_E_OUT_OF_MEMORY         (-3)
+/* compression errors */
+#define UCL_E_NOT_COMPRESSIBLE      (-101)
+/* decompression errors */
+#define UCL_E_INPUT_OVERRUN         (-201)
+#define UCL_E_OUTPUT_OVERRUN        (-202)
+#define UCL_E_LOOKBEHIND_OVERRUN    (-203)
+#define UCL_E_EOF_NOT_FOUND         (-204)
+#define UCL_E_INPUT_NOT_CONSUMED    (-205)
+#define UCL_E_OVERLAP_OVERRUN       (-206)
+
+
+/* ucl_init() should be the first function you call.
+ * Check the return code !
+ *
+ * ucl_init() is a macro to allow checking that the library and the
+ * compiler's view of various types are consistent.
+ */
+#define ucl_init() __ucl_init2(UCL_VERSION,(int)sizeof(short),(int)sizeof(int),\
+    (int)sizeof(long),(int)sizeof(ucl_uint32),(int)sizeof(ucl_uint),\
+    (int)-1,(int)sizeof(char *),(int)sizeof(ucl_voidp),\
+    (int)sizeof(ucl_compress_t))
+UCL_EXTERN(int) __ucl_init2(ucl_uint32,int,int,int,int,int,int,int,int,int);
+
+/* version functions (useful for shared libraries) */
+UCL_EXTERN(ucl_uint32) ucl_version(void);
+UCL_EXTERN(const char *) ucl_version_string(void);
+UCL_EXTERN(const char *) ucl_version_date(void);
+UCL_EXTERN(const ucl_charp) _ucl_version_string(void);
+UCL_EXTERN(const ucl_charp) _ucl_version_date(void);
+
+/* string functions */
+UCL_EXTERN(int)
+ucl_memcmp(const ucl_voidp _s1, const ucl_voidp _s2, ucl_uint _len);
+UCL_EXTERN(ucl_voidp)
+ucl_memcpy(ucl_voidp _dest, const ucl_voidp _src, ucl_uint _len);
+UCL_EXTERN(ucl_voidp)
+ucl_memmove(ucl_voidp _dest, const ucl_voidp _src, ucl_uint _len);
+UCL_EXTERN(ucl_voidp)
+ucl_memset(ucl_voidp _s, int _c, ucl_uint _len);
+
+/* checksum functions */
+UCL_EXTERN(ucl_uint32)
+ucl_adler32(ucl_uint32 _adler, const ucl_bytep _buf, ucl_uint _len);
+UCL_EXTERN(ucl_uint32)
+ucl_crc32(ucl_uint32 _c, const ucl_bytep _buf, ucl_uint _len);
+
+/* memory allocation functions */
+UCL_EXTERN(ucl_voidp) ucl_alloc(ucl_uint _nelems, ucl_uint _size);
+UCL_EXTERN(ucl_voidp) ucl_malloc(ucl_uint _size);
+UCL_EXTERN(void) ucl_free(ucl_voidp _ptr);
+
+typedef ucl_voidp (__UCL_ENTRY *ucl_alloc_hook_t) (ucl_uint, ucl_uint);
+typedef void (__UCL_ENTRY *ucl_free_hook_t) (ucl_voidp);
+
+extern ucl_alloc_hook_t ucl_alloc_hook;
+extern ucl_free_hook_t ucl_free_hook;
+
+/* misc. */
+UCL_EXTERN(ucl_bool) ucl_assert(int _expr);
+UCL_EXTERN(int) _ucl_config_check(void);
+typedef union { ucl_bytep p; ucl_uint u; } __ucl_pu_u;
+typedef union { ucl_bytep p; ucl_uint32 u32; } __ucl_pu32_u;
+
+/* align a char pointer on a boundary that is a multiple of `size' */
+UCL_EXTERN(unsigned) __ucl_align_gap(const ucl_voidp _ptr, ucl_uint _size);
+#define UCL_PTR_ALIGN_UP(_ptr,_size) \
+    ((_ptr) + (ucl_uint) __ucl_align_gap((const ucl_voidp)(_ptr),(ucl_uint)(_size)))
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* already included */
+
diff -ruN linux-2.6.0-mm2/include/ucl/uclutil.h linux-2.6.0-mm2.new/include/ucl/uclutil.h
--- linux-2.6.0-mm2/include/ucl/uclutil.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.0-mm2.new/include/ucl/uclutil.h	2004-01-01 13:18:06.000000000 +0100
@@ -0,0 +1,71 @@
+/* uclutil.h -- utilities for the UCL real-time data compression library
+
+   This file is part of the UCL data compression library.
+
+   Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
+   Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
+   All Rights Reserved.
+
+   The UCL library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2 of
+   the License, or (at your option) any later version.
+
+   The UCL library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with the UCL library; see the file COPYING.
+   If not, write to the Free Software Foundation, Inc.,
+   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+   Markus F.X.J. Oberhumer
+   <markus@oberhumer.com>
+   http://www.oberhumer.com/opensource/ucl/
+ */
+
+
+#ifndef __UCLUTIL_H
+#define __UCLUTIL_H
+
+#ifndef __UCLCONF_H
+#include <ucl/uclconf.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/***********************************************************************
+//
+************************************************************************/
+
+UCL_EXTERN(ucl_uint)
+ucl_fread(FILE *f, ucl_voidp buf, ucl_uint size);
+UCL_EXTERN(ucl_uint)
+ucl_fwrite(FILE *f, const ucl_voidp buf, ucl_uint size);
+
+
+#if (UCL_UINT_MAX <= UINT_MAX)
+   /* avoid problems with Win32 DLLs */
+#  define ucl_fread(f,b,s)      (fread(b,1,s,f))
+#  define ucl_fwrite(f,b,s)     (fwrite(b,1,s,f))
+#endif
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* already included */
+