decompress lz4f (lz4 with frame) in linux kernel - 4.15..0-rc4

113 views
Skip to first unread message

Avi Zana

unread,
Dec 10, 2019, 4:59:42 AM12/10/19
to LZ4c
Is there a way to decompress a file that was compressed with LZ4F (frame) in linux kernel?

I tried to compress a file using LZ4F_compressFrame API in user space but then decompression in kernel failed when I used LZ4_decompress_safe API in linux kernel probably due to malformed input data

Cyan

unread,
Dec 10, 2019, 12:12:34 PM12/10/19
to LZ4c
LZ4_decompress_safe() decodes blocks,
while LZ4F_compressFrame() compresses frames.
They are 2 different formats.

They are unrelated : blocks are subdivisions of frames.
But effectively, from a decoder perspective, it must be one way or another.

In order to be compatible with LZ4_decompress(),
one needs to compress blocks,
using, typically, LZ4_compress_default().

Note that, in order to decompress blocks, one needs to transport/provide metadata,
such as the size of said block, and decompressed size (or at least an upper bound).
Such metadata is not part of the block format, and must be provided out-of-band.

Avi Zana

unread,
Dec 10, 2019, 12:45:23 PM12/10/19
to LZ4c
Thanks for your reply.

So as far as I know, linux kernel doesn't support frames, only blocks, right?

Cyan

unread,
Dec 10, 2019, 12:53:05 PM12/10/19
to LZ4c
I suspect so. 

I'm no Kernel expert, to be fair,
but a quick search into the linux source code do not find any lz4frame related symbol.

Avi Zana

unread,
Dec 10, 2019, 11:20:04 PM12/10/19
to LZ4c
Yep, this is what I saw as well. Thought maybe I'm missing something.

Thanks again for your help

Reply all
Reply to author
Forward
0 new messages