aboutsummaryrefslogtreecommitdiff
path: root/lib/fstree
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-14 17:57:58 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-14 18:06:04 +0200
commite165fb864fe86eda398a14713cf38924cc537adc (patch)
tree217b80d56b1d8c21f3387390db06e525b2f9f064 /lib/fstree
parentf57814332a69bebc40e25e6537a3c08fc9e18f97 (diff)
Remove fstree file flags
As a side effect, this requires the data writer to keep track of statistics. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree')
-rw-r--r--lib/fstree/optimize_unpack_order.c15
1 files changed, 12 insertions, 3 deletions
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 */