aboutsummaryrefslogtreecommitdiff
path: root/lib/sqfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-26 22:06:04 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-28 16:33:57 +0200
commit8b633067948a30a0d45091afcced0392dd28d105 (patch)
treed3cfdd43132da1cee604bd18b3569bd19ba8fdd8 /lib/sqfs
parent0f1bedc90f4cb71d965e99446cf3e72a45909346 (diff)
Add fragment and block checksum fields to file_info_t
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs')
-rw-r--r--lib/sqfs/data_reader.c2
-rw-r--r--lib/sqfs/data_writer.c4
-rw-r--r--lib/sqfs/tree_node_from_inode.c12
-rw-r--r--lib/sqfs/write_inode.c2
4 files changed, 9 insertions, 11 deletions
diff --git a/lib/sqfs/data_reader.c b/lib/sqfs/data_reader.c
index 0e2e7ac..5facaa1 100644
--- a/lib/sqfs/data_reader.c
+++ b/lib/sqfs/data_reader.c
@@ -92,7 +92,7 @@ static int dump_blocks(data_reader_t *data, file_info_t *fi, int outfd,
void *ptr;
for (i = 0; i < count; ++i) {
- bs = fi->blocksizes[i];
+ bs = fi->blocks[i].size;
compressed = (bs & (1 << 24)) == 0;
bs &= (1 << 24) - 1;
diff --git a/lib/sqfs/data_writer.c b/lib/sqfs/data_writer.c
index ae8257c..aff296e 100644
--- a/lib/sqfs/data_writer.c
+++ b/lib/sqfs/data_writer.c
@@ -131,7 +131,7 @@ static int flush_data_block(data_writer_t *data, size_t size,
uint32_t out;
if (is_zero_block(data->block, size)) {
- fi->blocksizes[data->block_idx++] = 0;
+ fi->blocks[data->block_idx++].size = 0;
fi->sparse += size;
return 0;
}
@@ -152,7 +152,7 @@ static int flush_data_block(data_writer_t *data, size_t size,
if (write_compressed(data, data->block, size, &out, flags))
return -1;
- fi->blocksizes[data->block_idx++] = out;
+ fi->blocks[data->block_idx++].size = out;
}
return 0;
diff --git a/lib/sqfs/tree_node_from_inode.c b/lib/sqfs/tree_node_from_inode.c
index f35c046..034218c 100644
--- a/lib/sqfs/tree_node_from_inode.c
+++ b/lib/sqfs/tree_node_from_inode.c
@@ -38,13 +38,13 @@ static size_t compute_size(sqfs_inode_generic_t *inode, const char *name,
break;
}
- return size + block_count * sizeof(uint32_t);
+ return size + block_count * sizeof(((file_info_t *)0)->blocks[0]);
}
static void copy_block_sizes(sqfs_inode_generic_t *inode, tree_node_t *out,
size_t block_size)
{
- size_t block_count = out->data.file->size / block_size;
+ size_t i, block_count = out->data.file->size / block_size;
if ((out->data.file->size % block_size) != 0) {
if (out->data.file->fragment == 0xFFFFFFFF ||
@@ -53,12 +53,10 @@ static void copy_block_sizes(sqfs_inode_generic_t *inode, tree_node_t *out,
}
}
- out->name += block_count * sizeof(uint32_t);
+ out->name += block_count * sizeof(out->data.file->blocks[0]);
- if (block_count) {
- memcpy(out->data.file->blocksizes, inode->block_sizes,
- block_count * sizeof(uint32_t));
- }
+ for (i = 0; i < block_count; ++i)
+ out->data.file->blocks[i].size = inode->block_sizes[i];
}
tree_node_t *tree_node_from_inode(sqfs_inode_generic_t *inode,
diff --git a/lib/sqfs/write_inode.c b/lib/sqfs/write_inode.c
index 7cef7a7..726206e 100644
--- a/lib/sqfs/write_inode.c
+++ b/lib/sqfs/write_inode.c
@@ -88,7 +88,7 @@ static int write_file_blocks(fstree_t *fs, file_info_t *fi, meta_writer_t *im)
}
for (i = 0; i < count; ++i) {
- bs = htole32(fi->blocksizes[i]);
+ bs = htole32(fi->blocks[i].size);
if (meta_writer_append(im, &bs, sizeof(bs)))
return -1;