From 864302059679c15bc223d37ed8cef87c5b4a97aa Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 29 Jul 2019 10:57:40 +0200 Subject: Cleanup: move deduplication code from data writer to fstree Since it is actually completely independend of libsqfs and only works on file_info_t lists, it can be safely moved over to libfstree and the data writer becomes less cluttered as a result. Signed-off-by: David Oberhollenzer --- include/fstree.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'include/fstree.h') diff --git a/include/fstree.h b/include/fstree.h index 687b693..c327fc6 100644 --- a/include/fstree.h +++ b/include/fstree.h @@ -297,4 +297,25 @@ void tree_node_sort_recursive(tree_node_t *root); /* resolve a path to a tree node. Returns NULL on failure and sets errno */ tree_node_t *fstree_node_from_path(fstree_t *fs, const char *path); +/* + Walk through 'list' to find a file with a fragment that has + the same size ('frag_size') and checksum ('chksum') as 'fi'. + Processing stopps if 'fi' itself is found in the list. + + Returns NULL if no such fragment could be found. +*/ +file_info_t *fragment_by_chksum(file_info_t *fi, uint32_t chksum, + size_t frag_size, file_info_t *list, + size_t block_size); + +/* + Walk through 'list' to find a file that contains the same sequence of blocks + as 'file', comparing size and checksum. Processing stops if 'file' is found + in the list. + + Returns NULL if no such fragment could be found. + */ +uint64_t find_equal_blocks(file_info_t *file, file_info_t *list, + size_t block_size); + #endif /* FSTREE_H */ -- cgit v1.2.3