From 8cc0ed034504b744e6b1dd1af5db86bb97968097 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 23 Jun 2019 10:38:08 +0200 Subject: Add block size and device block size options to tar2sqfs Signed-off-by: David Oberhollenzer --- tar/tar2sqfs.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'tar') diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c index 8592fcb..8c55ea3 100644 --- a/tar/tar2sqfs.c +++ b/tar/tar2sqfs.c @@ -20,15 +20,17 @@ static struct option long_opts[] = { { "compressor", required_argument, NULL, 'c' }, - { "comp-extra", required_argument, NULL, 'X' }, + { "block-size", required_argument, NULL, 'b' }, + { "dev-block-size", required_argument, NULL, 'B' }, { "defaults", required_argument, NULL, 'd' }, + { "comp-extra", required_argument, NULL, 'X' }, { "force", no_argument, NULL, 'f' }, { "quiet", no_argument, NULL, 'q' }, { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, }; -static const char *short_opts = "c:X:d:fqhV"; +static const char *short_opts = "c:b:B:d:X:fqhV"; static const char *usagestr = "Usage: tar2sqfs [OPTIONS...] \n" @@ -43,6 +45,10 @@ static const char *usagestr = " --comp-extra, -X A comma seperated list of extra options for\n" " the selected compressor. Specify 'help' to\n" " get a list of available options.\n" +" --block-size, -b Block size to use for Squashfs image.\n" +" Defaults to %u.\n" +" --dev-block-size, -B Device block size to padd the image to.\n" +" Defaults to %u.\n" " --defaults, -d A comma seperated list of default values for\n" " implicitly created directories.\n" "\n" @@ -86,6 +92,17 @@ static void process_args(int argc, char **argv) break; switch (i) { + case 'b': + block_size = strtol(optarg, NULL, 0); + break; + case 'B': + devblksize = strtol(optarg, NULL, 0); + if (devblksize < 1024) { + fputs("Device block size must be at " + "least 1024\n", stderr); + exit(EXIT_FAILURE); + } + break; case 'c': have_compressor = true; @@ -114,7 +131,8 @@ static void process_args(int argc, char **argv) quiet = true; break; case 'h': - fputs(usagestr, stdout); + printf(help_string, SQFS_DEFAULT_BLOCK_SIZE, + SQFS_DEVBLK_SIZE); compressor_print_available(); exit(EXIT_SUCCESS); case 'V': -- cgit v1.2.3