#include #include #include #include #include MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Compress 64K zeroed chunk"); #define CHUNK_SIZE 65536 #define NR_PASSES 2 static int __init lkp_init( void ) { int i; int ret; void * wrkmem; unsigned char * src_buf; unsigned char * dst_buf; size_t src_len; size_t dst_len; src_len = CHUNK_SIZE; dst_len = lzo1x_worst_compress(src_len); printk("<1> Testing LZO: start...\n"); wrkmem = vmalloc(LZO1X_1_MEM_COMPRESS); if (!wrkmem) goto enomem; src_buf = vmalloc(src_len); if (!src_buf) { vfree(wrkmem); goto enomem; } memset(src_buf, 0, src_len); dst_buf = vmalloc(dst_len); if (!dst_buf) { vfree(wrkmem); vfree(src_buf); goto enomem; } for (i = 0; i < NR_PASSES; i++) { size_t out_len; ret = lzo1x_1_compress(src_buf, src_len, dst_buf, &out_len, wrkmem); if (ret) break; printk("pass %d: compressed to %d bytes\n", i, out_len); } vfree(wrkmem); vfree(src_buf); vfree(dst_buf); return ret; enomem: printk("vmalloc failed\n"); return -ENOMEM; } static void __exit lkp_cleanup( void ) { printk("<1>Testing LZO : finish\n"); } module_init(lkp_init); module_exit(lkp_cleanup);