diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-26 22:06:04 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-28 16:33:57 +0200 |
commit | 8b633067948a30a0d45091afcced0392dd28d105 (patch) | |
tree | d3cfdd43132da1cee604bd18b3569bd19ba8fdd8 /lib | |
parent | 0f1bedc90f4cb71d965e99446cf3e72a45909346 (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')
-rw-r--r-- | lib/fstree/mknode.c | 7 | ||||
-rw-r--r-- | lib/sqfs/data_reader.c | 2 | ||||
-rw-r--r-- | lib/sqfs/data_writer.c | 4 | ||||
-rw-r--r-- | lib/sqfs/tree_node_from_inode.c | 12 | ||||
-rw-r--r-- | lib/sqfs/write_inode.c | 2 |
5 files changed, 13 insertions, 14 deletions
diff --git a/lib/fstree/mknode.c b/lib/fstree/mknode.c index c6572fe..18602e4 100644 --- a/lib/fstree/mknode.c +++ b/lib/fstree/mknode.c @@ -31,7 +31,8 @@ tree_node_t *fstree_mknode(fstree_t *fs, tree_node_t *parent, const char *name, if ((sb->st_size % fs->block_size) != 0) ++block_count; - size += sizeof(*n->data.file) + block_count * sizeof(uint32_t); + size += sizeof(*n->data.file); + size += block_count * sizeof(n->data.file->blocks[0]); if (extra != NULL) size += strlen(extra) + 1; break; @@ -64,8 +65,8 @@ tree_node_t *fstree_mknode(fstree_t *fs, tree_node_t *parent, const char *name, if (extra == NULL) break; - ptr = (char *)n->data.file->blocksizes; - ptr += block_count * sizeof(uint32_t); + ptr = (char *)n->data.file->blocks; + ptr += block_count * sizeof(n->data.file->blocks[0]); n->data.file->input_file = ptr; strcpy(n->data.file->input_file, extra); break; 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; |