dwarfs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #------------------------------------------------------------------------------
  2. # $File: dwarfs,v 1.2 2023/05/23 13:37:32 christos Exp $
  3. # dwarfs: file(1) magic for DwarFS File System Image files
  4. # URL: https://github.com/mhx/dwarfs for details about DwarFS
  5. # From: Marcus Holland-Moritz <github@mhxnet.de>
  6. #### DwarFS Version Macro
  7. 0 name dwarfsversion
  8. >&0 byte x \b, version %d
  9. >&1 byte x \b.%d
  10. #### DwarFS Compression Macro
  11. 0 name dwarfscompression
  12. >&0 leshort =0 \b, uncompressed
  13. >&0 leshort =1 \b, LZMA compression
  14. >&0 leshort =2 \b, ZSTD compression
  15. >&0 leshort =3 \b, LZ4 compression
  16. >&0 leshort =4 \b, LZ4HC compression
  17. >&0 leshort =5 \b, BROTLI compression
  18. #### DwarFS files without header
  19. ## We first check against a DWARFS magic at the start of the file, then
  20. ## validate by checking the block count / section type to be all zeros
  21. ## for the first block. Finally, we check that the *next* block also
  22. ## has the correct DWARFS magic.
  23. 0 string DWARFS
  24. >&0x2A string/b \0\0\0\0\0\0
  25. >>&(&0x02.q+0x0A) string DWARFS DwarFS File System Image
  26. >>>&0 use dwarfsversion
  27. >>&0 use dwarfscompression
  28. #### DwarFS files with header
  29. ## We search for a DWARFS magic in the first 64k of the file (images with
  30. ## headers longer than 64k won't be recognized), then validate by checking
  31. ## the block count / section type to be all zeros for the first block.
  32. ## Finally, we check that the *next* block also has the correct DWARFS magic.
  33. ## If we find a DWARFS magic that doesn't pass validation, we continue with
  34. ## an indirect match recursively.
  35. 1 search/65536/b DWARFS
  36. >&0x2A string/b \0\0\0\0\0\0
  37. >>&(&0x02.q+0x0A) string DWARFS DwarFS File System Image (with header)
  38. >>>&0 use dwarfsversion
  39. >>&0 use dwarfscompression
  40. >&-1 indirect x