From aa22e7a83dd1f1fe803163dddfffb6683ffc35ad Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Wed, 5 Aug 2020 06:19:17 +0300 Subject: [PATCH 01/10] Add outline of SquashFS superblock --- filesystem/squashfs_superblock.ksy | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 filesystem/squashfs_superblock.ksy diff --git a/filesystem/squashfs_superblock.ksy b/filesystem/squashfs_superblock.ksy new file mode 100644 index 000000000..6288dc04b --- /dev/null +++ b/filesystem/squashfs_superblock.ksy @@ -0,0 +1,54 @@ +meta: + id: squashfs_superblock + title: SquashFS superblock + file-extension: + - squashfs + - snap + endian: le + license: CC-0 +doc-ref: https://github.com/AgentD/squashfs-tools-ng/blob/master/doc/format.txt +seq: + - id: superblock + type: superblock +types: + superblock: + seq: + - id: magic + contents: 'hsqs' + - id: inode_count + type: u4 + - id: mod_time + type: u4 + - id: block_size + type: u4 + - id: frag_count + type: u4 + - id: compressor + type: u2 + - id: block_log + type: u2 + - id: flags + type: u2 + - id: id_count + type: u2 + - id: version_major + contents: [ 4, 0 ] + - id: version_minor + contents: [ 0, 0 ] + - id: root_inode_ref + type: u8 + - id: bytes_used + type: u8 + - id: id_table_start + type: u8 + - id: xattr_id_table_start + type: u8 + - id: inode_table_start + type: u8 + - id: directory_table_start + type: u8 + - id: fragment_table_start + type: u8 + - id: export_table_start + type: u8 + \ No newline at end of file From 96745d1f8b78e3f825c67ae6865db188451f7e55 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Wed, 5 Aug 2020 10:55:29 +0300 Subject: [PATCH 02/10] Wikidata xref by @KOLANICH --- filesystem/squashfs_superblock.ksy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/filesystem/squashfs_superblock.ksy b/filesystem/squashfs_superblock.ksy index 6288dc04b..d81ab668d 100644 --- a/filesystem/squashfs_superblock.ksy +++ b/filesystem/squashfs_superblock.ksy @@ -6,6 +6,8 @@ meta: - snap endian: le license: CC-0 + xref: + wikidata: Q389314 doc-ref: https://github.com/AgentD/squashfs-tools-ng/blob/master/doc/format.txt seq: - id: superblock From 502d6daeb912ab29ab88f43ef5f8542dc475f9cf Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Wed, 5 Aug 2020 12:24:46 +0300 Subject: [PATCH 03/10] Add doc to `block_log` --- filesystem/squashfs_superblock.ksy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/filesystem/squashfs_superblock.ksy b/filesystem/squashfs_superblock.ksy index d81ab668d..3db03fe46 100644 --- a/filesystem/squashfs_superblock.ksy +++ b/filesystem/squashfs_superblock.ksy @@ -29,6 +29,9 @@ types: type: u2 - id: block_log type: u2 + doc: | + The log2 of the block size. If the two fields do not agree, the + archive is considered corrupted. - id: flags type: u2 - id: id_count @@ -53,4 +56,3 @@ types: type: u8 - id: export_table_start type: u8 - \ No newline at end of file From 044a7260d8eaa399955b876ac33a7aff4dac6f02 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Wed, 5 Aug 2020 15:57:07 +0300 Subject: [PATCH 04/10] Add docs to fields and made compressor a enum --- filesystem/squashfs_superblock.ksy | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/filesystem/squashfs_superblock.ksy b/filesystem/squashfs_superblock.ksy index 3db03fe46..98787dc62 100644 --- a/filesystem/squashfs_superblock.ksy +++ b/filesystem/squashfs_superblock.ksy @@ -12,6 +12,14 @@ doc-ref: https://github.com/AgentD/squashfs-tools-ng/blob/master/doc/format.txt seq: - id: superblock type: superblock +enums: + compressor: + 1: gzip + 2: lzo + 3: lzma + 4: xz + 5: lz4 + 6: zstd types: superblock: seq: @@ -21,12 +29,19 @@ types: type: u4 - id: mod_time type: u4 + doc: Unix times of last modification. - id: block_size type: u4 + doc: | + The size of a data block in bytes. Must be a power of two between + 4096 (4k) and 1048576 (1 MiB). - id: frag_count type: u4 + doc: The number of entries in the fragment table. - id: compressor type: u2 + enum: compressor + doc: Compressor used for both data and meta data blocks. - id: block_log type: u2 doc: | @@ -36,14 +51,20 @@ types: type: u2 - id: id_count type: u2 + doc: The number of entries in the ID lookup table. - id: version_major contents: [ 4, 0 ] - id: version_minor contents: [ 0, 0 ] - id: root_inode_ref type: u8 + doc: A reference to the inode of the root directory. - id: bytes_used type: u8 + doc: | + The number of bytes used by the archive. Because SquashFS + archives must be padded to a multiple of the underlying device + block size, this can be less than the actual file size. - id: id_table_start type: u8 - id: xattr_id_table_start From 2d2c8526d808020ad155b6c1b543627a2b133ee9 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Wed, 5 Aug 2020 21:08:41 +0300 Subject: [PATCH 05/10] Map `flags` to bit in SquashFS superblock --- filesystem/squashfs_superblock.ksy | 32 +++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/filesystem/squashfs_superblock.ksy b/filesystem/squashfs_superblock.ksy index 98787dc62..f1ffa6eb6 100644 --- a/filesystem/squashfs_superblock.ksy +++ b/filesystem/squashfs_superblock.ksy @@ -21,6 +21,36 @@ enums: 5: lz4 6: zstd types: + flags: + seq: + # bit count starts from the largest, byte count form the smallest + - id: nfs_export_table + type: b1 + - id: data_deduplicated + type: b1 + - id: fragments_always_generated + type: b1 + - id: fragments_not_used + type: b1 + - id: fragments_uncompresed + type: b1 + - type: b1 + doc: 0x0004 bit is unused. + - id: data_blocks_uncompresed + type: b1 + - id: inodes_uncompresed + type: b1 + # bits 0x0100 are below, starting from the largest + - type: b4 + doc: bits 11110000 are unused + - id: id_table_uncompresed + type: b1 + - id: compressor_options_present + type: b1 + - id: xattrs_absent + type: b1 + - id: xattrs_uncompressed + type: b1 superblock: seq: - id: magic @@ -48,7 +78,7 @@ types: The log2 of the block size. If the two fields do not agree, the archive is considered corrupted. - id: flags - type: u2 + type: flags - id: id_count type: u2 doc: The number of entries in the ID lookup table. From 9a3096967038e5ba8173c09ccd5fa7c867397bbb Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Thu, 6 Aug 2020 20:13:16 +0300 Subject: [PATCH 06/10] Add description about what SquashFS is --- filesystem/squashfs_superblock.ksy | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/filesystem/squashfs_superblock.ksy b/filesystem/squashfs_superblock.ksy index f1ffa6eb6..67261bde3 100644 --- a/filesystem/squashfs_superblock.ksy +++ b/filesystem/squashfs_superblock.ksy @@ -8,6 +8,11 @@ meta: license: CC-0 xref: wikidata: Q389314 +doc: | + SquashFS is a compressed filesystem in a file, that can be read-only + accessed from low memory devices. It is popular for booting LiveCDs and + packing self-contained binaries. SquashFS format is used by Ubuntu .snap + packages. SquashFS is natively supported by Linux Kernel. doc-ref: https://github.com/AgentD/squashfs-tools-ng/blob/master/doc/format.txt seq: - id: superblock From 0b78cdd9146566b8a28e38a5f275b6855bd93547 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Fri, 7 Aug 2020 12:16:37 +0300 Subject: [PATCH 07/10] Add bitmask `0x` comments to `flags` --- filesystem/squashfs_superblock.ksy | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/filesystem/squashfs_superblock.ksy b/filesystem/squashfs_superblock.ksy index 67261bde3..7626186e4 100644 --- a/filesystem/squashfs_superblock.ksy +++ b/filesystem/squashfs_superblock.ksy @@ -29,32 +29,30 @@ types: flags: seq: # bit count starts from the largest, byte count form the smallest - - id: nfs_export_table + - id: nfs_export_table # 0x0080 type: b1 - - id: data_deduplicated + - id: data_deduplicated # 0x0040 type: b1 - - id: fragments_always_generated + - id: fragments_always_generated # 0x0020 type: b1 - - id: fragments_not_used + - id: fragments_not_used # 0x0010 type: b1 - - id: fragments_uncompresed + - id: fragments_uncompresed # 0x0008 type: b1 - - type: b1 - doc: 0x0004 bit is unused. - - id: data_blocks_uncompresed + - type: b1 # 0x0004 bit is unused + - id: data_blocks_uncompresed # 0x0002 type: b1 - - id: inodes_uncompresed + - id: inodes_uncompresed # 0x0001 type: b1 # bits 0x0100 are below, starting from the largest - - type: b4 - doc: bits 11110000 are unused - - id: id_table_uncompresed + - type: b4 # bits 11110000 are unused + - id: id_table_uncompresed # 0x0800 type: b1 - - id: compressor_options_present + - id: compressor_options_present # 0x0400 type: b1 - - id: xattrs_absent + - id: xattrs_absent # 0x0200 type: b1 - - id: xattrs_uncompressed + - id: xattrs_uncompressed # 0x0100 type: b1 superblock: seq: From 9218754661c41597e2d1dc51fb08908d33fdc3c3 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Sat, 2 Jan 2021 17:56:26 +0300 Subject: [PATCH 08/10] s/CC-0/CC0-1.0/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Petr Pučil --- filesystem/squashfs_superblock.ksy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filesystem/squashfs_superblock.ksy b/filesystem/squashfs_superblock.ksy index 7626186e4..fa7d93768 100644 --- a/filesystem/squashfs_superblock.ksy +++ b/filesystem/squashfs_superblock.ksy @@ -5,7 +5,7 @@ meta: - squashfs - snap endian: le - license: CC-0 + license: CC0-1.0 xref: wikidata: Q389314 doc: | From 87b8a3665af9cb2f2bc81c098823d9b6faf597b9 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Sat, 2 Jan 2021 18:01:03 +0300 Subject: [PATCH 09/10] squashfs: Use `valid` instead of `contents` This reflects the field size in spec as agreed in review comments . --- filesystem/squashfs_superblock.ksy | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/filesystem/squashfs_superblock.ksy b/filesystem/squashfs_superblock.ksy index fa7d93768..a7e561205 100644 --- a/filesystem/squashfs_superblock.ksy +++ b/filesystem/squashfs_superblock.ksy @@ -86,9 +86,13 @@ types: type: u2 doc: The number of entries in the ID lookup table. - id: version_major - contents: [ 4, 0 ] + type: u2 + valid: + eq: 4 - id: version_minor - contents: [ 0, 0 ] + type: u2 + valid: + eq: 0 - id: root_inode_ref type: u8 doc: A reference to the inode of the root directory. From 44b535e2c4f28c978941ad4c039b639dbbad66f8 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Mon, 15 Mar 2021 23:50:50 +0300 Subject: [PATCH 10/10] Add .sqfs as possible file-extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Petr Pučil --- filesystem/squashfs_superblock.ksy | 1 + 1 file changed, 1 insertion(+) diff --git a/filesystem/squashfs_superblock.ksy b/filesystem/squashfs_superblock.ksy index a7e561205..feaa2a029 100644 --- a/filesystem/squashfs_superblock.ksy +++ b/filesystem/squashfs_superblock.ksy @@ -4,6 +4,7 @@ meta: file-extension: - squashfs - snap + - sqfs endian: le license: CC0-1.0 xref: