diff options
Diffstat (limited to 'fs/squashfs/decompressor.c')
-rw-r--r-- | fs/squashfs/decompressor.c | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/fs/squashfs/decompressor.c b/fs/squashfs/decompressor.c index 3f6271d86abc..234291f79ba5 100644 --- a/fs/squashfs/decompressor.c +++ b/fs/squashfs/decompressor.c | |||
@@ -37,29 +37,29 @@ | |||
37 | */ | 37 | */ |
38 | 38 | ||
39 | static const struct squashfs_decompressor squashfs_lzma_unsupported_comp_ops = { | 39 | static const struct squashfs_decompressor squashfs_lzma_unsupported_comp_ops = { |
40 | NULL, NULL, NULL, LZMA_COMPRESSION, "lzma", 0 | 40 | NULL, NULL, NULL, NULL, LZMA_COMPRESSION, "lzma", 0 |
41 | }; | 41 | }; |
42 | 42 | ||
43 | #ifndef CONFIG_SQUASHFS_LZO | 43 | #ifndef CONFIG_SQUASHFS_LZO |
44 | static const struct squashfs_decompressor squashfs_lzo_comp_ops = { | 44 | static const struct squashfs_decompressor squashfs_lzo_comp_ops = { |
45 | NULL, NULL, NULL, LZO_COMPRESSION, "lzo", 0 | 45 | NULL, NULL, NULL, NULL, LZO_COMPRESSION, "lzo", 0 |
46 | }; | 46 | }; |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #ifndef CONFIG_SQUASHFS_XZ | 49 | #ifndef CONFIG_SQUASHFS_XZ |
50 | static const struct squashfs_decompressor squashfs_xz_comp_ops = { | 50 | static const struct squashfs_decompressor squashfs_xz_comp_ops = { |
51 | NULL, NULL, NULL, XZ_COMPRESSION, "xz", 0 | 51 | NULL, NULL, NULL, NULL, XZ_COMPRESSION, "xz", 0 |
52 | }; | 52 | }; |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | #ifndef CONFIG_SQUASHFS_ZLIB | 55 | #ifndef CONFIG_SQUASHFS_ZLIB |
56 | static const struct squashfs_decompressor squashfs_zlib_comp_ops = { | 56 | static const struct squashfs_decompressor squashfs_zlib_comp_ops = { |
57 | NULL, NULL, NULL, ZLIB_COMPRESSION, "zlib", 0 | 57 | NULL, NULL, NULL, NULL, ZLIB_COMPRESSION, "zlib", 0 |
58 | }; | 58 | }; |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | static const struct squashfs_decompressor squashfs_unknown_comp_ops = { | 61 | static const struct squashfs_decompressor squashfs_unknown_comp_ops = { |
62 | NULL, NULL, NULL, 0, "unknown", 0 | 62 | NULL, NULL, NULL, NULL, 0, "unknown", 0 |
63 | }; | 63 | }; |
64 | 64 | ||
65 | static const struct squashfs_decompressor *decompressor[] = { | 65 | static const struct squashfs_decompressor *decompressor[] = { |
@@ -83,10 +83,10 @@ const struct squashfs_decompressor *squashfs_lookup_decompressor(int id) | |||
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | void *squashfs_decompressor_init(struct super_block *sb, unsigned short flags) | 86 | static void *get_comp_opts(struct super_block *sb, unsigned short flags) |
87 | { | 87 | { |
88 | struct squashfs_sb_info *msblk = sb->s_fs_info; | 88 | struct squashfs_sb_info *msblk = sb->s_fs_info; |
89 | void *strm, *buffer = NULL; | 89 | void *buffer = NULL, *comp_opts; |
90 | int length = 0; | 90 | int length = 0; |
91 | 91 | ||
92 | /* | 92 | /* |
@@ -94,23 +94,40 @@ void *squashfs_decompressor_init(struct super_block *sb, unsigned short flags) | |||
94 | */ | 94 | */ |
95 | if (SQUASHFS_COMP_OPTS(flags)) { | 95 | if (SQUASHFS_COMP_OPTS(flags)) { |
96 | buffer = kmalloc(PAGE_CACHE_SIZE, GFP_KERNEL); | 96 | buffer = kmalloc(PAGE_CACHE_SIZE, GFP_KERNEL); |
97 | if (buffer == NULL) | 97 | if (buffer == NULL) { |
98 | return ERR_PTR(-ENOMEM); | 98 | comp_opts = ERR_PTR(-ENOMEM); |
99 | goto out; | ||
100 | } | ||
99 | 101 | ||
100 | length = squashfs_read_data(sb, &buffer, | 102 | length = squashfs_read_data(sb, &buffer, |
101 | sizeof(struct squashfs_super_block), 0, NULL, | 103 | sizeof(struct squashfs_super_block), 0, NULL, |
102 | PAGE_CACHE_SIZE, 1); | 104 | PAGE_CACHE_SIZE, 1); |
103 | 105 | ||
104 | if (length < 0) { | 106 | if (length < 0) { |
105 | strm = ERR_PTR(length); | 107 | comp_opts = ERR_PTR(length); |
106 | goto finished; | 108 | goto out; |
107 | } | 109 | } |
108 | } | 110 | } |
109 | 111 | ||
110 | strm = msblk->decompressor->init(msblk, buffer, length); | 112 | comp_opts = squashfs_comp_opts(msblk, buffer, length); |
111 | 113 | ||
112 | finished: | 114 | out: |
113 | kfree(buffer); | 115 | kfree(buffer); |
116 | return comp_opts; | ||
117 | } | ||
118 | |||
119 | |||
120 | void *squashfs_decompressor_setup(struct super_block *sb, unsigned short flags) | ||
121 | { | ||
122 | struct squashfs_sb_info *msblk = sb->s_fs_info; | ||
123 | void *stream, *comp_opts = get_comp_opts(sb, flags); | ||
124 | |||
125 | if (IS_ERR(comp_opts)) | ||
126 | return comp_opts; | ||
127 | |||
128 | stream = squashfs_decompressor_create(msblk, comp_opts); | ||
129 | if (IS_ERR(stream)) | ||
130 | kfree(comp_opts); | ||
114 | 131 | ||
115 | return strm; | 132 | return stream; |
116 | } | 133 | } |