diff options
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/sqfs2tar/Makemodule.am | 6 | ||||
| -rw-r--r-- | bin/sqfs2tar/options.c | 37 | ||||
| -rw-r--r-- | bin/sqfs2tar/sqfs2tar.c | 6 | ||||
| -rw-r--r-- | bin/sqfs2tar/sqfs2tar.h | 1 | 
4 files changed, 47 insertions, 3 deletions
diff --git a/bin/sqfs2tar/Makemodule.am b/bin/sqfs2tar/Makemodule.am index cd00508..9dbfbbb 100644 --- a/bin/sqfs2tar/Makemodule.am +++ b/bin/sqfs2tar/Makemodule.am @@ -4,7 +4,11 @@ sqfs2tar_SOURCES += bin/sqfs2tar/xattr.c  sqfs2tar_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS)  sqfs2tar_LDADD = libcommon.a libutil.a libsquashfs.la libtar.a  sqfs2tar_LDADD += libfstream.a libcompat.a libfstree.a -sqfs2tar_LDADD += $(LZO_LIBS) $(PTHREAD_LIBS) +sqfs2tar_LDADD += $(ZLIB_LIBS) $(XZ_LIBS) $(LZO_LIBS) $(PTHREAD_LIBS) + +if WITH_OWN_ZLIB +sqfs2tar_LDADD += libz.la +endif  dist_man1_MANS += bin/sqfs2tar/sqfs2tar.1  bin_PROGRAMS += sqfs2tar diff --git a/bin/sqfs2tar/options.c b/bin/sqfs2tar/options.c index e5c8319..356913a 100644 --- a/bin/sqfs2tar/options.c +++ b/bin/sqfs2tar/options.c @@ -7,6 +7,7 @@  #include "sqfs2tar.h"  static struct option long_opts[] = { +	{ "compressor", required_argument, NULL, 'c' },  	{ "subdir", required_argument, NULL, 'd' },  	{ "keep-as-dir", no_argument, NULL, 'k' },  	{ "root-becomes", required_argument, NULL, 'r' }, @@ -18,7 +19,7 @@ static struct option long_opts[] = {  	{ NULL, 0, NULL, 0 },  }; -static const char *short_opts = "d:kr:sXLhV"; +static const char *short_opts = "c:d:kr:sXLhV";  static const char *usagestr =  "Usage: sqfs2tar [OPTIONS...] <sqfsfile>\n" @@ -28,6 +29,9 @@ static const char *usagestr =  "\n"  "Possible options:\n"  "\n" +"  --compressor, -c <name>   If set, stream compress the resulting tarball.\n" +"                            By default, the tarball is uncompressed.\n" +"\n"  "  --subdir, -d <dir>        Unpack the given sub directory instead of the\n"  "                            filesystem root. Can be specified more than\n"  "                            once to select multiple directories. If only\n" @@ -63,7 +67,8 @@ static const char *usagestr =  "\tsqfs2tar rootfs.sqfs > rootfs.tar\n"  "\tsqfs2tar rootfs.sqfs | gzip > rootfs.tar.gz\n"  "\tsqfs2tar rootfs.sqfs | xz > rootfs.tar.xz\n" -"\n"; +"\n" +"Available compressors:\n";  bool dont_skip = false;  bool keep_as_dir = false; @@ -74,12 +79,14 @@ char *root_becomes = NULL;  char **subdirs = NULL;  size_t num_subdirs = 0;  static size_t max_subdirs = 0; +int compressor = 0;  const char *filename = NULL;  void process_args(int argc, char **argv)  {  	size_t idx, new_count; +	const char *name;  	int i, ret;  	void *new; @@ -89,6 +96,21 @@ void process_args(int argc, char **argv)  			break;  		switch (i) { +		case 'c': +			compressor = fstream_compressor_id_from_name(optarg); +			if (compressor <= 0) { +				fprintf(stderr, "unknown compressor '%s'.\n", +					optarg); +				goto fail; +			} + +			if (!fstream_compressor_exists(compressor)) { +				fprintf(stderr, +					"%s compressor is not supported.\n", +					optarg); +				goto fail; +			} +			break;  		case 'd':  			if (num_subdirs == max_subdirs) {  				new_count = max_subdirs ? max_subdirs * 2 : 16; @@ -146,6 +168,17 @@ void process_args(int argc, char **argv)  			break;  		case 'h':  			fputs(usagestr, stdout); + +			i = FSTREAM_COMPRESSOR_MIN; + +			while (i <= FSTREAM_COMPRESSOR_MAX) { +				name = fstream_compressor_name_from_id(i); +				if (fstream_compressor_exists(i)) +					printf("\t%s\n", name); +				++i; +			} + +			fputc('\n', stdout);  			goto out_success;  		case 'V':  			print_version("sqfs2tar"); diff --git a/bin/sqfs2tar/sqfs2tar.c b/bin/sqfs2tar/sqfs2tar.c index c5d1201..00d1e27 100644 --- a/bin/sqfs2tar/sqfs2tar.c +++ b/bin/sqfs2tar/sqfs2tar.c @@ -123,6 +123,12 @@ int main(int argc, char **argv)  		goto out_dirs;  	} +	if (compressor > 0) { +		out_file = ostream_compressor_create(out_file, compressor); +		if (out_file == NULL) +			goto out_dirs; +	} +  	file = sqfs_open_file(filename, SQFS_FILE_OPEN_READ_ONLY);  	if (file == NULL) {  		perror(filename); diff --git a/bin/sqfs2tar/sqfs2tar.h b/bin/sqfs2tar/sqfs2tar.h index 70f51ef..1986c56 100644 --- a/bin/sqfs2tar/sqfs2tar.h +++ b/bin/sqfs2tar/sqfs2tar.h @@ -28,6 +28,7 @@ extern bool no_links;  extern char *root_becomes;  extern char **subdirs;  extern size_t num_subdirs; +extern int compressor;  extern const char *filename;  | 
