squashfs-tools-4.4_lzip-0.diff 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. diff -urdN squashfs-tools-4.4/squashfs-tools/Makefile squashfs-tools-4.4.new/squashfs-tools/Makefile
  2. --- squashfs-tools-4.4/squashfs-tools/Makefile 2019-08-29 03:58:04.000000000 +0200
  3. +++ squashfs-tools-4.4.new/squashfs-tools/Makefile 2019-09-07 18:49:55.000000000 +0200
  4. @@ -17,6 +17,15 @@
  5. #
  6. GZIP_SUPPORT = 1
  7. +########### Building LZIP support #############
  8. +#
  9. +# The lzlib library (http://www.nongnu.org/lzip/lzlib.html) is supported.
  10. +#
  11. +# To build using lzlib - install the library and uncomment the
  12. +# LZIP_SUPPORT line below.
  13. +#
  14. +LZIP_SUPPORT = 1
  15. +
  16. ########### Building XZ support #############
  17. #
  18. # LZMA2 compression.
  19. @@ -85,7 +94,7 @@
  20. # in Mksquashfs. Obviously the compression algorithm must have been
  21. # selected to be built
  22. #
  23. -COMP_DEFAULT = gzip
  24. +COMP_DEFAULT = lzip
  25. ###############################################
  26. @@ -172,6 +181,14 @@
  27. COMPRESSORS += gzip
  28. endif
  29. +ifeq ($(LZIP_SUPPORT),1)
  30. +CFLAGS += -DLZIP_SUPPORT
  31. +MKSQUASHFS_OBJS += lzip_wrapper.o
  32. +UNSQUASHFS_OBJS += lzip_wrapper.o
  33. +LIBS += -llz
  34. +COMPRESSORS += lzip
  35. +endif
  36. +
  37. ifeq ($(LZMA_SUPPORT),1)
  38. LZMA_OBJS = $(LZMA_DIR)/C/Alloc.o $(LZMA_DIR)/C/LzFind.o \
  39. $(LZMA_DIR)/C/LzmaDec.o $(LZMA_DIR)/C/LzmaEnc.o $(LZMA_DIR)/C/LzmaLib.o
  40. @@ -321,6 +338,8 @@
  41. gzip_wrapper.o: gzip_wrapper.c squashfs_fs.h gzip_wrapper.h compressor.h
  42. +lzip_wrapper.o: lzip_wrapper.c squashfs_fs.h lzip_wrapper.h compressor.h
  43. +
  44. lzma_wrapper.o: lzma_wrapper.c compressor.h squashfs_fs.h
  45. lzma_xz_wrapper.o: lzma_xz_wrapper.c compressor.h squashfs_fs.h
  46. diff -urdN squashfs-tools-4.4/squashfs-tools/compressor.c squashfs-tools-4.4.new/squashfs-tools/compressor.c
  47. --- squashfs-tools-4.4/squashfs-tools/compressor.c 2019-08-29 03:58:04.000000000 +0200
  48. +++ squashfs-tools-4.4.new/squashfs-tools/compressor.c 2019-09-07 18:22:09.000000000 +0200
  49. @@ -33,6 +33,14 @@
  50. extern struct compressor gzip_comp_ops;
  51. #endif
  52. +#ifndef LZIP_SUPPORT
  53. +static struct compressor lzip_comp_ops = {
  54. + LZIP_COMPRESSION, "lzip"
  55. +};
  56. +#else
  57. +extern struct compressor lzip_comp_ops;
  58. +#endif
  59. +
  60. #ifndef LZMA_SUPPORT
  61. static struct compressor lzma_comp_ops = {
  62. LZMA_COMPRESSION, "lzma"
  63. @@ -80,6 +88,7 @@
  64. struct compressor *compressor[] = {
  65. &gzip_comp_ops,
  66. + &lzip_comp_ops,
  67. &lzma_comp_ops,
  68. &lzo_comp_ops,
  69. &lz4_comp_ops,
  70. diff -urdN squashfs-tools-4.4/squashfs-tools/lzip_wrapper.c squashfs-tools-4.4.new/squashfs-tools/lzip_wrapper.c
  71. --- squashfs-tools-4.4/squashfs-tools/lzip_wrapper.c 1970-01-01 01:00:00.000000000 +0100
  72. +++ squashfs-tools-4.4.new/squashfs-tools/lzip_wrapper.c 2019-09-07 18:22:09.000000000 +0200
  73. @@ -0,0 +1,462 @@
  74. +/*
  75. + * Copyright (c) 2014
  76. + * Phillip Lougher <phillip@squashfs.org.uk>
  77. + * Copyright (C) 2018 Antonio Diaz Diaz
  78. + *
  79. + * This program is free software; you can redistribute it and/or
  80. + * modify it under the terms of the GNU General Public License
  81. + * as published by the Free Software Foundation; either version 2,
  82. + * or (at your option) any later version.
  83. + *
  84. + * This program is distributed in the hope that it will be useful,
  85. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  86. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  87. + * GNU General Public License for more details.
  88. + *
  89. + * You should have received a copy of the GNU General Public License
  90. + * along with this program; if not, write to the Free Software
  91. + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  92. + *
  93. + * lzip_wrapper.c
  94. + *
  95. + * Support for LZIP compression using lzlib
  96. + * http://www.nongnu.org/lzip/lzlib.html
  97. + */
  98. +
  99. +#include <limits.h>
  100. +#include <stdint.h>
  101. +#include <stdio.h>
  102. +#include <stdlib.h>
  103. +#include <string.h>
  104. +#include <lzlib.h>
  105. +
  106. +#include "squashfs_fs.h"
  107. +#include "lzip_wrapper.h"
  108. +#include "compressor.h"
  109. +
  110. +static int dictionary_size = 0;
  111. +static float dictionary_percent = 0;
  112. +
  113. +/* default compression level */
  114. +static int compression_level = LZIP_DEFAULT_COMPRESSION_LEVEL;
  115. +
  116. +/* match_len_limit of each compression level */
  117. +const int match_len[] = { 16, 5, 6, 8, 12, 20, 36, 68, 132, 273 };
  118. +
  119. +static inline int isvalid_ds( const int dictionary_size )
  120. +{
  121. + return (dictionary_size >= LZ_min_dictionary_size() &&
  122. + dictionary_size <= LZ_max_dictionary_size());
  123. +}
  124. +
  125. +/*
  126. + * This function is called by the options parsing code in mksquashfs.c
  127. + * to parse any -X compressor option.
  128. + *
  129. + * Two specific options are supported:
  130. + * -Xcompression-level
  131. + * -Xdict-size
  132. + *
  133. + * This function returns:
  134. + * >=0 (number of additional args parsed) on success
  135. + * -1 if the option was unrecognised, or
  136. + * -2 if the option was recognised, but otherwise bad in
  137. + * some way (e.g. invalid parameter)
  138. + *
  139. + * Note: this function sets internal compressor state, but does not
  140. + * pass back the results of the parsing other than success/failure.
  141. + * The lzip_dump_options() function is called later to get the options in
  142. + * a format suitable for writing to the filesystem.
  143. + */
  144. +static int lzip_options(char *argv[], int argc)
  145. +{
  146. + if(strcmp(argv[0], "-Xcompression-level") == 0) {
  147. + if(argc < 2) {
  148. + fprintf(stderr, "lzip: -Xcompression-level missing "
  149. + "compression level\n");
  150. + fprintf(stderr, "lzip: -Xcompression-level it "
  151. + "should be 0 <= n <= 9\n");
  152. + goto failed;
  153. + }
  154. +
  155. + compression_level = atoi(argv[1]);
  156. + if(compression_level < 0 || compression_level > 9) {
  157. + fprintf(stderr, "lzip: -Xcompression-level invalid, it "
  158. + "should be 0 <= n <= 9\n");
  159. + goto failed;
  160. + }
  161. + if(compression_level == 0) {
  162. + dictionary_size = 65535;
  163. + dictionary_percent = 0;
  164. + }
  165. +
  166. + return 1;
  167. + } else if(strcmp(argv[0], "-Xdict-size") == 0) {
  168. + char *b;
  169. + float size;
  170. +
  171. + if(argc < 2) {
  172. + fprintf(stderr, "lzip: -Xdict-size missing dict-size\n");
  173. + goto failed;
  174. + }
  175. +
  176. + size = strtof(argv[1], &b);
  177. + if(*b == '%') {
  178. + if(size <= 0 || size > 100) {
  179. + fprintf(stderr, "lzip: -Xdict-size percentage "
  180. + "should be 0%% < dict-size <= 100%%\n");
  181. + goto failed;
  182. + }
  183. +
  184. + dictionary_size = 0;
  185. + dictionary_percent = size;
  186. + } else {
  187. + if((float) ((int) size) != size) {
  188. + fprintf(stderr, "lzip: -Xdict-size can't be "
  189. + "fractional unless a percentage of the"
  190. + " block size\n");
  191. + goto failed;
  192. + }
  193. +
  194. + dictionary_size = (int) size;
  195. + dictionary_percent = 0;
  196. +
  197. + if(*b == 'k' || *b == 'K')
  198. + dictionary_size *= 1024;
  199. + else if(*b == 'm' || *b == 'M')
  200. + dictionary_size *= 1024 * 1024;
  201. + else if(*b != '\0') {
  202. + fprintf(stderr, "lzip: -Xdict-size invalid "
  203. + "dict-size\n");
  204. + goto failed;
  205. + }
  206. + if(!isvalid_ds(dictionary_size)) {
  207. + fprintf(stderr, "lzip: -Xdict-size invalid, it "
  208. + "should be %d <= n <= %d\n",
  209. + LZ_min_dictionary_size(),
  210. + LZ_max_dictionary_size());
  211. + goto failed;
  212. + }
  213. + }
  214. +
  215. + return 1;
  216. + }
  217. +
  218. + return -1;
  219. +
  220. +failed:
  221. + return -2;
  222. +}
  223. +
  224. +
  225. +/*
  226. + * This function is called after all options have been parsed.
  227. + * It is used to do post-processing on the compressor options using
  228. + * values that were not expected to be known at option parse time.
  229. + *
  230. + * In this case block_size may not be known until after -Xdict-size has
  231. + * been processed (in the case where -b is specified after -Xdict-size)
  232. + *
  233. + * This function returns 0 on successful post processing, or
  234. + * -1 on error
  235. + */
  236. +static int lzip_options_post(int block_size)
  237. +{
  238. + /*
  239. + * if -Xdict-size has been specified use this to compute the datablock
  240. + * dictionary size
  241. + */
  242. + if(dictionary_size || dictionary_percent) {
  243. + if(dictionary_size) {
  244. + if(dictionary_size > block_size) {
  245. + fprintf(stderr, "lzip: -Xdict-size is larger than"
  246. + " block_size\n");
  247. + goto failed;
  248. + }
  249. + } else
  250. + dictionary_size = block_size * dictionary_percent / 100;
  251. +
  252. + if(dictionary_size < 4096) {
  253. + fprintf(stderr, "lzip: -Xdict-size should be 4096 bytes "
  254. + "or larger\n");
  255. + goto failed;
  256. + }
  257. +
  258. + } else
  259. + /* No -Xdict-size specified, use defaults */
  260. + dictionary_size = block_size;
  261. +
  262. + return 0;
  263. +
  264. +failed:
  265. + return -1;
  266. +}
  267. +
  268. +
  269. +/*
  270. + * This function is called by mksquashfs to dump the parsed
  271. + * compressor options in a format suitable for writing to the
  272. + * compressor options field in the filesystem (stored immediately
  273. + * after the superblock).
  274. + *
  275. + * This function returns a pointer to the compression options structure
  276. + * to be stored (and the size), or NULL if there are no compression
  277. + * options
  278. + */
  279. +static void *lzip_dump_options(int block_size, int *size)
  280. +{
  281. + static struct lzip_comp_opts comp_opts;
  282. +
  283. + /*
  284. + * don't store compressor specific options in file system if the
  285. + * default options are being used - no compressor options in the
  286. + * file system means the default options are always assumed
  287. + *
  288. + * Defaults are:
  289. + * compression_level: LZIP_DEFAULT_COMPRESSION_LEVEL
  290. + * metadata dictionary size: SQUASHFS_METADATA_SIZE
  291. + * datablock dictionary size: block_size
  292. + */
  293. + if(dictionary_size == block_size &&
  294. + compression_level == LZIP_DEFAULT_COMPRESSION_LEVEL)
  295. + return NULL;
  296. +
  297. + comp_opts.dictionary_size = dictionary_size;
  298. + comp_opts.compression_level = compression_level;
  299. +
  300. + SQUASHFS_INSWAP_COMP_OPTS(&comp_opts);
  301. +
  302. + *size = sizeof(comp_opts);
  303. + return &comp_opts;
  304. +}
  305. +
  306. +
  307. +/* Check and swap options read from the filesystem. */
  308. +static int lzip_check_options(struct lzip_comp_opts *comp_opts, int size)
  309. +{
  310. + /* check passed comp opts struct is of the correct length */
  311. + if(size != sizeof(struct lzip_comp_opts))
  312. + goto failed;
  313. +
  314. + SQUASHFS_INSWAP_COMP_OPTS(comp_opts);
  315. +
  316. + /* Check comp_opts structure for correctness */
  317. + if(!isvalid_ds(comp_opts->dictionary_size)) {
  318. + fprintf(stderr, "lzip: bad dictionary size in "
  319. + "compression options structure\n");
  320. + goto failed;
  321. + }
  322. +
  323. + if(comp_opts->compression_level > 9) {
  324. + fprintf(stderr, "lzip: bad compression level in "
  325. + "compression options structure\n");
  326. + goto failed;
  327. + }
  328. +
  329. + return 1;
  330. +
  331. +failed:
  332. + fprintf(stderr, "lzip: error reading stored compressor options from "
  333. + "filesystem!\n");
  334. + return 0;
  335. +}
  336. +
  337. +
  338. +/*
  339. + * This function is a helper specifically for the append mode of
  340. + * mksquashfs. Its purpose is to set the internal compressor state
  341. + * to the stored compressor options in the passed compressor options
  342. + * structure.
  343. + *
  344. + * In effect this function sets up the compressor options
  345. + * to the same state they were when the filesystem was originally
  346. + * generated, this is to ensure on appending, the compressor uses
  347. + * the same compression options that were used to generate the
  348. + * original filesystem.
  349. + *
  350. + * Note, even if there are no compressor options, this function is still
  351. + * called with an empty compressor structure (size == 0), to explicitly
  352. + * set the default options, this is to ensure any user supplied
  353. + * -X options on the appending mksquashfs command line are over-ridden
  354. + *
  355. + * This function returns 0 on sucessful extraction of options, and
  356. + * -1 on error
  357. + */
  358. +static int lzip_extract_options(int block_size, void *buffer, int size)
  359. +{
  360. + if(size == 0) {
  361. + /* set defaults */
  362. + dictionary_size = block_size;
  363. + compression_level = LZIP_DEFAULT_COMPRESSION_LEVEL;
  364. + } else {
  365. + struct lzip_comp_opts *comp_opts = buffer;
  366. + if(!lzip_check_options(comp_opts, size))
  367. + return -1;
  368. +
  369. + dictionary_size = comp_opts->dictionary_size;
  370. + compression_level = comp_opts->compression_level;
  371. + }
  372. +
  373. + return 0;
  374. +}
  375. +
  376. +
  377. +static void lzip_display_options(void *buffer, int size)
  378. +{
  379. + struct lzip_comp_opts *comp_opts = buffer;
  380. + if(!lzip_check_options(comp_opts, size))
  381. + return;
  382. +
  383. + printf("\tcompression-level %d\n", comp_opts->compression_level);
  384. + printf("\tDictionary size %d\n", comp_opts->dictionary_size);
  385. +}
  386. +
  387. +
  388. +/*
  389. + * This function is called by mksquashfs to allocate and initialise
  390. + * a lzip_stream struct, before compress() is called.
  391. + *
  392. + * This function returns 0 on success, and
  393. + * -1 on error
  394. + */
  395. +static int lzip_init(void **strm, int block_size, int datablock)
  396. +{
  397. + struct lzip_stream * const stream = malloc(sizeof(struct lzip_stream));
  398. +
  399. + if(!stream)
  400. + return -1;
  401. +
  402. + /* dict == 65535 and match_len == 16 choose fast encoder */
  403. + stream->dictionary_size =
  404. + (datablock || (compression_level == 0 && dictionary_size == 65535)) ?
  405. + dictionary_size : SQUASHFS_METADATA_SIZE;
  406. + stream->match_len_limit = match_len[compression_level];
  407. + *strm = stream;
  408. + return 0;
  409. +}
  410. +
  411. +
  412. +/* Can be called multiple times after each call to lzip_init */
  413. +static int lzip_compress(void *strm, void *dest, void *src, int size,
  414. + int block_size, int *error)
  415. +{
  416. + int ipos = 0, opos = 0;
  417. + struct lzip_stream * const stream = strm;
  418. + struct LZ_Encoder * const encoder =
  419. + LZ_compress_open(stream->dictionary_size,
  420. + stream->match_len_limit, LLONG_MAX);
  421. +
  422. + if(!encoder || LZ_compress_errno(encoder) != LZ_ok) {
  423. + *error = LZ_mem_error;
  424. + goto failed2;
  425. + }
  426. +
  427. + for(;;) {
  428. + int rd = LZ_compress_write(encoder, src + ipos, size - ipos);
  429. + if(rd < 0)
  430. + goto failed;
  431. + ipos += rd;
  432. + if(ipos >= size)
  433. + LZ_compress_finish(encoder);
  434. + rd = LZ_compress_read(encoder, dest + opos, block_size - opos);
  435. + if(rd < 0)
  436. + goto failed;
  437. + opos += rd;
  438. + if(LZ_compress_finished(encoder) == 1)
  439. + break;
  440. + if(opos >= block_size) {
  441. + /* Output buffer overflow. Return out of buffer space */
  442. + opos = 0;
  443. + break;
  444. + }
  445. + }
  446. +
  447. + LZ_compress_close(encoder);
  448. + return opos;
  449. +
  450. +failed:
  451. + /*
  452. + * All other errors return failure, with the compressor
  453. + * specific error code in *error
  454. + */
  455. + *error = LZ_compress_errno(encoder);
  456. +failed2:
  457. + LZ_compress_close(encoder);
  458. + return -1;
  459. +}
  460. +
  461. +
  462. +static int lzip_uncompress(void *dest, void *src, int size, int outsize,
  463. + int *error)
  464. +{
  465. + int ipos = 0, opos = 0;
  466. + struct LZ_Decoder * const decoder = LZ_decompress_open();
  467. +
  468. + if(!decoder || LZ_decompress_errno(decoder) != LZ_ok) {
  469. + *error = LZ_mem_error;
  470. + goto failed2;
  471. + }
  472. +
  473. + for(;;) {
  474. + int rd = LZ_decompress_write(decoder, src + ipos, size - ipos);
  475. + if(rd < 0)
  476. + goto failed;
  477. + ipos += rd;
  478. + if(ipos >= size)
  479. + LZ_decompress_finish(decoder);
  480. + rd = LZ_decompress_read(decoder, dest + opos, outsize - opos);
  481. + if(rd < 0)
  482. + goto failed;
  483. + opos += rd;
  484. + if(LZ_decompress_finished(decoder) == 1)
  485. + break;
  486. + if(opos >= outsize) {
  487. + /* Output buffer overflow. Return out of buffer space */
  488. + *error = LZ_mem_error;
  489. + goto failed2;
  490. + }
  491. + }
  492. +
  493. + LZ_decompress_close(decoder);
  494. + return opos;
  495. +
  496. +failed:
  497. + /*
  498. + * All other errors return failure, with the compressor
  499. + * specific error code in *error
  500. + */
  501. + *error = LZ_decompress_errno(decoder);
  502. +failed2:
  503. + LZ_decompress_close(decoder);
  504. + return -1;
  505. +}
  506. +
  507. +
  508. +static void lzip_usage()
  509. +{
  510. + fprintf(stderr, "\t -Xcompression-level <compression-level>\n"
  511. + "\t\t<compression-level> should be 0 .. 9 (default %d)\n",
  512. + LZIP_DEFAULT_COMPRESSION_LEVEL);
  513. + fprintf(stderr, "\t -Xdict-size <dict-size>\n"
  514. + "\t\tUse <dict-size> as the LZIP dictionary size. The dictionary\n"
  515. + "\t\tsize can be specified as a percentage of the block size, or\n"
  516. + "\t\tas an absolute value. The dictionary size must be less than\n"
  517. + "\t\tor equal to the block size and 4096 bytes or larger.\n"
  518. + "\t\tExample dict-sizes are 25%%, 37.5%% or 8K, 32K, etc.\n");
  519. +}
  520. +
  521. +
  522. +struct compressor lzip_comp_ops = {
  523. + .init = lzip_init,
  524. + .compress = lzip_compress,
  525. + .uncompress = lzip_uncompress,
  526. + .options = lzip_options,
  527. + .options_post = lzip_options_post,
  528. + .dump_options = lzip_dump_options,
  529. + .extract_options = lzip_extract_options,
  530. + .display_options = lzip_display_options,
  531. + .usage = lzip_usage,
  532. + .id = LZIP_COMPRESSION,
  533. + .name = "lzip",
  534. + .supported = 1
  535. +};
  536. diff -urdN squashfs-tools-4.4/squashfs-tools/lzip_wrapper.h squashfs-tools-4.4.new/squashfs-tools/lzip_wrapper.h
  537. --- squashfs-tools-4.4/squashfs-tools/lzip_wrapper.h 1970-01-01 01:00:00.000000000 +0100
  538. +++ squashfs-tools-4.4.new/squashfs-tools/lzip_wrapper.h 2019-09-07 18:22:09.000000000 +0200
  539. @@ -0,0 +1,58 @@
  540. +#ifndef LZIP_WRAPPER_H
  541. +#define LZIP_WRAPPER_H
  542. +/*
  543. + * Squashfs
  544. + *
  545. + * Copyright (c) 2014
  546. + * Phillip Lougher <phillip@squashfs.org.uk>
  547. + * Copyright (C) 2018 Antonio Diaz Diaz
  548. + *
  549. + * This program is free software; you can redistribute it and/or
  550. + * modify it under the terms of the GNU General Public License
  551. + * as published by the Free Software Foundation; either version 2,
  552. + * or (at your option) any later version.
  553. + *
  554. + * This program is distributed in the hope that it will be useful,
  555. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  556. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  557. + * GNU General Public License for more details.
  558. + *
  559. + * You should have received a copy of the GNU General Public License
  560. + * along with this program; if not, write to the Free Software
  561. + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  562. + *
  563. + * lzip_wrapper.h
  564. + *
  565. + */
  566. +
  567. +#ifndef linux
  568. +#define __BYTE_ORDER BYTE_ORDER
  569. +#define __BIG_ENDIAN BIG_ENDIAN
  570. +#define __LITTLE_ENDIAN LITTLE_ENDIAN
  571. +#else
  572. +#include <endian.h>
  573. +#endif
  574. +
  575. +#if __BYTE_ORDER == __BIG_ENDIAN
  576. +extern unsigned int inswap_le32(unsigned int);
  577. +
  578. +#define SQUASHFS_INSWAP_COMP_OPTS(s) { \
  579. + (s)->dictionary_size = inswap_le32((s)->dictionary_size); \
  580. +}
  581. +#else
  582. +#define SQUASHFS_INSWAP_COMP_OPTS(s)
  583. +#endif
  584. +
  585. +/* Default compression */
  586. +#define LZIP_DEFAULT_COMPRESSION_LEVEL 9
  587. +
  588. +struct lzip_comp_opts {
  589. + int32_t dictionary_size;
  590. + uint8_t compression_level;
  591. +};
  592. +
  593. +struct lzip_stream {
  594. + int dictionary_size;
  595. + short match_len_limit;
  596. +};
  597. +#endif
  598. diff -urdN squashfs-tools-4.4/squashfs-tools/squashfs_fs.h squashfs-tools-4.4.new/squashfs-tools/squashfs_fs.h
  599. --- squashfs-tools-4.4/squashfs-tools/squashfs_fs.h 2019-08-29 03:58:04.000000000 +0200
  600. +++ squashfs-tools-4.4.new/squashfs-tools/squashfs_fs.h 2019-09-07 18:22:09.000000000 +0200
  601. @@ -285,6 +285,7 @@
  602. #define XZ_COMPRESSION 4
  603. #define LZ4_COMPRESSION 5
  604. #define ZSTD_COMPRESSION 6
  605. +#define LZIP_COMPRESSION 7
  606. struct squashfs_super_block {
  607. unsigned int s_magic;