summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-08 10:17:43 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-08 10:17:43 +0200
commit1fc5b3bb6d4dcaa5a1e54e3f60434c8623e8e274 (patch)
tree31e8962fc13bee73c1d608614489b91a11c50388
parent0b135e181b1610ff3d1e4a46dfdf06337b4a37e8 (diff)
sqfsdiff: continue comparison if types are compatible
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--difftool/node_compare.c76
1 files changed, 73 insertions, 3 deletions
diff --git a/difftool/node_compare.c b/difftool/node_compare.c
index 1612d34..d9ccf34 100644
--- a/difftool/node_compare.c
+++ b/difftool/node_compare.c
@@ -10,6 +10,7 @@ int node_compare(sqfsdiff_t *sd, sqfs_tree_node_t *a, sqfs_tree_node_t *b)
{
char *path = sqfs_tree_node_get_path(a);
sqfs_tree_node_t *ait, *bit;
+ bool promoted, demoted;
int ret, status = 0;
if (path == NULL) {
@@ -18,9 +19,78 @@ int node_compare(sqfsdiff_t *sd, sqfs_tree_node_t *a, sqfs_tree_node_t *b)
}
if (a->inode->base.type != b->inode->base.type) {
- fprintf(stdout, "%s has a different type\n", path);
- free(path);
- return 1;
+ promoted = demoted = false;
+
+ switch (a->inode->base.type) {
+ case SQFS_INODE_DIR:
+ if (b->inode->base.type == SQFS_INODE_EXT_DIR)
+ promoted = true;
+ break;
+ case SQFS_INODE_FILE:
+ if (b->inode->base.type == SQFS_INODE_EXT_FILE)
+ promoted = true;
+ break;
+ case SQFS_INODE_SLINK:
+ if (b->inode->base.type == SQFS_INODE_EXT_SLINK)
+ promoted = true;
+ break;
+ case SQFS_INODE_BDEV:
+ if (b->inode->base.type == SQFS_INODE_EXT_BDEV)
+ promoted = true;
+ break;
+ case SQFS_INODE_CDEV:
+ if (b->inode->base.type == SQFS_INODE_EXT_CDEV)
+ promoted = true;
+ break;
+ case SQFS_INODE_FIFO:
+ if (b->inode->base.type == SQFS_INODE_EXT_FIFO)
+ promoted = true;
+ break;
+ case SQFS_INODE_SOCKET:
+ if (b->inode->base.type == SQFS_INODE_EXT_SOCKET)
+ promoted = true;
+ break;
+ case SQFS_INODE_EXT_DIR:
+ if (b->inode->base.type == SQFS_INODE_DIR)
+ demoted = true;
+ break;
+ case SQFS_INODE_EXT_FILE:
+ if (b->inode->base.type == SQFS_INODE_FILE)
+ demoted = true;
+ break;
+ case SQFS_INODE_EXT_SLINK:
+ if (b->inode->base.type == SQFS_INODE_SLINK)
+ demoted = true;
+ break;
+ case SQFS_INODE_EXT_BDEV:
+ if (b->inode->base.type == SQFS_INODE_BDEV)
+ demoted = true;
+ break;
+ case SQFS_INODE_EXT_CDEV:
+ if (b->inode->base.type == SQFS_INODE_CDEV)
+ demoted = true;
+ break;
+ case SQFS_INODE_EXT_FIFO:
+ if (b->inode->base.type == SQFS_INODE_FIFO)
+ demoted = true;
+ break;
+ case SQFS_INODE_EXT_SOCKET:
+ if (b->inode->base.type == SQFS_INODE_SOCKET)
+ demoted = true;
+ break;
+ }
+
+ if (promoted) {
+ fprintf(stdout, "%s has an extended type\n", path);
+ status = 1;
+ } else if (demoted) {
+ fprintf(stdout, "%s has a basic type\n", path);
+ status = 1;
+ } else {
+ fprintf(stdout, "%s has a different type\n", path);
+ free(path);
+ return 1;
+ }
}
if (!(sd->compare_flags & COMPARE_NO_PERM)) {