Lines Matching +full:out +full:- +full:of +full:- +full:window
1 // SPDX-License-Identifier: GPL-2.0
4 * Important notes about in-place decompression
7 * is placed to the end of the output buffer, and the decompressor overwrites
8 * most of the compressed data. There must be enough safety margin to
14 * The worst case for in-place decompression is that the beginning of
15 * the file is compressed extremely well, and the rest of the file is
16 * uncompressible. Thus, we must look for worst-case expansion when the
19 * The structure of the .zst file in case of a compressed kernel is as follows.
20 * Maximum sizes (as bytes) of the fields are in parenthesis.
29 * a 3 bytes. After the block header, there is up to 128 KB of payload.
30 * The maximum uncompressed size of the payload is 128 KB. The minimum
31 * uncompressed size of the payload is never less than the payload size
34 * The assumption, that the uncompressed size of the payload is never
38 * the worst case for this would be tricky. Instead of trying to do that,
40 * of the payload which it is currently reading.
43 * - 22 bytes for the .zst file format headers;
44 * - 3 bytes per every 128 KiB of uncompressed size (one block header per
46 * - 128 KiB (biggest possible zstd block size) to make sure that the
58 * All of the source files we depend on must be #included.
63 * used for kernel decompression, instead of unzstd().
80 /* 128MB is the maximum window size supported by zstd. */
83 * Size of the input and output buffers in multi-call mode.
86 * zstd's window anyway. The larger size speeds up initramfs decompression.
103 error("ZSTD decompressor ran out of memory"); in handle_zstd_error()
111 error("ZSTD-compressed data is corrupt"); in handle_zstd_error()
114 error("ZSTD-compressed data is probably corrupt"); in handle_zstd_error()
117 return -1; in handle_zstd_error()
122 * We can allocate less memory (no circular buffer for the sliding window),
136 error("Out of memory while allocating zstd_dctx"); in decompress_single()
137 err = -1; in decompress_single()
138 goto out; in decompress_single()
141 * Find out how large the frame actually is, there may be junk at in decompress_single()
142 * the end of the frame that zstd_decompress_dctx() can't handle. in decompress_single()
147 goto out; in decompress_single()
153 goto out; in decompress_single()
159 out: in decompress_single()
173 zstd_out_buffer out; in __unzstd() local
189 out_len = UINTPTR_MAX - (uintptr_t)out_buf; in __unzstd()
207 error("Out of memory while allocating input buffer"); in __unzstd()
208 err = -1; in __unzstd()
209 goto out; in __unzstd()
218 error("ZSTD-compressed data is truncated"); in __unzstd()
219 err = -1; in __unzstd()
220 goto out; in __unzstd()
222 /* Set the first non-empty input buffer. */ in __unzstd()
230 error("Out of memory while allocating output buffer"); in __unzstd()
231 err = -1; in __unzstd()
232 goto out; in __unzstd()
238 out.dst = out_buf; in __unzstd()
239 out.pos = 0; in __unzstd()
240 out.size = out_len; in __unzstd()
243 * We need to know the window size to allocate the zstd_dstream. in __unzstd()
245 * window. The window size varies from 1 KB to ZSTD_WINDOWSIZE_MAX in __unzstd()
252 goto out; in __unzstd()
254 error("ZSTD-compressed data has an incomplete frame header"); in __unzstd()
255 err = -1; in __unzstd()
256 goto out; in __unzstd()
259 error("ZSTD-compressed data has too large a window size"); in __unzstd()
260 err = -1; in __unzstd()
261 goto out; in __unzstd()
272 error("Out of memory while allocating ZSTD_DStream"); in __unzstd()
273 err = -1; in __unzstd()
274 goto out; in __unzstd()
293 in_len = fill ? fill(in_buf, ZSTD_IOBUF_SIZE) : -1; in __unzstd()
295 error("ZSTD-compressed data is truncated"); in __unzstd()
296 err = -1; in __unzstd()
297 goto out; in __unzstd()
303 ret = zstd_decompress_stream(dstream, &out, &in); in __unzstd()
306 goto out; in __unzstd()
307 /* Flush all of the data produced if using flush(). */ in __unzstd()
308 if (flush != NULL && out.pos > 0) { in __unzstd()
309 if (out.pos != flush(out.dst, out.pos)) { in __unzstd()
311 err = -1; in __unzstd()
312 goto out; in __unzstd()
314 out.pos = 0; in __unzstd()
322 out: in __unzstd()