From e165fb864fe86eda398a14713cf38924cc537adc Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 14 Sep 2019 17:57:58 +0200 Subject: Remove fstree file flags As a side effect, this requires the data writer to keep track of statistics. Signed-off-by: David Oberhollenzer --- lib/fstree/optimize_unpack_order.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/fstree/optimize_unpack_order.c') diff --git a/lib/fstree/optimize_unpack_order.c b/lib/fstree/optimize_unpack_order.c index ad036e8..51576bd 100644 --- a/lib/fstree/optimize_unpack_order.c +++ b/lib/fstree/optimize_unpack_order.c @@ -7,6 +7,15 @@ #include "config.h" #include "fstree.h" +static bool has_fragment(const fstree_t *fs, const file_info_t *file) +{ + if (file->size % fs->block_size == 0) + return false; + + return file->fragment_offset < fs->block_size && + (file->fragment != 0xFFFFFFFF); +} + static int compare_files(const fstree_t *fs, const file_info_t *lhs, const file_info_t *rhs) { @@ -20,8 +29,8 @@ static int compare_files(const fstree_t *fs, const file_info_t *lhs, /* Files with fragments come first, ordered by ID. In case of tie, files without data blocks come first, and the others are ordered by start block. */ - if (lhs->flags & FILE_FLAG_HAS_FRAGMENT) { - if (!(rhs->flags & FILE_FLAG_HAS_FRAGMENT)) + if (has_fragment(fs, lhs)) { + if (!(has_fragment(fs, rhs))) return -1; if (lhs->fragment < rhs->fragment) @@ -36,7 +45,7 @@ static int compare_files(const fstree_t *fs, const file_info_t *lhs, goto order_by_start; } - if (rhs->flags & FILE_FLAG_HAS_FRAGMENT) + if (has_fragment(fs, rhs)) return 1; /* order the rest by start block */ -- cgit v1.2.3