lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1193441153.17726.17.camel@vince-desktop>
Date:	Fri, 26 Oct 2007 16:25:53 -0700
From:	vince kim <vince.kim@...ess-company.com>
To:	Vince Kim <Vince.Kim@...ess-company.com>,
	linux-kernel@...r.kernel.org
Cc:	"Richard Purdie [rpurdie"@openedhand.com
Subject: [PATCH 1/2 ] Add support LZO in cramfs

This is a kernel patch to add support LZO compression in cramfs. 
I used LZO kernel library patch done by Richard Purdie
[rpurdie@...nedhand.com], and my cramfs patch requires his LZO library
patch.
Richard's LZO kernel library patch can be found at:
http://lwn.net/Articles/238723/

This patch is generated against 2.6.23.

We had some performance gain with cramfs using LZO compression, but the
cramfs image size has been increased by around 10%.
So, if performance is higher priority, you could try this patch.

I will post separate patch for mkcramfs tool to generate cramfs image
using LZO compression.

Thanks,

Vince Kyong-jin Kim [vince.kim@...ess-company.com]

 
diff -Naur linux-2.6.23/fs/cramfs/inode.c
linux-2.6.23_cramfs_lzo/fs/cramfs/inode.c
--- linux-2.6.23/fs/cramfs/inode.c      2007-10-09 13:31:38.000000000
-0700
+++ linux-2.6.23_cramfs_lzo/fs/cramfs/inode.c    2007-10-26
14:35:59.000000000 -0700
@@ -31,6 +31,8 @@
 static const struct inode_operations cramfs_dir_inode_operations;
 static const struct file_operations cramfs_directory_operations;
 static const struct address_space_operations cramfs_aops; 
+/* function pointer to uncompress block */
+static int (* cramfs_uncompress_block) (void *dst, int dstlen, void
*src, int srclen);

 static DEFINE_MUTEX(read_mutex);

@@ -274,7 +276,17 @@
                printk(KERN_ERR "cramfs: unsupported filesystem features
\n"); 
                goto out;
        }
-
+
+       /* check flag to see if LZO compression is used */
+       if (super.flags & CRAMFS_FLAG_LZO_COMPRESSION) {
+               cramfs_uncompress_block = &cramfs_uncompress_block_lzo; 
+               printk("cramfs: LZO compression\n");
+       }
+       else {
+               cramfs_uncompress_block = &cramfs_uncompress_block_zlib;
+               printk("cramfs: ZLIB compression\n"); 
+       }
+
        /* Check that the root inode is in a sane state */
        if (!S_ISDIR(super.root.mode)) {
                printk(KERN_ERR "cramfs: root is not a directory\n");
diff -Naur linux-2.6.23/fs/cramfs/uncompress.c
linux-2.6.23_cramfs_lzo/fs/cramfs/uncompress.c
--- linux-2.6.23/fs/cramfs/uncompress.c 2007-10-09 13:31:38.000000000
-0700
+++ linux-2.6.23_cramfs_lzo/fs/cramfs/uncompress.c      2007-10-26
14:19: 01.000000000 -0700
@@ -20,12 +20,16 @@
 #include <linux/vmalloc.h>
 #include <linux/zlib.h>
 #include <linux/cramfs_fs.h>
+#include <linux/lzo.h>

 static z_stream stream;
 static int initialized; 

-/* Returns length of decompressed data. */
-int cramfs_uncompress_block(void *dst, int dstlen, void *src, int
srclen)
+/*
+ * uncompress with ZLIB
+ * Returns length of decompressed data.
+ */
+int cramfs_uncompress_block_zlib(void *dst, int dstlen, void *src, int
srclen) 
 {
        int err;

@@ -48,7 +52,26 @@
        return stream.total_out;

 err:
-       printk("Error %d while decompressing!\n", err);
+       printk("ZLIB Error %d while decompressing!\n", err); 
+       printk("%p(%d)->%p(%d)\n", src, srclen, dst, dstlen);
+       return 0;
+}
+
+/*
+ * uncompress with LZO
+ * Returns length of decompressed data.
+ */
+int cramfs_uncompress_block_lzo(void *dst, int dstlen, void *src, int
srclen) 
+{
+       int err;
+
+       err = lzo1x_decompress_safe(src,srclen,dst,(unsigned int
*)&dstlen);
+        if (err != LZO_E_OK)
+                goto err;
+        return dstlen;
+
+err:
+       printk("LZO Error %d while decompressing!\n", err);
        printk("%p(%d)->%p(%d)\n", src, srclen, dst, dstlen);
        return 0;
 }
diff -Naur linux-2.6.23/fs/Kconfig linux-2.6.23_cramfs_lzo/fs/Kconfig 
--- linux-2.6.23/fs/Kconfig     2007-10-09 13:31:38.000000000 -0700
+++ linux-2.6.23_cramfs_lzo/fs/Kconfig  2007-10-26 14:19:01.000000000
-0700
@@ -1348,6 +1348,7 @@
        tristate "Compressed ROM file system support (cramfs)" 
        depends on BLOCK
        select ZLIB_INFLATE
+       select LZO_DECOMPRESS
        help
          Saying Y here includes support for CramFs (Compressed ROM File
          System).  CramFs is designed to be a simple, small, and
compressed 
diff -Naur linux-2.6.23/include/linux/cramfs_fs.h
linux-2.6.23_cramfs_lzo/include/linux/cramfs_fs.h
--- linux-2.6.23/include/linux/cramfs_fs.h      2007-10-09
13:31:38.000000000 -0700
+++ linux-2.6.23_cramfs_lzo/include/linux/cramfs_fs.h    2007-10-26
14:19:01.000000000 -0700
@@ -73,6 +73,7 @@
 #define CRAMFS_FLAG_HOLES              0x00000100      /* support for
holes */
 #define CRAMFS_FLAG_WRONG_SIGNATURE    0x00000200      /* reserved */
 #define CRAMFS_FLAG_SHIFTED_ROOT_OFFSET        0x00000400      /*
shifted root fs */ 
+#define CRAMFS_FLAG_LZO_COMPRESSION    0x00000800      /* LZO
compression is used */

 /*
  * Valid values in super.flags.  Currently we refuse to mount
@@ -82,11 +83,16 @@
 #define CRAMFS_SUPPORTED_FLAGS ( 0x000000ff \ 
                                | CRAMFS_FLAG_HOLES \
                                | CRAMFS_FLAG_WRONG_SIGNATURE \
-                               | CRAMFS_FLAG_SHIFTED_ROOT_OFFSET )
+                               | CRAMFS_FLAG_SHIFTED_ROOT_OFFSET \ 
+                               | CRAMFS_FLAG_LZO_COMPRESSION )
+
+/* function pointer for uncompress function */

 /* Uncompression interfaces to the underlying zlib */
-int cramfs_uncompress_block(void *dst, int dstlen, void *src, int
srclen); 
+int cramfs_uncompress_block_zlib(void *dst, int dstlen, void *src, int
srclen);
 int cramfs_uncompress_init(void);
 void cramfs_uncompress_exit(void);

+/* Uncompression interfaces to the underlying lzo */ 
+int cramfs_uncompress_block_lzo(void *dst, int dstlen, void *src, int
srclen);
 #endif











-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ