zlib compress buffer in kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there,

How can I implement buffer compression in kernel space with zlib?

I found this piece of code in  fs/cramfs.c

/* Returns length of decompressed data. */
int cramfs_uncompress_block(void *dst, int dstlen, void *src, int srclen)
{
 int err;

 stream.next_in = src;
 stream.avail_in = srclen;

 stream.next_out = dst;
 stream.avail_out = dstlen;

 err = zlib_fs_inflateReset(&stream);
 if (err != Z_OK) {
   printk("zlib_fs_inflateReset error %d\n", err);
   zlib_fs_inflateEnd(&stream);
   zlib_fs_inflateInit(&stream);
 }

 err = zlib_fs_inflate(&stream, Z_FINISH);
 if (err != Z_STREAM_END)
   goto err;
 return stream.total_out;

err:
 printk("Error %d while decompressing!\n", err);
 printk("%p(%d)->%p(%d)\n", src, srclen, dst, dstlen);
 return 0;
}

Can I write something like this  in an kernel module?

static int compress (struct cloop_device *clo, char *dest, unsigned long *destLen,
char *source, unsigned long sourceLen)


I've tried something with "zlib_deflate", "zlib_deflateInit" "zlib_deflateEnd" and this results in unresolved symbols when I insmod my module.

TIA!
Lei


-- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux