1
0
Fork 0
mirror of git://slackware.nl/current.git synced 2025-01-28 08:02:25 +01:00
slackware-current/source/ap/squashfs-tools/0004-unsquashfs-add-support-for-LZMA-magics.patch
Patrick J Volkerding 646a5c1cbf Mon May 28 19:12:29 UTC 2018
a/pkgtools-15.0-noarch-13.txz:  Rebuilt.
  installpkg: default line length for --terselength is the number of columns.
  removepkg: added --terse mode.
  upgradepkg: default line length for --terselength is the number of columns.
  upgradepkg: accept -option in addition to --option.
ap/vim-8.1.0026-x86_64-1.txz:  Upgraded.
d/bison-3.0.5-x86_64-1.txz:  Upgraded.
e/emacs-26.1-x86_64-1.txz:  Upgraded.
kde/kopete-4.14.3-x86_64-8.txz:  Rebuilt.
  Recompiled against libidn-1.35.
n/conntrack-tools-1.4.5-x86_64-1.txz:  Upgraded.
n/libnetfilter_conntrack-1.0.7-x86_64-1.txz:  Upgraded.
n/libnftnl-1.1.0-x86_64-1.txz:  Upgraded.
n/links-2.16-x86_64-2.txz:  Rebuilt.
  Rebuilt to enable X driver for -g mode.
n/lynx-2.8.9dev.19-x86_64-1.txz:  Upgraded.
n/nftables-0.8.5-x86_64-1.txz:  Upgraded.
n/p11-kit-0.23.11-x86_64-1.txz:  Upgraded.
n/ulogd-2.0.7-x86_64-1.txz:  Upgraded.
n/whois-5.3.1-x86_64-1.txz:  Upgraded.
xap/network-manager-applet-1.8.12-x86_64-1.txz:  Upgraded.
xap/vim-gvim-8.1.0026-x86_64-1.txz:  Upgraded.
2018-05-31 23:39:35 +02:00

102 lines
3.3 KiB
Diff

From c2dc60a94b01a1fff4a22db1c0569651afa6c959 Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jonas.gorski@gmail.com>
Date: Wed, 19 Oct 2011 11:44:57 +0200
Subject: [PATCH] unsquashfs: add support for LZMA magics
X-Face: z*RaLf`X<@C75u6Ig9}{oW$H;1_\2t5)({*|jhM<pyWR#k60!#=#>/Vb;]yA5<GWI5`6u&+
;6b'@y|8w"wB;4/e!7wYYrcqdJFY,~%Gk_4]cq$Ei/7<j&N3ah(m`ku?pX.&+~:_/wC~dwn^)MizBG
!pE^+iDQQ1yC6^,)YDKkxDd!T>\I~93>J<_`<4)A{':UrE
Some vendor (e.g. Thomson/Technicolor) use a different super block magic
to indicate LZMA compression:
qshs (0x71736873) - LZMA compression
shsq (0x73687371) - LZMA compression, SWAPPED fields
Add support for detecting this and enable extraction for filesystems
from those firmwares.
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Tested-by: Antonio Ospite <ospite@studenti.unina.it>
---
squashfs-tools/squashfs_fs.h | 6 ++++++
squashfs-tools/unsquashfs.c | 24 ++++++++++++++++++------
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/squashfs-tools/squashfs_fs.h b/squashfs-tools/squashfs_fs.h
index d4fba1b..8462a6b 100644
--- a/squashfs-tools/squashfs_fs.h
+++ b/squashfs-tools/squashfs_fs.h
@@ -30,6 +30,12 @@
#define SQUASHFS_MAGIC_SWAP 0x68737173
#define SQUASHFS_START 0
+/*
+ * Squashfs + LZMA
+ */
+#define SQUASHFS_MAGIC_LZMA 0x71736873
+#define SQUASHFS_MAGIC_LZMA_SWAP 0x73687371
+
/* size of metadata (inode and directory) blocks */
#define SQUASHFS_METADATA_SIZE 8192
#define SQUASHFS_METADATA_LOG 13
diff --git a/squashfs-tools/unsquashfs.c b/squashfs-tools/unsquashfs.c
index 320bead..7869a38 100644
--- a/squashfs-tools/unsquashfs.c
+++ b/squashfs-tools/unsquashfs.c
@@ -1516,10 +1516,12 @@ int read_super(char *source)
*/
read_fs_bytes(fd, SQUASHFS_START, sizeof(struct squashfs_super_block),
&sBlk_4);
- swap = sBlk_4.s_magic != SQUASHFS_MAGIC;
+ swap = (sBlk_4.s_magic != SQUASHFS_MAGIC &&
+ sBlk_4.s_magic != SQUASHFS_MAGIC_LZMA);
SQUASHFS_INSWAP_SUPER_BLOCK(&sBlk_4);
- if(sBlk_4.s_magic == SQUASHFS_MAGIC && sBlk_4.s_major == 4 &&
+ if((sBlk_4.s_magic == SQUASHFS_MAGIC ||
+ sBlk_4.s_magic == SQUASHFS_MAGIC_LZMA) && sBlk_4.s_major == 4 &&
sBlk_4.s_minor == 0) {
s_ops.squashfs_opendir = squashfs_opendir_4;
s_ops.read_fragment = read_fragment_4;
@@ -1532,7 +1534,11 @@ int read_super(char *source)
/*
* Check the compression type
*/
- comp = lookup_compressor_id(sBlk.s.compression);
+ if (sBlk_4.s_magic == SQUASHFS_MAGIC_LZMA)
+ comp = lookup_compressor("lzma");
+ else
+ comp = lookup_compressor_id(sBlk.s.compression);
+
return TRUE;
}
@@ -1547,8 +1553,10 @@ int read_super(char *source)
* Check it is a SQUASHFS superblock
*/
swap = 0;
- if(sBlk_3.s_magic != SQUASHFS_MAGIC) {
- if(sBlk_3.s_magic == SQUASHFS_MAGIC_SWAP) {
+ if(sBlk_3.s_magic != SQUASHFS_MAGIC &&
+ sBlk_3.s_magic != SQUASHFS_MAGIC_LZMA) {
+ if(sBlk_3.s_magic == SQUASHFS_MAGIC_SWAP ||
+ sBlk_3.s_magic == SQUASHFS_MAGIC_LZMA_SWAP) {
squashfs_super_block_3 sblk;
ERROR("Reading a different endian SQUASHFS filesystem "
"on %s\n", source);
@@ -1626,7 +1634,11 @@ int read_super(char *source)
/*
* 1.x, 2.x and 3.x filesystems use gzip compression.
*/
- comp = lookup_compressor("gzip");
+ if (sBlk.s.s_magic == SQUASHFS_MAGIC_LZMA)
+ comp = lookup_compressor("lzma");
+ else
+ comp = lookup_compressor("gzip");
+
return TRUE;
failed_mount:
--
1.7.10.4