aboutsummaryrefslogtreecommitdiff
path: root/lib/sqfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-04 18:28:59 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-04 18:28:59 +0200
commit3b7f4dbb284462ef7065e19f1725f615973477da (patch)
tree2f1da14b33e69f4a73e49abf2fdec2dbd1844f23 /lib/sqfs
parent407a2baae5622b05f1e9c4137448a973fd648736 (diff)
Store number of file blocks in generic inode struct
This simplifies things a little bit. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs')
-rw-r--r--lib/sqfs/read_inode.c2
-rw-r--r--lib/sqfs/write_inode.c16
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/sqfs/read_inode.c b/lib/sqfs/read_inode.c
index 10337a7..6da9653 100644
--- a/lib/sqfs/read_inode.c
+++ b/lib/sqfs/read_inode.c
@@ -100,6 +100,7 @@ static sqfs_inode_generic_t *read_inode_file(meta_reader_t *ir,
out->base = *base;
out->data.file = file;
out->block_sizes = (uint32_t *)out->extra;
+ out->num_file_blocks = count;
if (meta_reader_read(ir, out->block_sizes, count * sizeof(uint32_t))) {
free(out);
@@ -143,6 +144,7 @@ static sqfs_inode_generic_t *read_inode_file_ext(meta_reader_t *ir,
out->base = *base;
out->data.file_ext = file;
out->block_sizes = (uint32_t *)out->extra;
+ out->num_file_blocks = count;
if (meta_reader_read(ir, out->block_sizes, count * sizeof(uint32_t))) {
free(out);
diff --git a/lib/sqfs/write_inode.c b/lib/sqfs/write_inode.c
index a2d87f9..258f516 100644
--- a/lib/sqfs/write_inode.c
+++ b/lib/sqfs/write_inode.c
@@ -8,21 +8,19 @@
#include "sqfs/inode.h"
-static int write_block_sizes(meta_writer_t *ir, sqfs_inode_generic_t *n,
- size_t file_num_blocks)
+static int write_block_sizes(meta_writer_t *ir, sqfs_inode_generic_t *n)
{
- uint32_t sizes[file_num_blocks];
+ uint32_t sizes[n->num_file_blocks];
size_t i;
- for (i = 0; i < file_num_blocks; ++i)
+ for (i = 0; i < n->num_file_blocks; ++i)
sizes[i] = htole32(n->block_sizes[i]);
return meta_writer_append(ir, sizes,
- sizeof(uint32_t) * file_num_blocks);
+ sizeof(uint32_t) * n->num_file_blocks);
}
-int meta_writer_write_inode(meta_writer_t *ir, sqfs_inode_generic_t *n,
- size_t file_num_blocks)
+int meta_writer_write_inode(meta_writer_t *ir, sqfs_inode_generic_t *n)
{
sqfs_inode_t base;
@@ -57,7 +55,7 @@ int meta_writer_write_inode(meta_writer_t *ir, sqfs_inode_generic_t *n,
};
if (meta_writer_append(ir, &file, sizeof(file)))
return -1;
- return write_block_sizes(ir, n, file_num_blocks);
+ return write_block_sizes(ir, n);
}
case SQFS_INODE_SLINK: {
sqfs_inode_slink_t slink = {
@@ -109,7 +107,7 @@ int meta_writer_write_inode(meta_writer_t *ir, sqfs_inode_generic_t *n,
};
if (meta_writer_append(ir, &file, sizeof(file)))
return -1;
- return write_block_sizes(ir, n, file_num_blocks);
+ return write_block_sizes(ir, n);
}
case SQFS_INODE_EXT_SLINK: {
sqfs_inode_slink_t slink = {