openssl: bump to release 1.1.1b
[openwrt/staging/chunkeey.git] / tools / squashfs4 / patches / 170-add_support_for_LZMA_MAGIC_to_unsqashfs.patch
1 --- a/squashfs-tools/squashfs_fs.h
2 +++ b/squashfs-tools/squashfs_fs.h
3 @@ -30,6 +30,13 @@
4 #define SQUASHFS_MAGIC_SWAP 0x68737173
5 #define SQUASHFS_START 0
6
7 +/*
8 + * Squashfs + LZMA
9 + */
10 +
11 +#define SQUASHFS_MAGIC_LZMA 0x71736873
12 +#define SQUASHFS_MAGIC_LZMA_SWAP 0x73687371
13 +
14 /* size of metadata (inode and directory) blocks */
15 #define SQUASHFS_METADATA_SIZE 8192
16 #define SQUASHFS_METADATA_LOG 13
17 --- a/squashfs-tools/unsquashfs.c
18 +++ b/squashfs-tools/unsquashfs.c
19 @@ -1464,10 +1464,12 @@ int read_super(char *source)
20 */
21 read_fs_bytes(fd, SQUASHFS_START, sizeof(struct squashfs_super_block),
22 &sBlk_4);
23 - swap = sBlk_4.s_magic != SQUASHFS_MAGIC;
24 + swap = (sBlk_4.s_magic != SQUASHFS_MAGIC &&
25 + sBlk_4.s_magic != SQUASHFS_MAGIC_LZMA);
26 SQUASHFS_INSWAP_SUPER_BLOCK(&sBlk_4);
27
28 - if(sBlk_4.s_magic == SQUASHFS_MAGIC && sBlk_4.s_major == 4 &&
29 + if((sBlk_4.s_magic == SQUASHFS_MAGIC ||
30 + sBlk_4.s_magic == SQUASHFS_MAGIC_LZMA) && sBlk_4.s_major == 4 &&
31 sBlk_4.s_minor == 0) {
32 s_ops.squashfs_opendir = squashfs_opendir_4;
33 s_ops.read_fragment = read_fragment_4;
34 @@ -1480,7 +1482,11 @@ int read_super(char *source)
35 /*
36 * Check the compression type
37 */
38 - comp = lookup_compressor_id(sBlk.s.compression);
39 + if (sBlk_4.s_magic == SQUASHFS_MAGIC_LZMA)
40 + comp = lookup_compressor("lzma");
41 + else
42 + comp = lookup_compressor_id(sBlk.s.compression);
43 +
44 return TRUE;
45 }
46
47 @@ -1495,8 +1501,10 @@ int read_super(char *source)
48 * Check it is a SQUASHFS superblock
49 */
50 swap = 0;
51 - if(sBlk_3.s_magic != SQUASHFS_MAGIC) {
52 - if(sBlk_3.s_magic == SQUASHFS_MAGIC_SWAP) {
53 + if(sBlk_3.s_magic != SQUASHFS_MAGIC &&
54 + sBlk_3.s_magic != SQUASHFS_MAGIC_LZMA) {
55 + if(sBlk_3.s_magic == SQUASHFS_MAGIC_SWAP ||
56 + sBlk_3.s_magic == SQUASHFS_MAGIC_LZMA_SWAP) {
57 squashfs_super_block_3 sblk;
58 ERROR("Reading a different endian SQUASHFS filesystem "
59 "on %s\n", source);
60 @@ -1574,7 +1582,11 @@ int read_super(char *source)
61 /*
62 * 1.x, 2.x and 3.x filesystems use gzip compression.
63 */
64 - comp = lookup_compressor("gzip");
65 + if (sBlk.s.s_magic == SQUASHFS_MAGIC_LZMA)
66 + comp = lookup_compressor("lzma");
67 + else
68 + comp = lookup_compressor("gzip");
69 +
70 return TRUE;
71
72 failed_mount: