aboutsummaryrefslogtreecommitdiff
path: root/difftool/compare_files.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-20 16:31:31 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-20 18:34:17 +0200
commitd57efdfa0b7420dabf97335ffe3a8b391b9f54b3 (patch)
treef42eed71fc5c4a07ef03696c9953da7d4e860095 /difftool/compare_files.c
parentc106a290ed07fa89b39072925b1a2258071511a8 (diff)
Remove sqfs reader & fstree usage from sqfsdiff
Replace with direct usage of the dir reader and lower level data structures. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'difftool/compare_files.c')
-rw-r--r--difftool/compare_files.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/difftool/compare_files.c b/difftool/compare_files.c
index 6138569..591fc2c 100644
--- a/difftool/compare_files.c
+++ b/difftool/compare_files.c
@@ -10,12 +10,12 @@ static unsigned char old_buf[MAX_WINDOW_SIZE];
static unsigned char new_buf[MAX_WINDOW_SIZE];
static int read_blob(const char *prefix, const char *path,
- data_reader_t *rd, file_info_t *fi, void *buffer,
- off_t offset, size_t size)
+ data_reader_t *rd, const sqfs_inode_generic_t *inode,
+ void *buffer, uint64_t offset, size_t size)
{
ssize_t ret;
- ret = data_reader_read(rd, fi, offset, buffer, size);
+ ret = data_reader_read(rd, inode, offset, buffer, size);
ret = (ret < 0 || (size_t)ret < size) ? -1 : 0;
if (ret) {
@@ -27,20 +27,32 @@ static int read_blob(const char *prefix, const char *path,
return 0;
}
-int compare_files(sqfsdiff_t *sd, file_info_t *old, file_info_t *new,
- const char *path)
+int compare_files(sqfsdiff_t *sd, const sqfs_inode_generic_t *old,
+ const sqfs_inode_generic_t *new, const char *path)
{
- uint64_t offset, diff;
+ uint64_t offset, diff, oldsz, newsz;
int status = 0, ret;
- if (old->size != new->size)
+ if (old->base.type == SQFS_INODE_EXT_FILE) {
+ oldsz = old->data.file_ext.file_size;
+ } else {
+ oldsz = old->data.file.file_size;
+ }
+
+ if (new->base.type == SQFS_INODE_EXT_FILE) {
+ newsz = new->data.file_ext.file_size;
+ } else {
+ newsz = new->data.file.file_size;
+ }
+
+ if (oldsz != newsz)
goto out_different;
if (sd->compare_flags & COMPARE_NO_CONTENTS)
return 0;
- for (offset = 0; offset < old->size; offset += diff) {
- diff = old->size - offset;
+ for (offset = 0; offset < oldsz; offset += diff) {
+ diff = oldsz - offset;
if (diff > MAX_WINDOW_SIZE)
diff = MAX_WINDOW_SIZE;