aboutsummaryrefslogtreecommitdiff
path: root/lib/sqfs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqfs')
-rw-r--r--lib/sqfs/data_reader.c15
-rw-r--r--lib/sqfs/data_writer/block.c2
-rw-r--r--lib/sqfs/data_writer/fileapi.c2
-rw-r--r--lib/sqfs/dir_writer.c3
-rw-r--r--lib/sqfs/inode.c3
-rw-r--r--lib/sqfs/read_inode.c19
-rw-r--r--lib/sqfs/write_inode.c9
7 files changed, 22 insertions, 31 deletions
diff --git a/lib/sqfs/data_reader.c b/lib/sqfs/data_reader.c
index 6a0db35..af15b9b 100644
--- a/lib/sqfs/data_reader.c
+++ b/lib/sqfs/data_reader.c
@@ -219,14 +219,13 @@ int sqfs_data_reader_get_block(sqfs_data_reader_t *data,
return SQFS_ERROR_OUT_OF_BOUNDS;
for (i = 0; i < index; ++i) {
- off += SQFS_ON_DISK_BLOCK_SIZE(inode->block_sizes[i]);
+ off += SQFS_ON_DISK_BLOCK_SIZE(inode->extra[i]);
filesz -= data->block_size;
}
unpacked_size = filesz < data->block_size ? filesz : data->block_size;
- return get_block(data, off, inode->block_sizes[index],
- unpacked_size, out);
+ return get_block(data, off, inode->extra[index], unpacked_size, out);
}
int sqfs_data_reader_get_fragment(sqfs_data_reader_t *data,
@@ -285,7 +284,7 @@ sqfs_s32 sqfs_data_reader_read(sqfs_data_reader_t *data,
i = 0;
while (offset > data->block_size && i < inode->num_file_blocks) {
- off += SQFS_ON_DISK_BLOCK_SIZE(inode->block_sizes[i++]);
+ off += SQFS_ON_DISK_BLOCK_SIZE(inode->extra[i++]);
offset -= data->block_size;
if (filesz >= data->block_size) {
@@ -301,17 +300,15 @@ sqfs_s32 sqfs_data_reader_read(sqfs_data_reader_t *data,
if (size < diff)
diff = size;
- if (SQFS_IS_SPARSE_BLOCK(inode->block_sizes[i])) {
+ if (SQFS_IS_SPARSE_BLOCK(inode->extra[i])) {
memset(buffer, 0, diff);
} else {
- if (precache_data_block(data, off,
- inode->block_sizes[i])) {
+ if (precache_data_block(data, off, inode->extra[i]))
return -1;
- }
memcpy(buffer, (char *)data->data_block->data + offset,
diff);
- off += SQFS_ON_DISK_BLOCK_SIZE(inode->block_sizes[i]);
+ off += SQFS_ON_DISK_BLOCK_SIZE(inode->extra[i]);
}
if (filesz >= data->block_size) {
diff --git a/lib/sqfs/data_writer/block.c b/lib/sqfs/data_writer/block.c
index 9396e4a..5967e59 100644
--- a/lib/sqfs/data_writer/block.c
+++ b/lib/sqfs/data_writer/block.c
@@ -116,7 +116,7 @@ int process_completed_block(sqfs_data_writer_t *proc, sqfs_block_t *blk)
proc->fragments[blk->index].pad0 = 0;
proc->fragments[blk->index].size = htole32(out);
} else {
- blk->inode->block_sizes[blk->index] = out;
+ blk->inode->extra[blk->index] = out;
}
err = store_block_location(proc, offset, out, blk->checksum);
diff --git a/lib/sqfs/data_writer/fileapi.c b/lib/sqfs/data_writer/fileapi.c
index de77690..89bac0b 100644
--- a/lib/sqfs/data_writer/fileapi.c
+++ b/lib/sqfs/data_writer/fileapi.c
@@ -67,7 +67,7 @@ static int flush_block(sqfs_data_writer_t *proc, sqfs_block_t *block)
sqfs_inode_make_extended(proc->inode);
proc->inode->data.file_ext.sparse += block->size;
proc->inode->num_file_blocks += 1;
- proc->inode->block_sizes[block->index] = 0;
+ proc->inode->extra[block->index] = 0;
free(block);
return 0;
}
diff --git a/lib/sqfs/dir_writer.c b/lib/sqfs/dir_writer.c
index 78256a1..53e5800 100644
--- a/lib/sqfs/dir_writer.c
+++ b/lib/sqfs/dir_writer.c
@@ -419,7 +419,8 @@ sqfs_inode_generic_t
ent.index = idx->index;
ent.size = idx->ent->name_len - 1;
- ptr = inode->extra + inode->num_dir_idx_bytes;
+ ptr = (sqfs_u8 *)inode->extra +
+ inode->num_dir_idx_bytes;
memcpy(ptr, &ent, sizeof(ent));
memcpy(ptr + sizeof(ent), idx->ent->name,
idx->ent->name_len);
diff --git a/lib/sqfs/inode.c b/lib/sqfs/inode.c
index 3a4ec09..815cc0f 100644
--- a/lib/sqfs/inode.c
+++ b/lib/sqfs/inode.c
@@ -72,9 +72,6 @@ int sqfs_inode_copy(const sqfs_inode_generic_t *src,
return SQFS_ERROR_ALLOC;
memcpy(copy, src, size);
- copy->block_sizes = (sqfs_u32 *)copy->extra;
- copy->slink_target = (char *)copy->extra;
-
*out = copy;
return 0;
}
diff --git a/lib/sqfs/read_inode.c b/lib/sqfs/read_inode.c
index f7bfff0..8653928 100644
--- a/lib/sqfs/read_inode.c
+++ b/lib/sqfs/read_inode.c
@@ -101,18 +101,16 @@ static int read_inode_file(sqfs_meta_reader_t *ir, sqfs_inode_t *base,
out->base = *base;
out->data.file = file;
- out->block_sizes = (sqfs_u32 *)out->extra;
out->num_file_blocks = count;
- err = sqfs_meta_reader_read(ir, out->block_sizes,
- count * sizeof(sqfs_u32));
+ err = sqfs_meta_reader_read(ir, out->extra, count * sizeof(sqfs_u32));
if (err) {
free(out);
return err;
}
for (i = 0; i < count; ++i)
- SWAB32(out->block_sizes[i]);
+ SWAB32(out->extra[i]);
*result = out;
return 0;
@@ -149,18 +147,16 @@ static int read_inode_file_ext(sqfs_meta_reader_t *ir, sqfs_inode_t *base,
out->base = *base;
out->data.file_ext = file;
- out->block_sizes = (sqfs_u32 *)out->extra;
out->num_file_blocks = count;
- err = sqfs_meta_reader_read(ir, out->block_sizes,
- count * sizeof(sqfs_u32));
+ err = sqfs_meta_reader_read(ir, out->extra, count * sizeof(sqfs_u32));
if (err) {
free(out);
return err;
}
for (i = 0; i < count; ++i)
- SWAB32(out->block_sizes[i]);
+ SWAB32(out->extra[i]);
*result = out;
return 0;
@@ -190,11 +186,10 @@ static int read_inode_slink(sqfs_meta_reader_t *ir, sqfs_inode_t *base,
if (out == NULL)
return SQFS_ERROR_ALLOC;
- out->slink_target = (char *)out->extra;
out->base = *base;
out->data.slink = slink;
- err = sqfs_meta_reader_read(ir, out->slink_target, slink.target_size);
+ err = sqfs_meta_reader_read(ir, (void *)out->extra, slink.target_size);
if (err) {
free(out);
return err;
@@ -290,10 +285,10 @@ static int read_inode_dir_ext(sqfs_meta_reader_t *ir, sqfs_inode_t *base,
index_max = new_sz;
}
- memcpy(out->extra + index_used, &ent, sizeof(ent));
+ memcpy((char *)out->extra + index_used, &ent, sizeof(ent));
index_used += sizeof(ent);
- err = sqfs_meta_reader_read(ir, out->extra + index_used,
+ err = sqfs_meta_reader_read(ir, (char *)out->extra + index_used,
ent.size + 1);
if (err) {
free(out);
diff --git a/lib/sqfs/write_inode.c b/lib/sqfs/write_inode.c
index 5f0ef4c..b5ba905 100644
--- a/lib/sqfs/write_inode.c
+++ b/lib/sqfs/write_inode.c
@@ -22,7 +22,7 @@ static int write_block_sizes(sqfs_meta_writer_t *ir,
size_t i;
for (i = 0; i < n->num_file_blocks; ++i)
- sizes[i] = htole32(n->block_sizes[i]);
+ sizes[i] = htole32(n->extra[i]);
return sqfs_meta_writer_append(ir, sizes,
sizeof(sqfs_u32) * n->num_file_blocks);
@@ -112,7 +112,7 @@ int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *ir,
ret = sqfs_meta_writer_append(ir, &slink, sizeof(slink));
if (ret)
return ret;
- return sqfs_meta_writer_append(ir, n->slink_target,
+ return sqfs_meta_writer_append(ir, n->extra,
n->data.slink.target_size);
}
case SQFS_INODE_BDEV:
@@ -143,7 +143,8 @@ int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *ir,
ret = sqfs_meta_writer_append(ir, &dir, sizeof(dir));
if (ret)
return ret;
- return write_dir_index(ir, n->extra, n->num_dir_idx_bytes);
+ return write_dir_index(ir, (const sqfs_u8 *)n->extra,
+ n->num_dir_idx_bytes);
}
case SQFS_INODE_EXT_FILE: {
sqfs_inode_file_ext_t file = {
@@ -171,7 +172,7 @@ int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *ir,
ret = sqfs_meta_writer_append(ir, &slink, sizeof(slink));
if (ret)
return ret;
- ret = sqfs_meta_writer_append(ir, n->slink_target,
+ ret = sqfs_meta_writer_append(ir, n->extra,
n->data.slink_ext.target_size);
if (ret)
return ret;