diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-04-30 10:50:13 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-05-02 12:40:06 +0200 |
commit | a85c6025903a2b6e97e1938b201b3361a0cbed66 (patch) | |
tree | cf92df4ba782c4b9c4a49dcf1cc3e25f849723a9 /mkfs/options.c | |
parent | fa7f378bf627ddcfd7a93a000149e4d8c3810bf5 (diff) |
Add compressor library
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs/options.c')
-rw-r--r-- | mkfs/options.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/mkfs/options.c b/mkfs/options.c index 513e76a..e3371aa 100644 --- a/mkfs/options.c +++ b/mkfs/options.c @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: GPL-3.0-or-later */ +#include "compress.h" #include "squashfs.h" #include "options.h" #include "config.h" @@ -221,6 +222,7 @@ static void process_defaults(options_t *opt, char *subopts) void process_command_line(options_t *opt, int argc, char **argv) { + bool have_compressor; int i; opt->def_uid = 0; @@ -241,12 +243,23 @@ void process_command_line(options_t *opt, int argc, char **argv) switch (i) { case 'c': + have_compressor = false; + for (i = SQFS_COMP_MIN; i <= SQFS_COMP_MAX; ++i) { if (strcmp(compressors[i], optarg) == 0) { - opt->compressor = i; - break; + if (compressor_exists(i)) { + have_compressor = true; + opt->compressor = i; + break; + } } } + + if (!have_compressor) { + fprintf(stderr, "Unsupported compressor '%s'\n", + optarg); + exit(EXIT_FAILURE); + } break; case 'b': opt->blksz = read_number("Block size", optarg, @@ -268,8 +281,10 @@ void process_command_line(options_t *opt, int argc, char **argv) fputs("Available compressors:\n", stdout); - for (i = SQFS_COMP_MIN; i <= SQFS_COMP_MAX; ++i) - printf("\t%s\n", compressors[i]); + for (i = SQFS_COMP_MIN; i <= SQFS_COMP_MAX; ++i) { + if (compressor_exists(i)) + printf("\t%s\n", compressors[i]); + } exit(EXIT_SUCCESS); case 'V': |