]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
feat: USTAR+LZ4 compressed initrd
authorTulio A M Mendes <[email protected]>
Mon, 16 Feb 2026 18:03:36 +0000 (15:03 -0300)
committerTulio A M Mendes <[email protected]>
Mon, 16 Feb 2026 18:03:36 +0000 (15:03 -0300)
commitc0e8f3d5be74802c0156e2b2e052ad46847ecaa7
tree7ad74f63e18b910765abcefa3866185bc63fb550
parent1860e2786ecdc08dc0d96b797d67d96fc99cc405
feat: USTAR+LZ4 compressed initrd

Add LZ4 block compression to the initrd pipeline:

- src/kernel/lz4.c + include/lz4.h: standalone LZ4 block decompressor
  (~80 lines, no external dependencies)
- src/drivers/initrd.c: auto-detect LZ4B magic at boot, decompress
  into heap buffer, then parse the contained USTAR tar as before
- tools/mkinitrd.c: built-in LZ4 block compressor (greedy hash-table),
  builds tar in memory then wraps in LZ4B envelope
  (magic + orig_size + comp_size + compressed data)

Format: LZ4B header (12 bytes) + raw LZ4 block.  Falls back to
uncompressed tar if compression fails.

Results on current initrd (12 files including doom.elf):
  TAR: 562 KB -> LZ4B: 326 KB (58% ratio)

Backward compatible: kernel still accepts plain USTAR tar
(no LZ4B magic = parse directly).

83/83 smoke tests pass (10s), cppcheck clean.
include/lz4.h [new file with mode: 0644]
src/drivers/initrd.c
src/kernel/lz4.c [new file with mode: 0644]
tools/mkinitrd.c