Root/target/linux/generic/patches-3.2/541-ubifs-xz-decompression-support.patch

1--- a/fs/ubifs/Kconfig
2+++ b/fs/ubifs/Kconfig
3@@ -5,8 +5,10 @@ config UBIFS_FS
4     select CRYPTO if UBIFS_FS_ADVANCED_COMPR
5     select CRYPTO if UBIFS_FS_LZO
6     select CRYPTO if UBIFS_FS_ZLIB
7+ select CRYPTO if UBIFS_FS_XZ
8     select CRYPTO_LZO if UBIFS_FS_LZO
9     select CRYPTO_DEFLATE if UBIFS_FS_ZLIB
10+ select CRYPTO_XZ if UBIFS_FS_XZ
11     depends on MTD_UBI
12     help
13       UBIFS is a file system for flash devices which works on top of UBI.
14@@ -42,6 +44,14 @@ config UBIFS_FS_ZLIB
15     help
16       Zlib compresses better than LZO but it is slower. Say 'Y' if unsure.
17 
18+config UBIFS_FS_XZ
19+ bool "XZ decompression support" if UBIFS_FS_ADVANCED_COMPR
20+ depends on UBIFS_FS
21+ default y
22+ help
23+ XZ compresses better the ZLIB but it is slower.
24+ Say 'Y' if unsure.
25+
26 # Debugging-related stuff
27 config UBIFS_FS_DEBUG
28     bool "Enable debugging support"
29--- a/fs/ubifs/compress.c
30+++ b/fs/ubifs/compress.c
31@@ -71,6 +71,24 @@ static struct ubifs_compressor zlib_comp
32 };
33 #endif
34 
35+#ifdef CONFIG_UBIFS_FS_XZ
36+static DEFINE_MUTEX(xz_enc_mutex);
37+static DEFINE_MUTEX(xz_dec_mutex);
38+
39+static struct ubifs_compressor xz_compr = {
40+ .compr_type = UBIFS_COMPR_XZ,
41+ .comp_mutex = &xz_enc_mutex,
42+ .decomp_mutex = &xz_dec_mutex,
43+ .name = "xz",
44+ .capi_name = "xz",
45+};
46+#else
47+static struct ubifs_compressor zlib_compr = {
48+ .compr_type = UBIFS_COMPR_XZ,
49+ .name = "xz",
50+};
51+#endif
52+
53 /* All UBIFS compressors */
54 struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
55 
56@@ -233,9 +251,15 @@ int __init ubifs_compressors_init(void)
57     if (err)
58         goto out_lzo;
59 
60+ err = compr_init(&xz_compr);
61+ if (err)
62+ goto out_zlib;
63+
64     ubifs_compressors[UBIFS_COMPR_NONE] = &none_compr;
65     return 0;
66 
67+out_zlib:
68+ compr_exit(&zlib_compr);
69 out_lzo:
70     compr_exit(&lzo_compr);
71     return err;
72@@ -248,4 +272,5 @@ void ubifs_compressors_exit(void)
73 {
74     compr_exit(&lzo_compr);
75     compr_exit(&zlib_compr);
76+ compr_exit(&xz_compr);
77 }
78--- a/fs/ubifs/ubifs-media.h
79+++ b/fs/ubifs/ubifs-media.h
80@@ -332,12 +332,14 @@ enum {
81  * UBIFS_COMPR_NONE: no compression
82  * UBIFS_COMPR_LZO: LZO compression
83  * UBIFS_COMPR_ZLIB: ZLIB compression
84+ * UBIFS_COMPR_XZ: XZ compression
85  * UBIFS_COMPR_TYPES_CNT: count of supported compression types
86  */
87 enum {
88     UBIFS_COMPR_NONE,
89     UBIFS_COMPR_LZO,
90     UBIFS_COMPR_ZLIB,
91+ UBIFS_COMPR_XZ,
92     UBIFS_COMPR_TYPES_CNT,
93 };
94 
95

Archive Download this file



interactive