summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-07 11:10:58 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-07 11:24:37 +0200
commit740b161bfaddbd236c9d052546f27dd4af30582c (patch)
tree6635a86cf206f4111dcceb0f46c34691ccaf3ca3
parent55914564db1ce7a4fc71e9dc34156aa144661d0d (diff)
Add flag to difftool to also compare time stamps
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--difftool/difftool.h1
-rw-r--r--difftool/fscompare.c12
-rw-r--r--difftool/node_compare.c7
-rw-r--r--difftool/sqfsdiff.c8
4 files changed, 24 insertions, 4 deletions
diff --git a/difftool/difftool.h b/difftool/difftool.h
index 3d2b6e6..072af02 100644
--- a/difftool/difftool.h
+++ b/difftool/difftool.h
@@ -33,6 +33,7 @@ enum {
COMPARE_NO_PERM = 0x01,
COMPARE_NO_OWNER = 0x02,
COMPARE_NO_CONTENTS = 0x04,
+ COMPARE_TIMESTAMP = 0x08,
};
int compare_dir_entries(tree_node_t *a, tree_node_t *b);
diff --git a/difftool/fscompare.c b/difftool/fscompare.c
index c925adc..3f00a5c 100644
--- a/difftool/fscompare.c
+++ b/difftool/fscompare.c
@@ -9,11 +9,12 @@
static struct option long_opts[] = {
{ "no-owner", no_argument, NULL, 'O' },
{ "no-permissions", no_argument, NULL, 'P' },
+ { "timestamps", no_argument, NULL, 'T' },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
};
-static const char *short_opts = "OPhV";
+static const char *short_opts = "OPThV";
static const char *usagestr =
"Usage: fscompare [OPTIONS...] <first> <second>\n"
@@ -26,6 +27,8 @@ static const char *usagestr =
" --no-owner, -O Do not compare file owners.\n"
" --no-permissions, -P Do not compare permission bits.\n"
"\n"
+" --timestamps, -T Compare file timestamps.\n"
+"\n"
" --help, -h Print help text and exit.\n"
" --version, -V Print version information and exit.\n"
"\n";
@@ -50,6 +53,9 @@ static void process_options(int argc, char **argv)
case 'P':
compare_flags |= COMPARE_NO_PERM;
break;
+ case 'T':
+ compare_flags |= COMPARE_TIMESTAMP;
+ break;
case 'h':
fputs(usagestr, stdout);
exit(EXIT_SUCCESS);
@@ -98,10 +104,10 @@ int main(int argc, char **argv)
if (fstree_init(&bfs, 512, NULL))
goto out_afs;
- if (fstree_from_dir(&afs, first_path, false))
+ if (fstree_from_dir(&afs, first_path, true))
goto out_bfs;
- if (fstree_from_dir(&bfs, second_path, false))
+ if (fstree_from_dir(&bfs, second_path, true))
goto out_bfs;
tree_node_sort_recursive(afs.root);
diff --git a/difftool/node_compare.c b/difftool/node_compare.c
index fae35ab..e1b72c6 100644
--- a/difftool/node_compare.c
+++ b/difftool/node_compare.c
@@ -36,6 +36,13 @@ int node_compare(tree_node_t *a, tree_node_t *b)
}
}
+ if (compare_flags & COMPARE_TIMESTAMP) {
+ if (a->mod_time != b->mod_time) {
+ fprintf(stdout, "%s has a different timestamp\n", path);
+ status = 1;
+ }
+ }
+
switch (a->mode & S_IFMT) {
case S_IFSOCK:
case S_IFIFO:
diff --git a/difftool/sqfsdiff.c b/difftool/sqfsdiff.c
index 02de33a..d23a724 100644
--- a/difftool/sqfsdiff.c
+++ b/difftool/sqfsdiff.c
@@ -10,11 +10,12 @@ static struct option long_opts[] = {
{ "no-owner", no_argument, NULL, 'O' },
{ "no-permissions", no_argument, NULL, 'P' },
{ "no-contents", no_argument, NULL, 'C' },
+ { "timestamps", no_argument, NULL, 'T' },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
};
-static const char *short_opts = "OPChV";
+static const char *short_opts = "OPCThV";
static const char *usagestr =
"Usage: sqfsdiff [OPTIONS...] <first> <second>\n"
@@ -38,6 +39,8 @@ static const char *usagestr =
" --no-owner, -O Do not compare file owners.\n"
" --no-permissions, -P Do not compare permission bits.\n"
"\n"
+" --timestamps, -T Compare file timestamps.\n"
+"\n"
" --help, -h Print help text and exit.\n"
" --version, -V Print version information and exit.\n"
"\n";
@@ -67,6 +70,9 @@ static void process_options(int argc, char **argv)
case 'C':
compare_flags |= COMPARE_NO_CONTENTS;
break;
+ case 'T':
+ compare_flags |= COMPARE_TIMESTAMP;
+ break;
case 'h':
fputs(usagestr, stdout);
exit(EXIT_SUCCESS);