5 #include <linux/compiler.h> 16 return "Memory allocation failed";
17 case LZMA_OPTIONS_ERROR:
18 return "Unsupported decompressor flags";
19 case LZMA_FORMAT_ERROR:
20 return "The input is not in the .xz format";
22 return "Compressed file is corrupt";
24 return "Compressed file is truncated or otherwise corrupt";
26 return "Unknown error, possibly a bug";
32 lzma_action action = LZMA_RUN;
33 lzma_stream strm = LZMA_STREAM_INIT;
41 infile = fopen(input,
"rb");
43 pr_err(
"lzma: fopen failed on %s: '%s'\n",
48 ret = lzma_stream_decoder(&strm, UINT64_MAX, LZMA_CONCATENATED);
50 pr_err(
"lzma: lzma_stream_decoder failed %s (%d)\n",
57 strm.next_out = buf_out;
58 strm.avail_out =
sizeof(buf_out);
61 if (strm.avail_in == 0 && !feof(infile)) {
62 strm.next_in = buf_in;
63 strm.avail_in = fread(buf_in, 1,
sizeof(buf_in), infile);
74 ret = lzma_code(&strm, action);
76 if (strm.avail_out == 0 || ret == LZMA_STREAM_END) {
77 ssize_t write_size =
sizeof(buf_out) - strm.avail_out;
79 if (
writen(output_fd, buf_out, write_size) != write_size) {
84 strm.next_out = buf_out;
85 strm.avail_out =
sizeof(buf_out);
89 if (ret == LZMA_STREAM_END)
static int input(yyscan_t yyscanner)
int lzma_decompress_to_file(const char *input, int output_fd)
ssize_t writen(int fd, const void *buf, size_t n)
static const char * lzma_strerror(lzma_ret ret)