summaryrefslogtreecommitdiff
path: root/mkfs/options.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-23 02:14:52 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-23 02:37:08 +0200
commit0b22d6ad0ebed2af239259dbfa36cd9920c6f4a2 (patch)
tree0680c237006ed11fc200e9d3d4717d25455e9599 /mkfs/options.c
parent5f7a1a092495c84c4c4cd208c3c983c3f16c8951 (diff)
Move all handling of compressor names to libcompress.a
This commit removes handling of compressor names from gensquashfs. Instead, functions are added to libcompress to obtain name from ID, ID from name and to print out defaults. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs/options.c')
-rw-r--r--mkfs/options.c36
1 files changed, 7 insertions, 29 deletions
diff --git a/mkfs/options.c b/mkfs/options.c
index a746ba4..e298a6c 100644
--- a/mkfs/options.c
+++ b/mkfs/options.c
@@ -61,7 +61,6 @@ static const char *help_string =
"\n"
" --compressor, -c <name> Select the compressor to use.\n"
" A list of available compressors is below.\n"
-" Defaults to '%s'.\n"
" --comp-extra, -X <options> A comma seperated list of extra options for\n"
" the selected compressor. Specify 'help' to\n"
" get a list of available options.\n"
@@ -126,15 +125,6 @@ static const char *help_string =
" file /bin/bash 0755 0 0"
"\n\n";
-static const char *compressors[] = {
- [SQFS_COMP_GZIP] = "gzip",
- [SQFS_COMP_LZMA] = "lzma",
- [SQFS_COMP_LZO] = "lzo",
- [SQFS_COMP_XZ] = "xz",
- [SQFS_COMP_LZ4] = "lz4",
- [SQFS_COMP_ZSTD] = "zstd",
-};
-
static long read_number(const char *name, const char *str, long min, long max)
{
long result = strtol(str, NULL, 0);
@@ -217,17 +207,13 @@ void process_command_line(options_t *opt, int argc, char **argv)
switch (i) {
case 'c':
- have_compressor = false;
+ have_compressor = true;
- for (i = SQFS_COMP_MIN; i <= SQFS_COMP_MAX; ++i) {
- if (strcmp(compressors[i], optarg) == 0) {
- if (compressor_exists(i)) {
- have_compressor = true;
- opt->compressor = i;
- break;
- }
- }
- }
+ if (compressor_id_from_name(optarg, &opt->compressor))
+ have_compressor = false;
+
+ if (!compressor_exists(opt->compressor))
+ have_compressor = false;
if (!have_compressor) {
fprintf(stderr, "Unsupported compressor '%s'\n",
@@ -268,16 +254,8 @@ void process_command_line(options_t *opt, int argc, char **argv)
#endif
case 'h':
printf(help_string, __progname,
- compressors[compressor_get_default()],
SQFS_DEFAULT_BLOCK_SIZE, SQFS_DEVBLK_SIZE);
-
- fputs("Available compressors:\n", stdout);
-
- for (i = SQFS_COMP_MIN; i <= SQFS_COMP_MAX; ++i) {
- if (compressor_exists(i))
- printf("\t%s\n", compressors[i]);
- }
-
+ compressor_print_available();
exit(EXIT_SUCCESS);
case 'V':
print_version();