aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-05 17:17:38 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-05 17:17:53 +0200
commita4b4c27bb01e64ff0072be78f7ddc0fa64193bfa (patch)
tree463fc886baae6b12f01c22c8a53ac94491d8a2ad
parentdd5d7adaa914982e8947bfe76fa3f195ed11cdb1 (diff)
Cleanup: add sqfs_* prefix to meta reader
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--include/sqfs/dir.h5
-rw-r--r--include/sqfs/inode.h8
-rw-r--r--include/sqfs/meta_reader.h25
-rw-r--r--lib/sqfs/meta_reader.c21
-rw-r--r--lib/sqfs/read_inode.c60
-rw-r--r--lib/sqfs/read_table.c12
-rw-r--r--lib/sqfs/readdir.c11
-rw-r--r--lib/sqfs/xattr_reader.c42
-rw-r--r--lib/sqfshelper/deserialize_fstree.c35
9 files changed, 114 insertions, 105 deletions
diff --git a/include/sqfs/dir.h b/include/sqfs/dir.h
index 22f8a57..c57831c 100644
--- a/include/sqfs/dir.h
+++ b/include/sqfs/dir.h
@@ -44,11 +44,12 @@ extern "C" {
#endif
/* Returns 0 on success. Internally prints to stderr on failure */
-int meta_reader_read_dir_header(meta_reader_t *m, sqfs_dir_header_t *hdr);
+int sqfs_meta_reader_read_dir_header(sqfs_meta_reader_t *m,
+ sqfs_dir_header_t *hdr);
/* Entry can be freed with a single free() call.
The function internally prints to stderr on failure */
-sqfs_dir_entry_t *meta_reader_read_dir_ent(meta_reader_t *m);
+sqfs_dir_entry_t *sqfs_meta_reader_read_dir_ent(sqfs_meta_reader_t *m);
sqfs_dir_writer_t *sqfs_dir_writer_create(sqfs_meta_writer_t *dm);
diff --git a/include/sqfs/inode.h b/include/sqfs/inode.h
index 20c8fa2..d693aec 100644
--- a/include/sqfs/inode.h
+++ b/include/sqfs/inode.h
@@ -138,10 +138,10 @@ extern "C" {
/* Inode can be freed with a single free() call.
The function internally prints error message to stderr on failure. */
-sqfs_inode_generic_t *meta_reader_read_inode(meta_reader_t *ir,
- sqfs_super_t *super,
- uint64_t block_start,
- size_t offset);
+sqfs_inode_generic_t *sqfs_meta_reader_read_inode(sqfs_meta_reader_t *ir,
+ sqfs_super_t *super,
+ uint64_t block_start,
+ size_t offset);
int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *iw,
sqfs_inode_generic_t *n);
diff --git a/include/sqfs/meta_reader.h b/include/sqfs/meta_reader.h
index ab9f46d..1517e67 100644
--- a/include/sqfs/meta_reader.h
+++ b/include/sqfs/meta_reader.h
@@ -4,15 +4,15 @@
*
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
-#ifndef META_READER_H
-#define META_READER_H
+#ifndef SQFS_META_READER_H
+#define SQFS_META_READER_H
#include "config.h"
#include "sqfs/compress.h"
#include "sqfs/data.h"
-typedef struct meta_reader_t meta_reader_t;
+typedef struct sqfs_meta_reader_t sqfs_meta_reader_t;
#ifdef __cplusplus
extern "C" {
@@ -24,23 +24,24 @@ extern "C" {
Start offset and limit can be specified to do bounds checking against
a subregion of the filesystem image.
*/
-meta_reader_t *meta_reader_create(int fd, compressor_t *cmp,
- uint64_t start, uint64_t limit);
+sqfs_meta_reader_t *sqfs_meta_reader_create(int fd, compressor_t *cmp,
+ uint64_t start, uint64_t limit);
-void meta_reader_destroy(meta_reader_t *m);
+void sqfs_meta_reader_destroy(sqfs_meta_reader_t *m);
/* Returns 0 on success. Internally prints to stderr on failure */
-int meta_reader_seek(meta_reader_t *m, uint64_t block_start,
- size_t offset);
+int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, uint64_t block_start,
+ size_t offset);
-void meta_reader_get_position(meta_reader_t *m, uint64_t *block_start,
- size_t *offset);
+void sqfs_meta_reader_get_position(sqfs_meta_reader_t *m,
+ uint64_t *block_start,
+ size_t *offset);
/* Returns 0 on success. Internally prints to stderr on failure */
-int meta_reader_read(meta_reader_t *m, void *data, size_t size);
+int sqfs_meta_reader_read(sqfs_meta_reader_t *m, void *data, size_t size);
#ifdef __cplusplus
}
#endif
-#endif /* META_READER_H */
+#endif /* SQFS_META_READER_H */
diff --git a/lib/sqfs/meta_reader.c b/lib/sqfs/meta_reader.c
index 0183255..0fd892e 100644
--- a/lib/sqfs/meta_reader.c
+++ b/lib/sqfs/meta_reader.c
@@ -14,7 +14,7 @@
#include <string.h>
#include <stdio.h>
-struct meta_reader_t {
+struct sqfs_meta_reader_t {
uint64_t start;
uint64_t limit;
size_t data_used;
@@ -41,10 +41,10 @@ struct meta_reader_t {
uint8_t scratch[SQFS_META_BLOCK_SIZE];
};
-meta_reader_t *meta_reader_create(int fd, compressor_t *cmp,
- uint64_t start, uint64_t limit)
+sqfs_meta_reader_t *sqfs_meta_reader_create(int fd, compressor_t *cmp,
+ uint64_t start, uint64_t limit)
{
- meta_reader_t *m = calloc(1, sizeof(*m));
+ sqfs_meta_reader_t *m = calloc(1, sizeof(*m));
if (m == NULL) {
perror("creating meta data reader");
@@ -58,12 +58,13 @@ meta_reader_t *meta_reader_create(int fd, compressor_t *cmp,
return m;
}
-void meta_reader_destroy(meta_reader_t *m)
+void sqfs_meta_reader_destroy(sqfs_meta_reader_t *m)
{
free(m);
}
-int meta_reader_seek(meta_reader_t *m, uint64_t block_start, size_t offset)
+int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, uint64_t block_start,
+ size_t offset)
{
bool compressed;
uint16_t header;
@@ -139,14 +140,14 @@ fail_range:
return -1;
}
-void meta_reader_get_position(meta_reader_t *m, uint64_t *block_start,
- size_t *offset)
+void sqfs_meta_reader_get_position(sqfs_meta_reader_t *m, uint64_t *block_start,
+ size_t *offset)
{
*block_start = m->block_offset;
*offset = m->offset;
}
-int meta_reader_read(meta_reader_t *m, void *data, size_t size)
+int sqfs_meta_reader_read(sqfs_meta_reader_t *m, void *data, size_t size)
{
size_t diff;
@@ -154,7 +155,7 @@ int meta_reader_read(meta_reader_t *m, void *data, size_t size)
diff = m->data_used - m->offset;
if (diff == 0) {
- if (meta_reader_seek(m, m->next_block, 0))
+ if (sqfs_meta_reader_seek(m, m->next_block, 0))
return -1;
diff = m->data_used;
}
diff --git a/lib/sqfs/read_inode.c b/lib/sqfs/read_inode.c
index 6da9653..90cc060 100644
--- a/lib/sqfs/read_inode.c
+++ b/lib/sqfs/read_inode.c
@@ -72,7 +72,7 @@ static uint64_t get_block_count(uint64_t size, uint64_t block_size,
return count;
}
-static sqfs_inode_generic_t *read_inode_file(meta_reader_t *ir,
+static sqfs_inode_generic_t *read_inode_file(sqfs_meta_reader_t *ir,
sqfs_inode_t *base,
size_t block_size)
{
@@ -80,7 +80,7 @@ static sqfs_inode_generic_t *read_inode_file(meta_reader_t *ir,
sqfs_inode_file_t file;
uint64_t i, count;
- if (meta_reader_read(ir, &file, sizeof(file)))
+ if (sqfs_meta_reader_read(ir, &file, sizeof(file)))
return NULL;
SWAB32(file.blocks_start);
@@ -102,7 +102,8 @@ static sqfs_inode_generic_t *read_inode_file(meta_reader_t *ir,
out->block_sizes = (uint32_t *)out->extra;
out->num_file_blocks = count;
- if (meta_reader_read(ir, out->block_sizes, count * sizeof(uint32_t))) {
+ if (sqfs_meta_reader_read(ir, out->block_sizes,
+ count * sizeof(uint32_t))) {
free(out);
return NULL;
}
@@ -113,7 +114,7 @@ static sqfs_inode_generic_t *read_inode_file(meta_reader_t *ir,
return out;
}
-static sqfs_inode_generic_t *read_inode_file_ext(meta_reader_t *ir,
+static sqfs_inode_generic_t *read_inode_file_ext(sqfs_meta_reader_t *ir,
sqfs_inode_t *base,
size_t block_size)
{
@@ -121,7 +122,7 @@ static sqfs_inode_generic_t *read_inode_file_ext(meta_reader_t *ir,
sqfs_inode_generic_t *out;
uint64_t i, count;
- if (meta_reader_read(ir, &file, sizeof(file)))
+ if (sqfs_meta_reader_read(ir, &file, sizeof(file)))
return NULL;
SWAB64(file.blocks_start);
@@ -146,7 +147,8 @@ static sqfs_inode_generic_t *read_inode_file_ext(meta_reader_t *ir,
out->block_sizes = (uint32_t *)out->extra;
out->num_file_blocks = count;
- if (meta_reader_read(ir, out->block_sizes, count * sizeof(uint32_t))) {
+ if (sqfs_meta_reader_read(ir, out->block_sizes,
+ count * sizeof(uint32_t))) {
free(out);
return NULL;
}
@@ -157,14 +159,14 @@ static sqfs_inode_generic_t *read_inode_file_ext(meta_reader_t *ir,
return out;
}
-static sqfs_inode_generic_t *read_inode_slink(meta_reader_t *ir,
+static sqfs_inode_generic_t *read_inode_slink(sqfs_meta_reader_t *ir,
sqfs_inode_t *base)
{
sqfs_inode_generic_t *out;
sqfs_inode_slink_t slink;
size_t size;
- if (meta_reader_read(ir, &slink, sizeof(slink)))
+ if (sqfs_meta_reader_read(ir, &slink, sizeof(slink)))
return NULL;
SWAB32(slink.nlink);
@@ -184,7 +186,7 @@ static sqfs_inode_generic_t *read_inode_slink(meta_reader_t *ir,
out->base = *base;
out->data.slink = slink;
- if (meta_reader_read(ir, out->slink_target, slink.target_size)) {
+ if (sqfs_meta_reader_read(ir, out->slink_target, slink.target_size)) {
free(out);
return NULL;
}
@@ -195,14 +197,14 @@ fail:
return NULL;
}
-static sqfs_inode_generic_t *read_inode_slink_ext(meta_reader_t *ir,
+static sqfs_inode_generic_t *read_inode_slink_ext(sqfs_meta_reader_t *ir,
sqfs_inode_t *base)
{
sqfs_inode_generic_t *out = read_inode_slink(ir, base);
uint32_t xattr;
if (out != NULL) {
- if (meta_reader_read(ir, &xattr, sizeof(xattr))) {
+ if (sqfs_meta_reader_read(ir, &xattr, sizeof(xattr))) {
free(out);
return NULL;
}
@@ -213,10 +215,10 @@ static sqfs_inode_generic_t *read_inode_slink_ext(meta_reader_t *ir,
return out;
}
-sqfs_inode_generic_t *meta_reader_read_inode(meta_reader_t *ir,
- sqfs_super_t *super,
- uint64_t block_start,
- size_t offset)
+sqfs_inode_generic_t *sqfs_meta_reader_read_inode(sqfs_meta_reader_t *ir,
+ sqfs_super_t *super,
+ uint64_t block_start,
+ size_t offset)
{
sqfs_inode_generic_t *out;
sqfs_inode_t inode;
@@ -224,10 +226,10 @@ sqfs_inode_generic_t *meta_reader_read_inode(meta_reader_t *ir,
/* read base inode */
block_start += super->inode_table_start;
- if (meta_reader_seek(ir, block_start, offset))
+ if (sqfs_meta_reader_seek(ir, block_start, offset))
return NULL;
- if (meta_reader_read(ir, &inode, sizeof(inode)))
+ if (sqfs_meta_reader_read(ir, &inode, sizeof(inode)))
return NULL;
SWAB16(inode.type);
@@ -265,8 +267,8 @@ sqfs_inode_generic_t *meta_reader_read_inode(meta_reader_t *ir,
switch (inode.type) {
case SQFS_INODE_DIR:
- if (meta_reader_read(ir, &out->data.dir,
- sizeof(out->data.dir))) {
+ if (sqfs_meta_reader_read(ir, &out->data.dir,
+ sizeof(out->data.dir))) {
goto fail_free;
}
SWAB32(out->data.dir.start_block);
@@ -277,8 +279,8 @@ sqfs_inode_generic_t *meta_reader_read_inode(meta_reader_t *ir,
break;
case SQFS_INODE_BDEV:
case SQFS_INODE_CDEV:
- if (meta_reader_read(ir, &out->data.dev,
- sizeof(out->data.dev))) {
+ if (sqfs_meta_reader_read(ir, &out->data.dev,
+ sizeof(out->data.dev))) {
goto fail_free;
}
SWAB32(out->data.dev.nlink);
@@ -286,15 +288,15 @@ sqfs_inode_generic_t *meta_reader_read_inode(meta_reader_t *ir,
break;
case SQFS_INODE_FIFO:
case SQFS_INODE_SOCKET:
- if (meta_reader_read(ir, &out->data.ipc,
- sizeof(out->data.ipc))) {
+ if (sqfs_meta_reader_read(ir, &out->data.ipc,
+ sizeof(out->data.ipc))) {
goto fail_free;
}
SWAB32(out->data.ipc.nlink);
break;
case SQFS_INODE_EXT_DIR:
- if (meta_reader_read(ir, &out->data.dir_ext,
- sizeof(out->data.dir_ext))) {
+ if (sqfs_meta_reader_read(ir, &out->data.dir_ext,
+ sizeof(out->data.dir_ext))) {
goto fail_free;
}
SWAB32(out->data.dir_ext.nlink);
@@ -307,8 +309,8 @@ sqfs_inode_generic_t *meta_reader_read_inode(meta_reader_t *ir,
break;
case SQFS_INODE_EXT_BDEV:
case SQFS_INODE_EXT_CDEV:
- if (meta_reader_read(ir, &out->data.dev_ext,
- sizeof(out->data.dev_ext))) {
+ if (sqfs_meta_reader_read(ir, &out->data.dev_ext,
+ sizeof(out->data.dev_ext))) {
goto fail_free;
}
SWAB32(out->data.dev_ext.nlink);
@@ -317,8 +319,8 @@ sqfs_inode_generic_t *meta_reader_read_inode(meta_reader_t *ir,
break;
case SQFS_INODE_EXT_FIFO:
case SQFS_INODE_EXT_SOCKET:
- if (meta_reader_read(ir, &out->data.ipc_ext,
- sizeof(out->data.ipc_ext))) {
+ if (sqfs_meta_reader_read(ir, &out->data.ipc_ext,
+ sizeof(out->data.ipc_ext))) {
goto fail_free;
}
SWAB32(out->data.ipc_ext.nlink);
diff --git a/lib/sqfs/read_table.c b/lib/sqfs/read_table.c
index e7ba08a..1470fac 100644
--- a/lib/sqfs/read_table.c
+++ b/lib/sqfs/read_table.c
@@ -20,7 +20,7 @@ void *sqfs_read_table(int fd, compressor_t *cmp, size_t table_size,
{
size_t diff, block_count, blk_idx = 0;
uint64_t start, *locations;
- meta_reader_t *m;
+ sqfs_meta_reader_t *m;
void *data, *ptr;
data = malloc(table_size);
@@ -48,7 +48,7 @@ void *sqfs_read_table(int fd, compressor_t *cmp, size_t table_size,
}
/* Read the actual data */
- m = meta_reader_create(fd, cmp, lower_limit, upper_limit);
+ m = sqfs_meta_reader_create(fd, cmp, lower_limit, upper_limit);
if (m == NULL)
goto fail_idx;
@@ -57,25 +57,25 @@ void *sqfs_read_table(int fd, compressor_t *cmp, size_t table_size,
while (table_size > 0) {
start = le64toh(locations[blk_idx++]);
- if (meta_reader_seek(m, start, 0))
+ if (sqfs_meta_reader_seek(m, start, 0))
goto fail;
diff = SQFS_META_BLOCK_SIZE;
if (diff > table_size)
diff = table_size;
- if (meta_reader_read(m, ptr, diff))
+ if (sqfs_meta_reader_read(m, ptr, diff))
goto fail;
ptr = (char *)ptr + diff;
table_size -= diff;
}
- meta_reader_destroy(m);
+ sqfs_meta_reader_destroy(m);
free(locations);
return data;
fail:
- meta_reader_destroy(m);
+ sqfs_meta_reader_destroy(m);
fail_idx:
free(locations);
fail_data:
diff --git a/lib/sqfs/readdir.c b/lib/sqfs/readdir.c
index 31e4c63..310929c 100644
--- a/lib/sqfs/readdir.c
+++ b/lib/sqfs/readdir.c
@@ -12,9 +12,10 @@
#include <string.h>
#include <stdio.h>
-int meta_reader_read_dir_header(meta_reader_t *m, sqfs_dir_header_t *hdr)
+int sqfs_meta_reader_read_dir_header(sqfs_meta_reader_t *m,
+ sqfs_dir_header_t *hdr)
{
- if (meta_reader_read(m, hdr, sizeof(*hdr)))
+ if (sqfs_meta_reader_read(m, hdr, sizeof(*hdr)))
return -1;
hdr->count = le32toh(hdr->count);
@@ -30,12 +31,12 @@ int meta_reader_read_dir_header(meta_reader_t *m, sqfs_dir_header_t *hdr)
return 0;
}
-sqfs_dir_entry_t *meta_reader_read_dir_ent(meta_reader_t *m)
+sqfs_dir_entry_t *sqfs_meta_reader_read_dir_ent(sqfs_meta_reader_t *m)
{
sqfs_dir_entry_t ent, *out;
uint16_t *diff_u16;
- if (meta_reader_read(m, &ent, sizeof(ent)))
+ if (sqfs_meta_reader_read(m, &ent, sizeof(ent)))
return NULL;
diff_u16 = (uint16_t *)&ent.inode_diff;
@@ -52,7 +53,7 @@ sqfs_dir_entry_t *meta_reader_read_dir_ent(meta_reader_t *m)
}
*out = ent;
- if (meta_reader_read(m, out->name, ent.size + 1)) {
+ if (sqfs_meta_reader_read(m, out->name, ent.size + 1)) {
free(out);
return NULL;
}
diff --git a/lib/sqfs/xattr_reader.c b/lib/sqfs/xattr_reader.c
index 3e74424..d7bcbf7 100644
--- a/lib/sqfs/xattr_reader.c
+++ b/lib/sqfs/xattr_reader.c
@@ -23,8 +23,8 @@ struct sqfs_xattr_reader_t {
uint64_t *id_block_starts;
- meta_reader_t *idrd;
- meta_reader_t *kvrd;
+ sqfs_meta_reader_t *idrd;
+ sqfs_meta_reader_t *kvrd;
sqfs_super_t *super;
};
@@ -90,7 +90,7 @@ sqfs_xattr_entry_t *sqfs_xattr_reader_read_key(sqfs_xattr_reader_t *xr)
const char *prefix;
size_t plen, total;
- if (meta_reader_read(xr->kvrd, &key, sizeof(key)))
+ if (sqfs_meta_reader_read(xr->kvrd, &key, sizeof(key)))
return NULL;
key.type = le16toh(key.type);
@@ -119,7 +119,7 @@ sqfs_xattr_entry_t *sqfs_xattr_reader_read_key(sqfs_xattr_reader_t *xr)
*out = key;
memcpy(out->key, prefix, plen);
- if (meta_reader_read(xr->kvrd, out->key + plen, key.size)) {
+ if (sqfs_meta_reader_read(xr->kvrd, out->key + plen, key.size)) {
free(out);
return NULL;
}
@@ -137,14 +137,14 @@ sqfs_xattr_value_t *sqfs_xattr_reader_read_value(sqfs_xattr_reader_t *xr,
sqfs_xattr_value_t value, *out;
uint64_t ref, start, new_start;
- if (meta_reader_read(xr->kvrd, &value, sizeof(value)))
+ if (sqfs_meta_reader_read(xr->kvrd, &value, sizeof(value)))
return NULL;
if (key->type & SQFS_XATTR_FLAG_OOL) {
- if (meta_reader_read(xr->kvrd, &ref, sizeof(ref)))
+ if (sqfs_meta_reader_read(xr->kvrd, &ref, sizeof(ref)))
return NULL;
- meta_reader_get_position(xr->kvrd, &start, &offset);
+ sqfs_meta_reader_get_position(xr->kvrd, &start, &offset);
new_start = xr->xattr_start + (ref >> 16);
new_offset = ref & 0xFFFF;
@@ -161,7 +161,7 @@ sqfs_xattr_value_t *sqfs_xattr_reader_read_value(sqfs_xattr_reader_t *xr,
return NULL;
}
- if (meta_reader_seek(xr->kvrd, new_start, new_offset))
+ if (sqfs_meta_reader_seek(xr->kvrd, new_start, new_offset))
return NULL;
}
@@ -179,11 +179,11 @@ sqfs_xattr_value_t *sqfs_xattr_reader_read_value(sqfs_xattr_reader_t *xr,
*out = value;
- if (meta_reader_read(xr->kvrd, out->value, value.size))
+ if (sqfs_meta_reader_read(xr->kvrd, out->value, value.size))
goto fail;
if (key->type & SQFS_XATTR_FLAG_OOL) {
- if (meta_reader_seek(xr->kvrd, start, offset))
+ if (sqfs_meta_reader_seek(xr->kvrd, start, offset))
goto fail;
}
@@ -202,7 +202,7 @@ int sqfs_xattr_reader_seek_kv(sqfs_xattr_reader_t *xr,
uint32_t offset = desc->xattr & 0xFFFF;
uint64_t block = xr->xattr_start + (desc->xattr >> 16);
- return meta_reader_seek(xr->kvrd, block, offset);
+ return sqfs_meta_reader_seek(xr->kvrd, block, offset);
}
int sqfs_xattr_reader_get_desc(sqfs_xattr_reader_t *xr, uint32_t idx,
@@ -227,10 +227,10 @@ int sqfs_xattr_reader_get_desc(sqfs_xattr_reader_t *xr, uint32_t idx,
offset = (idx * sizeof(*desc)) % SQFS_META_BLOCK_SIZE;
block = (idx * sizeof(*desc)) / SQFS_META_BLOCK_SIZE;
- if (meta_reader_seek(xr->idrd, xr->id_block_starts[block], offset))
+ if (sqfs_meta_reader_seek(xr->idrd, xr->id_block_starts[block], offset))
return -1;
- if (meta_reader_read(xr->idrd, desc, sizeof(*desc)))
+ if (sqfs_meta_reader_read(xr->idrd, desc, sizeof(*desc)))
return -1;
desc->xattr = le64toh(desc->xattr);
@@ -246,10 +246,10 @@ fail_bounds:
void sqfs_xattr_reader_destroy(sqfs_xattr_reader_t *xr)
{
if (xr->kvrd != NULL)
- meta_reader_destroy(xr->kvrd);
+ sqfs_meta_reader_destroy(xr->kvrd);
if (xr->idrd != NULL)
- meta_reader_destroy(xr->idrd);
+ sqfs_meta_reader_destroy(xr->idrd);
free(xr->id_block_starts);
free(xr);
@@ -274,15 +274,15 @@ sqfs_xattr_reader_t *sqfs_xattr_reader_create(int sqfsfd, sqfs_super_t *super,
if (get_id_block_locations(xr, sqfsfd, super))
goto fail;
- xr->idrd = meta_reader_create(sqfsfd, cmp,
- super->id_table_start,
- super->bytes_used);
+ xr->idrd = sqfs_meta_reader_create(sqfsfd, cmp,
+ super->id_table_start,
+ super->bytes_used);
if (xr->idrd == NULL)
goto fail;
- xr->kvrd = meta_reader_create(sqfsfd, cmp,
- super->id_table_start,
- super->bytes_used);
+ xr->kvrd = sqfs_meta_reader_create(sqfsfd, cmp,
+ super->id_table_start,
+ super->bytes_used);
if (xr->kvrd == NULL)
goto fail;
diff --git a/lib/sqfshelper/deserialize_fstree.c b/lib/sqfshelper/deserialize_fstree.c
index 312dde1..71cc57e 100644
--- a/lib/sqfshelper/deserialize_fstree.c
+++ b/lib/sqfshelper/deserialize_fstree.c
@@ -78,9 +78,9 @@ static bool node_would_be_own_parent(tree_node_t *root, tree_node_t *n)
return false;
}
-static int fill_dir(meta_reader_t *ir, meta_reader_t *dr, tree_node_t *root,
- sqfs_super_t *super, id_table_t *idtbl, fstree_t *fs,
- sqfs_xattr_reader_t *xr, int flags)
+static int fill_dir(sqfs_meta_reader_t *ir, sqfs_meta_reader_t *dr,
+ tree_node_t *root, sqfs_super_t *super, id_table_t *idtbl,
+ fstree_t *fs, sqfs_xattr_reader_t *xr, int flags)
{
sqfs_inode_generic_t *inode;
sqfs_dir_header_t hdr;
@@ -97,17 +97,19 @@ static int fill_dir(meta_reader_t *ir, meta_reader_t *dr, tree_node_t *root,
block_start = root->data.dir->start_block;
block_start += super->directory_table_start;
- if (meta_reader_seek(dr, block_start, root->data.dir->block_offset))
+ if (sqfs_meta_reader_seek(dr, block_start,
+ root->data.dir->block_offset)) {
return -1;
+ }
while (size > sizeof(hdr)) {
- if (meta_reader_read_dir_header(dr, &hdr))
+ if (sqfs_meta_reader_read_dir_header(dr, &hdr))
return -1;
size -= sizeof(hdr);
for (i = 0; i <= hdr.count && size > sizeof(*ent); ++i) {
- ent = meta_reader_read_dir_ent(dr);
+ ent = sqfs_meta_reader_read_dir_ent(dr);
if (ent == NULL)
return -1;
@@ -123,9 +125,9 @@ static int fill_dir(meta_reader_t *ir, meta_reader_t *dr, tree_node_t *root,
continue;
}
- inode = meta_reader_read_inode(ir, super,
- hdr.start_block,
- ent->offset);
+ inode = sqfs_meta_reader_read_inode(ir, super,
+ hdr.start_block,
+ ent->offset);
if (inode == NULL) {
free(ent);
return -1;
@@ -203,15 +205,15 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super, compressor_t *cmp,
int fd, int flags)
{
uint64_t block_start, limit;
+ sqfs_meta_reader_t *ir, *dr;
sqfs_inode_generic_t *root;
sqfs_xattr_reader_t *xr;
- meta_reader_t *ir, *dr;
id_table_t *idtbl;
int status = -1;
size_t offset;
- ir = meta_reader_create(fd, cmp, super->inode_table_start,
- super->directory_table_start);
+ ir = sqfs_meta_reader_create(fd, cmp, super->inode_table_start,
+ super->directory_table_start);
if (ir == NULL)
return -1;
@@ -221,7 +223,8 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super, compressor_t *cmp,
if (super->fragment_table_start < limit)
limit = super->fragment_table_start;
- dr = meta_reader_create(fd, cmp, super->directory_table_start, limit);
+ dr = sqfs_meta_reader_create(fd, cmp, super->directory_table_start,
+ limit);
if (dr == NULL)
goto out_ir;
@@ -238,7 +241,7 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super, compressor_t *cmp,
block_start = super->root_inode_ref >> 16;
offset = super->root_inode_ref & 0xFFFF;
- root = meta_reader_read_inode(ir, super, block_start, offset);
+ root = sqfs_meta_reader_read_inode(ir, super, block_start, offset);
if (root == NULL)
goto out_xr;
@@ -296,9 +299,9 @@ out_xr:
out_id:
id_table_destroy(idtbl);
out_dr:
- meta_reader_destroy(dr);
+ sqfs_meta_reader_destroy(dr);
out_ir:
- meta_reader_destroy(ir);
+ sqfs_meta_reader_destroy(ir);
return status;
fail_fs:
fstree_cleanup(out);