summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-06 16:55:41 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-07 11:24:36 +0200
commit55914564db1ce7a4fc71e9dc34156aa144661d0d (patch)
tree2b981d86df104906c9c9b2bad5434d105a4cff5c
parentd6149732b67fbedc7ac2d2ba984c07ab466392f1 (diff)
Add flag to sqfsdiff to skip comparing filesystem contents
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--difftool/compare_files_sqfs.c3
-rw-r--r--difftool/difftool.h1
-rw-r--r--difftool/sqfsdiff.c24
3 files changed, 18 insertions, 10 deletions
diff --git a/difftool/compare_files_sqfs.c b/difftool/compare_files_sqfs.c
index d8bef83..76fae7a 100644
--- a/difftool/compare_files_sqfs.c
+++ b/difftool/compare_files_sqfs.c
@@ -17,6 +17,9 @@ int compare_files(file_info_t *a, file_info_t *b, const char *path)
if (a->size != b->size)
return 1;
+ if (compare_flags & COMPARE_NO_CONTENTS)
+ return 0;
+
for (offset = 0; offset < a->size; offset += diff) {
diff = a->size - offset;
diff --git a/difftool/difftool.h b/difftool/difftool.h
index f7739c4..3d2b6e6 100644
--- a/difftool/difftool.h
+++ b/difftool/difftool.h
@@ -32,6 +32,7 @@ extern sqfs_reader_t sqfs_b;
enum {
COMPARE_NO_PERM = 0x01,
COMPARE_NO_OWNER = 0x02,
+ COMPARE_NO_CONTENTS = 0x04,
};
int compare_dir_entries(tree_node_t *a, tree_node_t *b);
diff --git a/difftool/sqfsdiff.c b/difftool/sqfsdiff.c
index 2fc10a1..02de33a 100644
--- a/difftool/sqfsdiff.c
+++ b/difftool/sqfsdiff.c
@@ -9,31 +9,32 @@
static struct option long_opts[] = {
{ "no-owner", no_argument, NULL, 'O' },
{ "no-permissions", no_argument, NULL, 'P' },
+ { "no-contents", no_argument, NULL, 'C' },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
};
-static const char *short_opts = "OPhV";
+static const char *short_opts = "OPChV";
static const char *usagestr =
"Usage: sqfsdiff [OPTIONS...] <first> <second>\n"
"\n"
-"Compare the contents of two squashfs images. In contrast to doing a direct\n"
-"diff of the images, this actually recovers the file system trees and\n"
-"recursively compares them against each other.\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"
+"meaningful difference report.\n"
"\n"
-"Any differences in packed file layout, ordering, compression, inode\n"
-"allocation and so on is ignored, only the contents are compared.\n"
-"\n"
-"The two images are considered equal if each directory contains the same\n"
-"entries, symlink with the same paths have the same targets, device nodes\n"
-"the same device number and files the same size and contents.\n"
+"If only contents are compared, any differences in packed file layout,\n"
+"ordering, compression, inode allocation and so on is ignored and the two\n"
+"images are considered equal if each directory contains the same entries,\n"
+"symlink with the same paths have the same targets, device nodes the same\n"
+"device number and files the same size and contents.\n"
"\n"
"A report of any difference is printed to stdout. The exit status is similar\n"
"that of diff(1): 0 means equal, 1 means different, 2 means problem.\n"
"\n"
"Possible options:\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"
"\n"
@@ -63,6 +64,9 @@ static void process_options(int argc, char **argv)
case 'P':
compare_flags |= COMPARE_NO_PERM;
break;
+ case 'C':
+ compare_flags |= COMPARE_NO_CONTENTS;
+ break;
case 'h':
fputs(usagestr, stdout);
exit(EXIT_SUCCESS);