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