2 +++ b/squashfs-tools/lzma_xz_options.h
4 +#ifndef LZMA_XZ_OPTIONS_H
5 +#define LZMA_XZ_OPTIONS_H
8 + * Jonas Gorski <jonas.gorski@gmail.com>
10 + * This program is free software; you can redistribute it and/or
11 + * modify it under the terms of the GNU General Public License
12 + * as published by the Free Software Foundation; either version 2,
13 + * or (at your option) any later version.
15 + * This program is distributed in the hope that it will be useful,
16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 + * GNU General Public License for more details.
20 + * You should have received a copy of the GNU General Public License
21 + * along with this program; if not, write to the Free Software
22 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 +#define __BYTE_ORDER BYTE_ORDER
31 +#define __BIG_ENDIAN BIG_ENDIAN
32 +#define __LITTLE_ENDIAN LITTLE_ENDIAN
41 +#define LZMA_OPT_FLT_MASK 0xffff
42 +#define LZMA_OPT_PRE_OFF 16
43 +#define LZMA_OPT_PRE_MASK (0xf << LZMA_OPT_PRE_OFF)
44 +#define LZMA_OPT_EXTREME 20
46 +#define LZMA_OPT_LC_OFF 0
47 +#define LZMA_OPT_LC_MASK (0x7 << LZMA_OPT_LC_OFF)
48 +#define LZMA_OPT_LP_OFF 3
49 +#define LZMA_OPT_LP_MASK (0x7 << LZMA_OPT_LP_OFF)
50 +#define LZMA_OPT_PB_OFF 6
51 +#define LZMA_OPT_PB_MASK (0x7 << LZMA_OPT_PB_OFF)
56 +#if __BYTE_ORDER == __BIG_ENDIAN
57 +extern unsigned int inswap_le32(unsigned int);
59 +#define SQUASHFS_INSWAP_LZMA_COMP_OPTS(s) { \
60 + (s)->flags = inswap_le32((s)->flags); \
61 + (s)->bit_opts = inswap_le16((s)->bit_opts); \
62 + (s)->fb = inswap_le16((s)->fb); \
63 + (s)->dict_size = inswap_le32((s)->dict_size); \
66 +#define SQUASHFS_INSWAP_LZMA_COMP_OPTS(s)
69 +#define MEMLIMIT (32 * 1024 * 1024)
71 +#define LZMA_OPT_LC_MIN 0
72 +#define LZMA_OPT_LC_MAX 4
73 +#define LZMA_OPT_LC_DEFAULT 3
75 +#define LZMA_OPT_LP_MIN 0
76 +#define LZMA_OPT_LP_MAX 4
77 +#define LZMA_OPT_LP_DEFAULT 0
79 +#define LZMA_OPT_PB_MIN 0
80 +#define LZMA_OPT_PB_MAX 4
81 +#define LZMA_OPT_PB_DEFAULT 2
83 +#define LZMA_OPT_FB_MIN 5
84 +#define LZMA_OPT_FB_MAX 273
85 +#define LZMA_OPT_FB_DEFAULT 64
92 +struct lzma_xz_options {
103 +struct lzma_xz_options *lzma_xz_get_options(void);
105 +int lzma_xz_options(char *argv[], int argc, int lzmaver);
107 +int lzma_xz_options_post(int block_size, int lzmaver);
109 +void *lzma_xz_dump_options(int block_size, int *size, int flags);
111 +int lzma_xz_extract_options(int block_size, void *buffer, int size, int lzmaver);
113 +void lzma_xz_usage(int lzmaver);
117 +++ b/squashfs-tools/lzma_xz_options.c
120 + * Copyright (c) 2011
121 + * Jonas Gorski <jonas.gorski@gmail.com>
123 + * This program is free software; you can redistribute it and/or
124 + * modify it under the terms of the GNU General Public License
125 + * as published by the Free Software Foundation; either version 2,
126 + * or (at your option) any later version.
128 + * This program is distributed in the hope that it will be useful,
129 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
130 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
131 + * GNU General Public License for more details.
133 + * You should have received a copy of the GNU General Public License
134 + * along with this program; if not, write to the Free Software
135 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
139 + * Common options for LZMA1 and 2 compressors. Based on xz_wrapper.c
148 +#include "lzma_xz_options.h"
150 +static const char const *lzmaver_str[] = { "", "lzma", "xz" };
152 +static struct lzma_xz_options options = {
156 + .lc = LZMA_OPT_LC_DEFAULT,
157 + .lp = LZMA_OPT_LP_DEFAULT,
158 + .pb = LZMA_OPT_PB_DEFAULT,
159 + .fb = LZMA_OPT_FB_DEFAULT,
163 +static float lzma_dict_percent = 0;
165 +struct lzma_xz_options *lzma_xz_get_options(void)
171 +int lzma_xz_options(char *argv[], int argc, int lzmaver)
173 + const char *comp_name = lzmaver_str[lzmaver];
175 + if(strcmp(argv[0], "-Xpreset") == 0) {
179 + fprintf(stderr, "%s: -Xpreset missing preset\n", comp_name);
183 + preset = atoi(argv[1]);
185 + if (preset < 0 || preset > 9) {
186 + fprintf(stderr, "%s: -Xpreset invalid value\n", comp_name);
189 + options.preset = preset;
191 + } else if(strcmp(argv[0], "-Xe") == 0) {
192 + options.extreme = 1;
194 + } else if(strcmp(argv[0], "-Xlc") == 0) {
198 + fprintf(stderr, "%s: -Xlc missing lc\n", comp_name);
202 + lc = atoi(argv[1]);
204 + if (lc < LZMA_OPT_LC_MIN || lc > LZMA_OPT_LC_MAX) {
205 + fprintf(stderr, "%s: -Xlc invalid value\n", comp_name);
210 + } else if(strcmp(argv[0], "-Xlp") == 0) {
214 + fprintf(stderr, "%s: -Xlp missing lp\n", comp_name);
218 + lp = atoi(argv[1]);
220 + if (lp < LZMA_OPT_LP_MIN || lp > LZMA_OPT_LP_MAX) {
221 + fprintf(stderr, "%s: -Xlp invalid value\n", comp_name);
226 + } else if(strcmp(argv[0], "-Xpb") == 0) {
230 + fprintf(stderr, "%s: -Xpb missing pb\n", comp_name);
234 + pb = atoi(argv[1]);
236 + if (pb < LZMA_OPT_PB_MIN || pb > LZMA_OPT_PB_MAX) {
237 + fprintf(stderr, "%s: -Xbp invalid value\n", comp_name);
242 + } else if(strcmp(argv[0], "-Xfb") == 0) {
246 + fprintf(stderr, "%s: -Xfb missing fb\n", comp_name);
250 + fb = atoi(argv[1]);
252 + if (fb < LZMA_OPT_FB_MIN || fb > LZMA_OPT_FB_MAX) {
253 + fprintf(stderr, "%s: -Xfb invalid value\n", comp_name);
258 + } else if(strcmp(argv[0], "-Xdict-size") == 0) {
263 + fprintf(stderr, "%s: -Xdict-size missing dict-size\n", comp_name);
267 + size = strtof(argv[1], &b);
269 + if(size <= 0 || size > 100) {
270 + fprintf(stderr, "%s: -Xdict-size percentage "
271 + "should be 0 < dict-size <= 100\n", comp_name);
275 + lzma_dict_percent = size;
276 + options.dict_size = 0;
278 + if((float) ((int) size) != size) {
279 + fprintf(stderr, "%s: -Xdict-size can't be "
280 + "fractional unless a percentage of the"
281 + " block size\n", comp_name);
285 + lzma_dict_percent = 0;
286 + options.dict_size = (int) size;
288 + if(*b == 'k' || *b == 'K')
289 + options.dict_size *= 1024;
290 + else if(*b == 'm' || *b == 'M')
291 + options.dict_size *= 1024 * 1024;
292 + else if(*b != '\0') {
293 + fprintf(stderr, "%s: -Xdict-size invalid "
294 + "dict-size\n", comp_name);
309 +int lzma_xz_options_post(int block_size, int lzmaver)
311 + const char *comp_name = lzmaver_str[lzmaver];
313 + * if -Xdict-size has been specified use this to compute the datablock
316 + if(options.dict_size || lzma_dict_percent) {
317 + int dict_size_min = (lzmaver == 1 ? 4096 : 8192);
320 + if(options.dict_size) {
321 + if(options.dict_size > block_size) {
322 + fprintf(stderr, "%s: -Xdict-size is larger than"
323 + " block_size\n", comp_name);
327 + options.dict_size = block_size * lzma_dict_percent / 100;
329 + if(options.dict_size < dict_size_min) {
330 + fprintf(stderr, "%s: -Xdict-size should be %i bytes "
331 + "or larger\n", comp_name, dict_size_min);
336 + * dictionary_size must be storable in xz header as either
337 + * 2^n or as 2^n+2^(n+1)
339 + n = ffs(options.dict_size) - 1;
340 + if(options.dict_size != (1 << n) &&
341 + options.dict_size != ((1 << n) + (1 << (n + 1)))) {
342 + fprintf(stderr, "%s: -Xdict-size is an unsupported "
343 + "value, dict-size must be storable in %s "
344 + "header\n", comp_name, comp_name);
345 + fprintf(stderr, "as either 2^n or as 2^n+2^(n+1). "
346 + "Example dict-sizes are 75%%, 50%%, 37.5%%, "
348 + fprintf(stderr, "or 32K, 16K, 8K etc.\n");
353 + /* No -Xdict-size specified, use defaults */
354 + options.dict_size = block_size;
362 +static struct lzma_opts lzma_comp_opts;
364 +void *lzma_xz_dump_options(int block_size, int *size, int flags)
366 + /* No need to store default options */
367 + if (options.preset == 6 &&
368 + options.extreme == 0 &&
369 + options.lc == LZMA_OPT_LC_DEFAULT &&
370 + options.lp == LZMA_OPT_LC_DEFAULT &&
371 + options.pb == LZMA_OPT_PB_DEFAULT &&
373 + options.dict_size == block_size &&
377 + *size = sizeof(struct lzma_opts);
379 + lzma_comp_opts.flags |= flags;
381 + if (options.extreme)
382 + lzma_comp_opts.flags |= LZMA_OPT_EXTREME;
384 + lzma_comp_opts.flags |= ((options.preset << LZMA_OPT_PRE_OFF) & LZMA_OPT_PRE_MASK);
386 + lzma_comp_opts.bit_opts =
387 + ((options.lc << LZMA_OPT_LC_OFF) & LZMA_OPT_LC_MASK) |
388 + ((options.lp << LZMA_OPT_LP_OFF) & LZMA_OPT_LP_MASK) |
389 + ((options.pb << LZMA_OPT_PB_OFF) & LZMA_OPT_PB_MASK);
390 + lzma_comp_opts.fb = options.fb;
391 + lzma_comp_opts.dict_size = options.dict_size;
393 + SQUASHFS_INSWAP_LZMA_COMP_OPTS(&lzma_comp_opts);
395 + return &lzma_comp_opts;
398 +int lzma_xz_extract_options(int block_size, void *buffer, int size, int lzmaver)
401 + /* default options */
402 + options.preset = 6;
403 + options.extreme = 0;
404 + options.lc = LZMA_OPT_LC_DEFAULT;
405 + options.lp = LZMA_OPT_LC_DEFAULT;
406 + options.pb = LZMA_OPT_PB_DEFAULT;
407 + options.fb = LZMA_OPT_FB_DEFAULT;
408 + options.dict_size = block_size;
411 + struct lzma_opts *comp_opts = buffer;
414 + if (size != sizeof(struct lzma_opts))
417 + SQUASHFS_INSWAP_LZMA_COMP_OPTS(&comp_opts);
419 + options.flags = comp_opts->flags & LZMA_OPT_FLT_MASK;
420 + options.preset = (comp_opts->flags & LZMA_OPT_PRE_MASK) >> LZMA_OPT_PRE_OFF;
421 + options.extreme = !!(comp_opts->flags & LZMA_OPT_EXTREME);
423 + options.lc = (comp_opts->bit_opts & LZMA_OPT_LC_MASK) >> LZMA_OPT_LC_OFF;
424 + options.lp = (comp_opts->bit_opts & LZMA_OPT_LP_MASK) >> LZMA_OPT_LP_OFF;
425 + options.pb = (comp_opts->bit_opts & LZMA_OPT_PB_MASK) >> LZMA_OPT_PB_OFF;
426 + options.fb = comp_opts->fb;
427 + options.dict_size = comp_opts->dict_size;
429 + /* check that the LZMA bit options are in range */
430 + if (options.lc < LZMA_OPT_LC_MIN || options.lc > LZMA_OPT_LC_MAX ||
431 + options.lp < LZMA_OPT_LP_MIN || options.lp > LZMA_OPT_LP_MAX ||
432 + options.pb < LZMA_OPT_PB_MIN || options.pb > LZMA_OPT_PB_MAX ||
433 + options.fb < LZMA_OPT_FB_MIN || options.fb > LZMA_OPT_FB_MAX)
437 + * check that the dictionary size seems correct - the dictionary
438 + * size should 2^n or 2^n+2^(n+1)
440 + n = ffs(options.dict_size) - 1;
441 + if(options.dict_size != (1 << n) &&
442 + options.dict_size != ((1 << n) + (1 << (n + 1))))
450 + fprintf(stderr, "%s: error reading stored compressor options from "
451 + "filesystem!\n", lzmaver_str[lzmaver]);
455 +void lzma_xz_usage(int lzmaver)
457 + fprintf(stderr, "\t -Xpreset <preset>\n");
458 + fprintf(stderr, "\t\tcompression preset (0-9, default 6)\n");
459 + fprintf(stderr, "\t -Xe\n");
460 + fprintf(stderr, "\t\tTry to improve compression ratio by using more ");
461 + fprintf(stderr, "CPU time.\n");
462 + fprintf(stderr, "\t -Xlc <lc>\n");
463 + fprintf(stderr, "\t\tNumber of literal context bits (0-4, default 3)\n");
464 + fprintf(stderr, "\t -Xlp <lp>\n");
465 + fprintf(stderr, "\t\tNumber of literal position bits (0-4, default 0)\n");
466 + fprintf(stderr, "\t -Xpb <pb>\n");
467 + fprintf(stderr, "\t\tNumber of position bits (0-4, default 2)\n");
468 + fprintf(stderr, "\t -Xnice <nice>\n");
469 + fprintf(stderr, "\t\tNice length of a match (5-273, default 64)\n");
470 + fprintf(stderr, "\t -Xdict-size <dict-size>\n");
471 + fprintf(stderr, "\t\tUse <dict-size> as the %s dictionary size. The",
472 + lzmaver == LZMA_OPT_LZMA ? "LZMA" : "XZ");
473 + fprintf(stderr, " dictionary size\n\t\tcan be specified as a");
474 + fprintf(stderr, " percentage of the block size, or as an\n\t\t");
475 + fprintf(stderr, "absolute value. The dictionary size must be less");
476 + fprintf(stderr, " than or equal\n\t\tto the block size and %d bytes",
477 + lzmaver == LZMA_OPT_LZMA ? 4096 : 8192);
478 + fprintf(stderr, " or larger. It must also be\n\t\tstorable in the lzma");
479 + fprintf(stderr, " header as either 2^n or as 2^n+2^(n+1).\n\t\t");
480 + fprintf(stderr, "Example dict-sizes are 75%%, 50%%, 37.5%%, 25%%, or");
481 + fprintf(stderr, " 32K, 16K, 8K\n\t\tetc.\n");
484 --- a/squashfs-tools/lzma_xz_wrapper.c
485 +++ b/squashfs-tools/lzma_xz_wrapper.c
488 #include "squashfs_fs.h"
489 #include "compressor.h"
490 +#include "lzma_xz_options.h"
492 #define LZMA_PROPS_SIZE 5
493 #define LZMA_UNCOMP_SIZE 8
495 static int lzma_compress(void *dummy, void *dest, void *src, int size,
496 int block_size, int *error)
499 unsigned char *d = (unsigned char *) dest;
500 + struct lzma_xz_options *opts = lzma_xz_get_options();
502 lzma_options_lzma opt;
503 lzma_stream strm = LZMA_STREAM_INIT;
506 - lzma_lzma_preset(&opt, LZMA_OPTIONS);
507 - opt.dict_size = block_size;
508 + preset = opts->preset;
511 + preset |= LZMA_PRESET_EXTREME;
513 + lzma_lzma_preset(&opt, opts->preset);
518 + opt.nice_len = opts->fb;
520 + opt.dict_size = opts->dict_size;
522 res = lzma_alone_encoder(&strm, &opt);
524 @@ -143,13 +158,45 @@ failed:
528 +static int lzma_options(char *argv[], int argc)
530 + return lzma_xz_options(argv, argc, LZMA_OPT_LZMA);
534 +static int lzma_options_post(int block_size)
536 + return lzma_xz_options_post(block_size, LZMA_OPT_LZMA);
540 +static void *lzma_dump_options(int block_size, int *size)
542 + return lzma_xz_dump_options(block_size, size, 0);
546 +static int lzma_extract_options(int block_size, void *buffer, int size)
548 + return lzma_xz_extract_options(block_size, buffer, size, LZMA_OPT_LZMA);
554 + lzma_xz_usage(LZMA_OPT_LZMA);
558 struct compressor lzma_comp_ops = {
560 .compress = lzma_compress,
561 .uncompress = lzma_uncompress,
564 + .options = lzma_options,
565 + .options_post = lzma_options_post,
566 + .dump_options = lzma_dump_options,
567 + .extract_options = lzma_extract_options,
568 + .usage = lzma_usage,
569 .id = LZMA_COMPRESSION,
572 --- a/squashfs-tools/xz_wrapper.h
573 +++ b/squashfs-tools/xz_wrapper.h
579 -#define __BYTE_ORDER BYTE_ORDER
580 -#define __BIG_ENDIAN BIG_ENDIAN
581 -#define __LITTLE_ENDIAN LITTLE_ENDIAN
586 -#if __BYTE_ORDER == __BIG_ENDIAN
587 -extern unsigned int inswap_le32(unsigned int);
589 -#define SQUASHFS_INSWAP_COMP_OPTS(s) { \
590 - (s)->dictionary_size = inswap_le32((s)->dictionary_size); \
591 - (s)->flags = inswap_le32((s)->flags); \
594 -#define SQUASHFS_INSWAP_COMP_OPTS(s)
597 #define MEMLIMIT (32 * 1024 * 1024)
600 --- a/squashfs-tools/xz_wrapper.c
601 +++ b/squashfs-tools/xz_wrapper.c
603 #include "squashfs_fs.h"
604 #include "xz_wrapper.h"
605 #include "compressor.h"
606 +#include "lzma_xz_options.h"
608 static struct bcj bcj[] = {
609 { "x86", LZMA_FILTER_X86, 0 },
610 @@ -41,22 +42,18 @@ static struct bcj bcj[] = {
611 { NULL, LZMA_VLI_UNKNOWN, 0 }
614 -static struct comp_opts comp_opts;
616 static int filter_count = 1;
617 -static int dictionary_size = 0;
618 -static float dictionary_percent = 0;
621 static int xz_options(char *argv[], int argc)
626 if(strcmp(argv[0], "-Xbcj") == 0) {
631 fprintf(stderr, "xz: -Xbcj missing filter\n");
637 @@ -76,190 +73,50 @@ static int xz_options(char *argv[], int
639 if(bcj[i].name == NULL) {
640 fprintf(stderr, "xz: -Xbcj unrecognised "
647 - } else if(strcmp(argv[0], "-Xdict-size") == 0) {
652 - fprintf(stderr, "xz: -Xdict-size missing dict-size\n");
656 - size = strtof(argv[1], &b);
658 - if(size <= 0 || size > 100) {
659 - fprintf(stderr, "xz: -Xdict-size percentage "
660 - "should be 0 < dict-size <= 100\n");
664 - dictionary_percent = size;
665 - dictionary_size = 0;
667 - if((float) ((int) size) != size) {
668 - fprintf(stderr, "xz: -Xdict-size can't be "
669 - "fractional unless a percentage of the"
674 - dictionary_percent = 0;
675 - dictionary_size = (int) size;
677 - if(*b == 'k' || *b == 'K')
678 - dictionary_size *= 1024;
679 - else if(*b == 'm' || *b == 'M')
680 - dictionary_size *= 1024 * 1024;
681 - else if(*b != '\0') {
682 - fprintf(stderr, "xz: -Xdict-size invalid "
692 + return lzma_xz_options(argv, argc, LZMA_OPT_XZ);
702 static int xz_options_post(int block_size)
705 - * if -Xdict-size has been specified use this to compute the datablock
708 - if(dictionary_size || dictionary_percent) {
711 - if(dictionary_size) {
712 - if(dictionary_size > block_size) {
713 - fprintf(stderr, "xz: -Xdict-size is larger than"
718 - dictionary_size = block_size * dictionary_percent / 100;
720 - if(dictionary_size < 8192) {
721 - fprintf(stderr, "xz: -Xdict-size should be 8192 bytes "
727 - * dictionary_size must be storable in xz header as either
728 - * 2^n or as 2^n+2^(n+1)
730 - n = ffs(dictionary_size) - 1;
731 - if(dictionary_size != (1 << n) &&
732 - dictionary_size != ((1 << n) + (1 << (n + 1)))) {
733 - fprintf(stderr, "xz: -Xdict-size is an unsupported "
734 - "value, dict-size must be storable in xz "
736 - fprintf(stderr, "as either 2^n or as 2^n+2^(n+1). "
737 - "Example dict-sizes are 75%%, 50%%, 37.5%%, "
739 - fprintf(stderr, "or 32K, 16K, 8K etc.\n");
744 - /* No -Xdict-size specified, use defaults */
745 - dictionary_size = block_size;
751 + return lzma_xz_options_post(block_size, LZMA_OPT_XZ);
755 static void *xz_dump_options(int block_size, int *size)
760 - * don't store compressor specific options in file system if the
761 - * default options are being used - no compressor options in the
762 - * file system means the default options are always assumed
765 - * metadata dictionary size: SQUASHFS_METADATA_SIZE
766 - * datablock dictionary size: block_size
769 - if(dictionary_size == block_size && filter_count == 1)
773 for(i = 0; bcj[i].name; i++)
774 flags |= bcj[i].selected << i;
776 - comp_opts.dictionary_size = dictionary_size;
777 - comp_opts.flags = flags;
779 - SQUASHFS_INSWAP_COMP_OPTS(&comp_opts);
781 - *size = sizeof(comp_opts);
783 + return lzma_xz_dump_options(block_size, size, flags);
787 static int xz_extract_options(int block_size, void *buffer, int size)
789 - struct comp_opts *comp_opts = buffer;
794 - dictionary_size = block_size;
797 - /* check passed comp opts struct is of the correct length */
798 - if(size != sizeof(struct comp_opts))
801 - SQUASHFS_INSWAP_COMP_OPTS(comp_opts);
803 - dictionary_size = comp_opts->dictionary_size;
804 - flags = comp_opts->flags;
807 - * check that the dictionary size seems correct - the dictionary
808 - * size should 2^n or 2^n+2^(n+1)
810 - n = ffs(dictionary_size) - 1;
811 - if(dictionary_size != (1 << n) &&
812 - dictionary_size != ((1 << n) + (1 << (n + 1))))
815 + int ret = lzma_xz_extract_options(block_size, buffer, size, LZMA_OPT_XZ);
818 - for(i = 0; bcj[i].name; i++) {
819 - if((flags >> i) & 1) {
820 - bcj[i].selected = 1;
823 - bcj[i].selected = 0;
826 + struct lzma_xz_options *opts = lzma_xz_get_options();
827 + for(i = 0; bcj[i].name; i++) {
828 + if((opts->flags >> i) & 1) {
829 + bcj[i].selected = 1;
832 + bcj[i].selected = 0;
839 - fprintf(stderr, "xz: error reading stored compressor options from "
847 @@ -268,6 +125,7 @@ static int xz_init(void **strm, int bloc
848 int i, j, filters = datablock ? filter_count : 1;
849 struct filter *filter = malloc(filters * sizeof(struct filter));
850 struct xz_stream *stream;
851 + struct lzma_xz_options *opts = lzma_xz_get_options();
855 @@ -281,7 +139,7 @@ static int xz_init(void **strm, int bloc
857 memset(filter, 0, filters * sizeof(struct filter));
859 - stream->dictionary_size = datablock ? dictionary_size :
860 + stream->dictionary_size = datablock ? opts->dict_size :
861 SQUASHFS_METADATA_SIZE;
863 filter[0].filter[0].id = LZMA_FILTER_LZMA2;
864 @@ -323,14 +181,25 @@ static int xz_compress(void *strm, void
866 struct xz_stream *stream = strm;
867 struct filter *selected = NULL;
868 + struct lzma_xz_options *opts = lzma_xz_get_options();
870 stream->filter[0].buffer = dest;
872 for(i = 0; i < stream->filters; i++) {
873 + uint32_t preset = opts->preset;
874 struct filter *filter = &stream->filter[i];
876 - if(lzma_lzma_preset(&stream->opt, LZMA_PRESET_DEFAULT))
879 + preset |= LZMA_PRESET_EXTREME;
881 + if(lzma_lzma_preset(&stream->opt, preset))
884 + stream->opt.lc = opts->lc;
885 + stream->opt.lp = opts->lp;
886 + stream->opt.pb = opts->pb;
888 + stream->opt.nice_len = opts->fb;
890 stream->opt.dict_size = stream->dictionary_size;
892 @@ -384,22 +253,13 @@ static int xz_uncompress(void *dest, voi
896 + lzma_xz_usage(LZMA_OPT_XZ);
897 fprintf(stderr, "\t -Xbcj filter1,filter2,...,filterN\n");
898 fprintf(stderr, "\t\tCompress using filter1,filter2,...,filterN in");
899 fprintf(stderr, " turn\n\t\t(in addition to no filter), and choose");
900 fprintf(stderr, " the best compression.\n");
901 fprintf(stderr, "\t\tAvailable filters: x86, arm, armthumb,");
902 fprintf(stderr, " powerpc, sparc, ia64\n");
903 - fprintf(stderr, "\t -Xdict-size <dict-size>\n");
904 - fprintf(stderr, "\t\tUse <dict-size> as the XZ dictionary size. The");
905 - fprintf(stderr, " dictionary size\n\t\tcan be specified as a");
906 - fprintf(stderr, " percentage of the block size, or as an\n\t\t");
907 - fprintf(stderr, "absolute value. The dictionary size must be less");
908 - fprintf(stderr, " than or equal\n\t\tto the block size and 8192 bytes");
909 - fprintf(stderr, " or larger. It must also be\n\t\tstorable in the xz");
910 - fprintf(stderr, " header as either 2^n or as 2^n+2^(n+1).\n\t\t");
911 - fprintf(stderr, "Example dict-sizes are 75%%, 50%%, 37.5%%, 25%%, or");
912 - fprintf(stderr, " 32K, 16K, 8K\n\t\tetc.\n");
916 --- a/squashfs-tools/Makefile
917 +++ b/squashfs-tools/Makefile
918 @@ -140,6 +140,8 @@ COMPRESSORS += xz
921 ifneq ($(LZMA_XZ_SUPPORT)$(XZ_SUPPORT),)
922 +MKSQUASHFS_OBJS += lzma_xz_options.o
923 +UNSQUASHFS_OBJS += lzma_xz_options.o
925 MKSQUASHFS_OBJS += $(LZMA_LIB)
926 UNSQUASHFS_OBJS += $(LZMA_LIB)