summaryrefslogtreecommitdiff
path: root/mkfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-04-30 10:50:13 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-02 12:40:06 +0200
commita85c6025903a2b6e97e1938b201b3361a0cbed66 (patch)
treecf92df4ba782c4b9c4a49dcf1cc3e25f849723a9 /mkfs
parentfa7f378bf627ddcfd7a93a000149e4d8c3810bf5 (diff)
Add compressor library
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs')
-rw-r--r--mkfs/Makemodule.am10
-rw-r--r--mkfs/options.c23
2 files changed, 28 insertions, 5 deletions
diff --git a/mkfs/Makemodule.am b/mkfs/Makemodule.am
index 1d062b9..ad3f166 100644
--- a/mkfs/Makemodule.am
+++ b/mkfs/Makemodule.am
@@ -1,5 +1,13 @@
mksquashfs_SOURCES = mkfs/mksquashfs.c mkfs/options.c mkfs/options.h
mksquashfs_SOURCES += include/squashfs.h
-mksquashfs_LDADD = libfstree.a
+mksquashfs_LDADD = libfstree.a libcompress.a
+
+if WITH_LZMA
+mksquashfs_LDADD += $(XZ_LIBS)
+endif
+
+if WITH_ZLIB
+mksquashfs_LDADD += $(ZLIB_LIBS)
+endif
bin_PROGRAMS += mksquashfs
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':