summaryrefslogtreecommitdiff
path: root/lib/sqfshelper/tree_node_to_inode.c
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/sqfshelper/tree_node_to_inode.c
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/sqfshelper/tree_node_to_inode.c')
-rw-r--r--lib/sqfshelper/tree_node_to_inode.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/sqfshelper/tree_node_to_inode.c b/lib/sqfshelper/tree_node_to_inode.c
index cc76a8d..2fdc21b 100644
--- a/lib/sqfshelper/tree_node_to_inode.c
+++ b/lib/sqfshelper/tree_node_to_inode.c
@@ -81,6 +81,15 @@ static int get_type(tree_node_t *node)
assert(0);
}
+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);
+}
+
sqfs_inode_generic_t *tree_node_to_inode(fstree_t *fs, sqfs_id_table_t *idtbl,
tree_node_t *node)
{
@@ -97,10 +106,8 @@ sqfs_inode_generic_t *tree_node_to_inode(fstree_t *fs, sqfs_id_table_t *idtbl,
block_count = fi->size / fs->block_size;
- if ((fi->size % fs->block_size) != 0 &&
- !(fi->flags & FILE_FLAG_HAS_FRAGMENT)) {
+ if ((fi->size % fs->block_size) != 0 && !has_fragment(fs, fi))
++block_count;
- }
extra = block_count * sizeof(uint32_t);
}
@@ -176,8 +183,7 @@ sqfs_inode_generic_t *tree_node_to_inode(fstree_t *fs, sqfs_id_table_t *idtbl,
inode->data.file.fragment_offset = 0xFFFFFFFF;
inode->data.file.file_size = fi->size;
- if ((fi->size % fs->block_size) != 0 &&
- (fi->flags & FILE_FLAG_HAS_FRAGMENT)) {
+ if (has_fragment(fs, fi)) {
inode->data.file.fragment_index = fi->fragment;
inode->data.file.fragment_offset = fi->fragment_offset;
}
@@ -191,8 +197,7 @@ sqfs_inode_generic_t *tree_node_to_inode(fstree_t *fs, sqfs_id_table_t *idtbl,
inode->data.file_ext.fragment_offset = 0xFFFFFFFF;
inode->data.file_ext.xattr_idx = xattr;
- if ((fi->size % fs->block_size) != 0 &&
- (fi->flags & FILE_FLAG_HAS_FRAGMENT)) {
+ if (has_fragment(fs, fi)) {
inode->data.file_ext.fragment_idx = fi->fragment;
inode->data.file_ext.fragment_offset =
fi->fragment_offset;