xz_dec_run(9)
π xz_dec_run(9) β the one that actually runs the XZ decoder π
okay so bestie, welcome to xz_dec_run(9) from the Kernel API Manual β yes the kernel has a whole manpage vibe and honestly? iconic. this is the function that literally runs the XZ decoder. let's get into it π«Ά
β¨ SYNOPSIS β¨
enum xz_ret xz_dec_run (struct xz_dec *s , struct xz_buf *b );
like, that's it. two args. slay.
π ARGUMENTS π
sβ the decoder state, and no you can't just make one up out of thin air, it has to be allocated usingxz_dec_init. main character energy only πbβ the input and output buffers. that's the whole vibe, in and out.
π¦ DESCRIPTION π¦
so the possible return values depend on build options and operation mode β like, it's giving β¨situationalβ¨. for the details you gotta go see enum xz_ret. iykyk π
β οΈ okay this part is important, don't skip it β οΈ
note that if an error occurs in single-call mode (aka the return value is not XZ_STREAM_END), then b->in_pos and b->out_pos are not modified, and the contents of the output buffer from b->out[b->out_pos] onward are undefined. π like literally undefined-undefined, not "probably fine"-undefined.
and bestie, this is true even after XZ_BUF_ERROR β because with some filter chains, there may be a second pass over the output buffer, and that pass cannot be properly done if the output buffer is truncated. so no, you cannot hand the single-call decoder a too-small buffer and then expect to get that amount of valid data from the beginning of the stream. that's not how any of this works, ngl π
translation: if you don't want to uncompress the whole entire stream, you must use the multi-call decoder. periodt. π₯
πΈ SEE ALSO πΈ
- Kernel file
./include/linux/xz.h enum xz_mode(9)enum xz_ret(9)struct xz_buf(9)xz_dec_init(9)xz_dec_reset(9)xz_dec_end(9)MicroLZMA decompressor(9)xz_dec_microlzma_alloc(9)xz_dec_microlzma_reset(9)xz_dec_microlzma_run(9)xz_dec_microlzma_end(9)
like a whole little friend group of functions, obsessed π
and that's the page!! this one lives over in ./include/linux and it's dated October 2026 β so go forth and decode responsibly, bestie. mwah πβ¨π§
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms