From 56edfefb9718f72bd45093e0efd76bd88645fa89 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 18 Sep 2022 16:04:24 +0200 Subject: block writer: move block comaprison to utility function Slightly modify the byte-for-byte comparison function to compare an arbitrary range in a file and move it to libutil. Instead of calling it for each block in the block writer, simply let it check an entire range in the block writer and compute the range position/size of the reference ahead, before looking for potential matches. Signed-off-by: David Oberhollenzer --- include/util/util.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/util/util.h b/include/util/util.h index 6e34a82..0161c2b 100644 --- a/include/util/util.h +++ b/include/util/util.h @@ -69,4 +69,12 @@ SQFS_INTERNAL bool is_filename_sane(const char *name, bool check_os_specific); */ SQFS_INTERNAL sqfs_u32 get_source_date_epoch(void); +/* + Check if two regions in a file are equal using a scratch buffer to load the + data into for comparision. Returns 0 if equal, > 0 if not, < 0 if error. + */ +SQFS_INTERNAL int check_file_range_equal(sqfs_file_t *file, void *scratch, + size_t scratch_size, sqfs_u64 loc_a, + sqfs_u64 loc_b, sqfs_u64 size); + #endif /* SQFS_UTIL_H */ -- cgit v1.2.3