/[linux-patches]/genpatches-2.6/historical/2.6.2/415_gcloop-2.6-20040118.patch
Gentoo

Contents of /genpatches-2.6/historical/2.6.2/415_gcloop-2.6-20040118.patch

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20