From a7d22b83cf70eb500f52edb625e9c719a35b0134 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 20 Aug 2019 21:01:59 +0200 Subject: Change CLI of sqfsdiff to specify images through long options Signed-off-by: David Oberhollenzer --- difftool/sqfsdiff.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'difftool/sqfsdiff.c') diff --git a/difftool/sqfsdiff.c b/difftool/sqfsdiff.c index 4754557..baebc25 100644 --- a/difftool/sqfsdiff.c +++ b/difftool/sqfsdiff.c @@ -7,6 +7,8 @@ #include "difftool.h" static struct option long_opts[] = { + { "old", required_argument, NULL, 'a' }, + { "new", required_argument, NULL, 'b' }, { "no-owner", no_argument, NULL, 'O' }, { "no-permissions", no_argument, NULL, 'P' }, { "no-contents", no_argument, NULL, 'C' }, @@ -18,10 +20,10 @@ static struct option long_opts[] = { { "version", no_argument, NULL, 'V' }, }; -static const char *short_opts = "OPCTISe:hV"; +static const char *short_opts = "a:b:OPCTISe:hV"; static const char *usagestr = -"Usage: sqfsdiff [OPTIONS...] \n" +"Usage: sqfsdiff [OPTIONS...] --old,-a --new,-b \n" "\n" "Compare two squashfs images. In contrast to doing a direct diff of the\n" "images, this actually parses the filesystems and generates a more\n" @@ -38,6 +40,9 @@ static const char *usagestr = "\n" "Possible options:\n" "\n" +" --old, -a The first of the two images to compare.\n" +" --new, -b The second of the two images to compare.\n" +"\n" " --no-contents, -C Do not compare file contents.\n" " --no-owner, -O Do not compare file owners.\n" " --no-permissions, -P Do not compare permission bits.\n" @@ -73,6 +78,12 @@ static void process_options(int argc, char **argv) break; switch (i) { + case 'a': + first_path = optarg; + break; + case 'b': + second_path = optarg; + break; case 'O': compare_flags |= COMPARE_NO_OWNER; break; @@ -106,20 +117,16 @@ static void process_options(int argc, char **argv) } } - if (optind >= argc) { + if (first_path == NULL) { fputs("Missing arguments: first filesystem\n", stderr); goto fail_arg; } - first_path = argv[optind++]; - - if (optind >= argc) { + if (second_path == NULL) { fputs("Missing arguments: second filesystem\n", stderr); goto fail_arg; } - second_path = argv[optind++]; - if (optind < argc) { fputs("Unknown extra arguments\n", stderr); goto fail_arg; -- cgit v1.2.3