summaryrefslogtreecommitdiff
path: root/difftool/sqfsdiff.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-09 11:43:15 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-09 12:11:12 +0200
commitb3c3401aee91bc2ff46ba0eab0ceb88c78cb5bbb (patch)
tree097241e9080420385db37a3985c5beabe42cb57b /difftool/sqfsdiff.c
parentfd98948e840f6e67cd2d7c72f57d2fd80ed9a418 (diff)
Add option to sqfsdiff to extract regular files that are different
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'difftool/sqfsdiff.c')
-rw-r--r--difftool/sqfsdiff.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/difftool/sqfsdiff.c b/difftool/sqfsdiff.c
index 8818a37..4754557 100644
--- a/difftool/sqfsdiff.c
+++ b/difftool/sqfsdiff.c
@@ -13,11 +13,12 @@ static struct option long_opts[] = {
{ "timestamps", no_argument, NULL, 'T' },
{ "inode-num", no_argument, NULL, 'I' },
{ "super", no_argument, NULL, 'S' },
+ { "extract", required_argument, NULL, 'e' },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
};
-static const char *short_opts = "OPCTIShV";
+static const char *short_opts = "OPCTISe:hV";
static const char *usagestr =
"Usage: sqfsdiff [OPTIONS...] <first> <second>\n"
@@ -45,6 +46,11 @@ static const char *usagestr =
" --inode-num, -I Compare inode numbers of all files.\n"
" --super, -S Also compare metadata in super blocks.\n"
"\n"
+" --extract, -e <path> Extract files that differ to the specified\n"
+" directory. Contents of the first image end up\n"
+" in a subdirectory 'a' and of the second image\n"
+" in a subdirectory 'b'.\n"
+"\n"
" --help, -h Print help text and exit.\n"
" --version, -V Print version information and exit.\n"
"\n";
@@ -55,6 +61,7 @@ const char *second_path;
sqfs_reader_t sqfs_a;
sqfs_reader_t sqfs_b;
static bool compare_super = false;
+static const char *extract_dir;
static void process_options(int argc, char **argv)
{
@@ -84,6 +91,10 @@ static void process_options(int argc, char **argv)
case 'S':
compare_super = true;
break;
+ case 'e':
+ compare_flags |= COMPARE_EXTRACT_FILES;
+ extract_dir = optarg;
+ break;
case 'h':
fputs(usagestr, stdout);
exit(EXIT_SUCCESS);
@@ -125,6 +136,11 @@ int main(int argc, char **argv)
process_options(argc, argv);
+ if (extract_dir != NULL) {
+ if (mkdir_p(extract_dir))
+ return EXIT_FAILURE;
+ }
+
if (sqfs_reader_open(&sqfs_a, first_path, 0))
return 2;
@@ -133,6 +149,14 @@ int main(int argc, char **argv)
goto out_sqfs_a;
}
+ if (extract_dir != NULL) {
+ if (chdir(extract_dir)) {
+ perror(extract_dir);
+ ret = -1;
+ goto out;
+ }
+ }
+
ret = node_compare(sqfs_a.fs.root, sqfs_b.fs.root);
if (ret != 0)
goto out;