aboutsummaryrefslogtreecommitdiff
path: root/lib/sqfshelper
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-01 23:08:04 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-01 23:08:36 +0200
commit9d9d4505f58b6584fe3b261a7686c5d779f77c11 (patch)
tree7f1a086abc273c55c4d3a9cf96144715e3d15329 /lib/sqfshelper
parent307107ecd2fc3ffbf6fe91497daf767700f3572f (diff)
Internalize the layout of the id_table_t structure
As an opaque struct it has a chance to change its layout in the future without breaking ABI compatibiliy. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfshelper')
-rw-r--r--lib/sqfshelper/deserialize_fstree.c13
-rw-r--r--lib/sqfshelper/tree_node_from_inode.c18
2 files changed, 14 insertions, 17 deletions
diff --git a/lib/sqfshelper/deserialize_fstree.c b/lib/sqfshelper/deserialize_fstree.c
index 232c382..c418b16 100644
--- a/lib/sqfshelper/deserialize_fstree.c
+++ b/lib/sqfshelper/deserialize_fstree.c
@@ -207,7 +207,7 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super, compressor_t *cmp,
sqfs_inode_generic_t *root;
meta_reader_t *ir, *dr;
xattr_reader_t *xr;
- id_table_t idtbl;
+ id_table_t *idtbl;
int status = -1;
size_t offset;
@@ -226,10 +226,11 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super, compressor_t *cmp,
if (dr == NULL)
goto out_ir;
- if (id_table_init(&idtbl))
+ idtbl = id_table_create();
+ if (idtbl == NULL)
goto out_dr;
- if (id_table_read(&idtbl, fd, super, cmp))
+ if (id_table_read(idtbl, fd, super, cmp))
goto out_id;
xr = xattr_reader_create(fd, super, cmp);
@@ -257,7 +258,7 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super, compressor_t *cmp,
out->defaults.st_mode = 0755;
out->defaults.st_mtime = super->modification_time;
- out->root = tree_node_from_inode(root, &idtbl, "", super->block_size);
+ out->root = tree_node_from_inode(root, idtbl, "", super->block_size);
if (out->root == NULL) {
free(root);
@@ -285,7 +286,7 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super, compressor_t *cmp,
free(root);
- if (fill_dir(ir, dr, out->root, super, &idtbl, out, xr, flags))
+ if (fill_dir(ir, dr, out->root, super, idtbl, out, xr, flags))
goto fail_fs;
tree_node_sort_recursive(out->root);
@@ -294,7 +295,7 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super, compressor_t *cmp,
out_xr:
xattr_reader_destroy(xr);
out_id:
- id_table_cleanup(&idtbl);
+ id_table_destroy(idtbl);
out_dr:
meta_reader_destroy(dr);
out_ir:
diff --git a/lib/sqfshelper/tree_node_from_inode.c b/lib/sqfshelper/tree_node_from_inode.c
index 582399c..e77266a 100644
--- a/lib/sqfshelper/tree_node_from_inode.c
+++ b/lib/sqfshelper/tree_node_from_inode.c
@@ -73,26 +73,22 @@ tree_node_t *tree_node_from_inode(sqfs_inode_generic_t *inode,
{
tree_node_t *out;
- if (inode->base.uid_idx >= idtbl->num_ids) {
- fputs("converting inode to fs tree node: UID out of range\n",
- stderr);
+ out = calloc(1, compute_size(inode, name, block_size));
+ if (out == NULL) {
+ perror("converting inode to fs tree node");
return NULL;
}
- if (inode->base.gid_idx >= idtbl->num_ids) {
- fputs("converting inode to fs tree node: GID out of range\n",
- stderr);
+ if (id_table_index_to_id(idtbl, inode->base.uid_idx, &out->uid)) {
+ free(out);
return NULL;
}
- out = calloc(1, compute_size(inode, name, block_size));
- if (out == NULL) {
- perror("converting inode to fs tree node");
+ if (id_table_index_to_id(idtbl, inode->base.gid_idx, &out->gid)) {
+ free(out);
return NULL;
}
- out->uid = idtbl->ids[inode->base.uid_idx];
- out->gid = idtbl->ids[inode->base.gid_idx];
out->mode = inode->base.mode;
out->inode_num = inode->base.inode_number;
out->mod_time = inode->base.mod_time;