clean of the rootfs_split patch
[openwrt.git] / target / linux / generic-2.6 / patches / 003-squashfs_lzma.patch
1 diff -urN linux-2.6.21.1.old/fs/squashfs/inode.c linux-2.6.21.1.dev/fs/squashfs/inode.c
2 --- linux-2.6.21.1.old/fs/squashfs/inode.c 2007-05-26 19:03:45.499713896 +0200
3 +++ linux-2.6.21.1.dev/fs/squashfs/inode.c 2007-05-26 19:07:27.951896024 +0200
4 @@ -4,6 +4,9 @@
5 * Copyright (c) 2002, 2003, 2004, 2005, 2006
6 * Phillip Lougher <phillip@lougher.org.uk>
7 *
8 + * LZMA decompressor support added by Oleg I. Vdovikin
9 + * Copyright (c) 2005 Oleg I.Vdovikin <oleg@cs.msu.su>
10 + *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2,
14 @@ -21,6 +24,7 @@
15 * inode.c
16 */
17
18 +#define SQUASHFS_LZMA
19 #include <linux/types.h>
20 #include <linux/squashfs_fs.h>
21 #include <linux/module.h>
22 @@ -44,6 +48,19 @@
23
24 #include "squashfs.h"
25
26 +#ifdef SQUASHFS_LZMA
27 +#include <linux/LzmaDecode.h>
28 +
29 +/* default LZMA settings, should be in sync with mksquashfs */
30 +#define LZMA_LC 3
31 +#define LZMA_LP 0
32 +#define LZMA_PB 2
33 +
34 +#define LZMA_WORKSPACE_SIZE ((LZMA_BASE_SIZE + \
35 + (LZMA_LIT_SIZE << (LZMA_LC + LZMA_LP))) * sizeof(CProb))
36 +
37 +#endif
38 +
39 static void squashfs_put_super(struct super_block *);
40 static int squashfs_statfs(struct dentry *, struct kstatfs *);
41 static int squashfs_symlink_readpage(struct file *file, struct page *page);
42 @@ -64,7 +81,11 @@
43 const char *, void *, struct vfsmount *);
44
45
46 +#ifdef SQUASHFS_LZMA
47 +static unsigned char lzma_workspace[LZMA_WORKSPACE_SIZE];
48 +#else
49 static z_stream stream;
50 +#endif
51
52 static struct file_system_type squashfs_fs_type = {
53 .owner = THIS_MODULE,
54 @@ -249,6 +270,15 @@
55 if (compressed) {
56 int zlib_err;
57
58 +#ifdef SQUASHFS_LZMA
59 + if ((zlib_err = LzmaDecode(lzma_workspace,
60 + LZMA_WORKSPACE_SIZE, LZMA_LC, LZMA_LP, LZMA_PB,
61 + c_buffer, c_byte, buffer, msblk->read_size, &bytes)) != LZMA_RESULT_OK)
62 + {
63 + ERROR("lzma returned unexpected result 0x%x\n", zlib_err);
64 + bytes = 0;
65 + }
66 +#else
67 stream.next_in = c_buffer;
68 stream.avail_in = c_byte;
69 stream.next_out = buffer;
70 @@ -263,7 +293,7 @@
71 bytes = 0;
72 } else
73 bytes = stream.total_out;
74 -
75 +#endif
76 up(&msblk->read_data_mutex);
77 }
78
79 @@ -2045,15 +2075,19 @@
80 printk(KERN_INFO "squashfs: version 3.0 (2006/03/15) "
81 "Phillip Lougher\n");
82
83 +#ifndef SQUASHFS_LZMA
84 if (!(stream.workspace = vmalloc(zlib_inflate_workspacesize()))) {
85 ERROR("Failed to allocate zlib workspace\n");
86 destroy_inodecache();
87 err = -ENOMEM;
88 goto out;
89 }
90 +#endif
91
92 if ((err = register_filesystem(&squashfs_fs_type))) {
93 +#ifndef SQUASHFS_LZMA
94 vfree(stream.workspace);
95 +#endif
96 destroy_inodecache();
97 }
98
99 @@ -2064,7 +2098,9 @@
100
101 static void __exit exit_squashfs_fs(void)
102 {
103 +#ifndef SQUASHFS_LZMA
104 vfree(stream.workspace);
105 +#endif
106 unregister_filesystem(&squashfs_fs_type);
107 destroy_inodecache();
108 }
This page took 0.055696 seconds and 5 git commands to generate.