summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-20 22:26:56 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-20 22:26:56 +0200
commit012a83c9466e8668fc08acb6a80fa4dd5c82997c (patch)
tree4cd6cb483db184e2fd560a48c3650431cb1fd5d3
parent1a6b70f3702d3bdb0f1cb8e4669ec5ed21ea923b (diff)
Add sqfs_ prefix to data_reader_t & functions
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--difftool/compare_files.c4
-rw-r--r--difftool/extract.c4
-rw-r--r--difftool/sqfsdiff.c11
-rw-r--r--difftool/sqfsdiff.h2
-rw-r--r--include/data_reader.h36
-rw-r--r--lib/sqfshelper/data_reader.c39
-rw-r--r--lib/sqfshelper/data_reader_dump.c9
-rw-r--r--tar/sqfs2tar.c12
-rw-r--r--unpack/fill_files.c8
-rw-r--r--unpack/rdsquashfs.c12
-rw-r--r--unpack/rdsquashfs.h2
11 files changed, 72 insertions, 67 deletions
diff --git a/difftool/compare_files.c b/difftool/compare_files.c
index 591fc2c..a977d95 100644
--- a/difftool/compare_files.c
+++ b/difftool/compare_files.c
@@ -10,12 +10,12 @@ static unsigned char old_buf[MAX_WINDOW_SIZE];
static unsigned char new_buf[MAX_WINDOW_SIZE];
static int read_blob(const char *prefix, const char *path,
- data_reader_t *rd, const sqfs_inode_generic_t *inode,
+ sqfs_data_reader_t *rd, const sqfs_inode_generic_t *inode,
void *buffer, uint64_t offset, size_t size)
{
ssize_t ret;
- ret = data_reader_read(rd, inode, offset, buffer, size);
+ ret = sqfs_data_reader_read(rd, inode, offset, buffer, size);
ret = (ret < 0 || (size_t)ret < size) ? -1 : 0;
if (ret) {
diff --git a/difftool/extract.c b/difftool/extract.c
index 94477b1..c0cebfd 100644
--- a/difftool/extract.c
+++ b/difftool/extract.c
@@ -6,7 +6,7 @@
*/
#include "sqfsdiff.h"
-static int extract(data_reader_t *data, const sqfs_inode_generic_t *inode,
+static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode,
const char *prefix, const char *path, size_t block_size)
{
char *ptr, *temp;
@@ -27,7 +27,7 @@ static int extract(data_reader_t *data, const sqfs_inode_generic_t *inode,
return -1;
}
- if (data_reader_dump(data, inode, fd, block_size, true)) {
+ if (sqfs_data_reader_dump(data, inode, fd, block_size, true)) {
close(fd);
return -1;
}
diff --git a/difftool/sqfsdiff.c b/difftool/sqfsdiff.c
index 22b8ec6..b0d270a 100644
--- a/difftool/sqfsdiff.c
+++ b/difftool/sqfsdiff.c
@@ -69,19 +69,20 @@ static int open_sfqs(sqfs_state_t *state, const char *path)
goto fail_dr;
}
- state->data = data_reader_create(state->file, state->super.block_size,
- state->cmp);
+ state->data = sqfs_data_reader_create(state->file,
+ state->super.block_size,
+ state->cmp);
if (state->data == NULL) {
fprintf(stderr, "%s: error loading file system tree\n", path);
goto fail_tree;
}
- if (data_reader_load_fragment_table(state->data, &state->super))
+ if (sqfs_data_reader_load_fragment_table(state->data, &state->super))
goto fail_data;
return 0;
fail_data:
- data_reader_destroy(state->data);
+ sqfs_data_reader_destroy(state->data);
fail_tree:
sqfs_dir_tree_destroy(state->root);
fail_dr:
@@ -97,7 +98,7 @@ fail_file:
static void close_sfqs(sqfs_state_t *state)
{
- data_reader_destroy(state->data);
+ sqfs_data_reader_destroy(state->data);
sqfs_dir_tree_destroy(state->root);
sqfs_dir_reader_destroy(state->dr);
sqfs_id_table_destroy(state->idtbl);
diff --git a/difftool/sqfsdiff.h b/difftool/sqfsdiff.h
index 40c0fc5..e274353 100644
--- a/difftool/sqfsdiff.h
+++ b/difftool/sqfsdiff.h
@@ -30,7 +30,7 @@ typedef struct {
sqfs_id_table_t *idtbl;
sqfs_dir_reader_t *dr;
sqfs_tree_node_t *root;
- data_reader_t *data;
+ sqfs_data_reader_t *data;
} sqfs_state_t;
typedef struct {
diff --git a/include/data_reader.h b/include/data_reader.h
index a8ccabf..2ad3749 100644
--- a/include/data_reader.h
+++ b/include/data_reader.h
@@ -13,27 +13,29 @@
#include "sqfs/data.h"
#include "fstree.h"
-typedef struct data_reader_t data_reader_t;
+typedef struct sqfs_data_reader_t sqfs_data_reader_t;
-data_reader_t *data_reader_create(sqfs_file_t *file, size_t block_size,
- sqfs_compressor_t *cmp);
+sqfs_data_reader_t *sqfs_data_reader_create(sqfs_file_t *file,
+ size_t block_size,
+ sqfs_compressor_t *cmp);
-int data_reader_load_fragment_table(data_reader_t *data,
- const sqfs_super_t *super);
+int sqfs_data_reader_load_fragment_table(sqfs_data_reader_t *data,
+ const sqfs_super_t *super);
-void data_reader_destroy(data_reader_t *data);
+void sqfs_data_reader_destroy(sqfs_data_reader_t *data);
-int data_reader_get_fragment(data_reader_t *data,
- const sqfs_inode_generic_t *inode,
- sqfs_block_t **out);
+int sqfs_data_reader_get_fragment(sqfs_data_reader_t *data,
+ const sqfs_inode_generic_t *inode,
+ sqfs_block_t **out);
-int data_reader_get_block(data_reader_t *data,
- const sqfs_inode_generic_t *inode,
- size_t index, sqfs_block_t **out);
+int sqfs_data_reader_get_block(sqfs_data_reader_t *data,
+ const sqfs_inode_generic_t *inode,
+ size_t index, sqfs_block_t **out);
-int data_reader_dump(data_reader_t *data, const sqfs_inode_generic_t *inode,
- int outfd, size_t block_size, bool allow_sparse);
+int sqfs_data_reader_dump(sqfs_data_reader_t *data,
+ const sqfs_inode_generic_t *inode,
+ int outfd, size_t block_size, bool allow_sparse);
/*
Read a chunk of data from a file. Starting from 'offset' into the
@@ -42,8 +44,8 @@ int data_reader_dump(data_reader_t *data, const sqfs_inode_generic_t *inode,
Returns the number of bytes read, 0 if EOF, -1 on failure. Prints an
error message to stderr on failure.
*/
-ssize_t data_reader_read(data_reader_t *data,
- const sqfs_inode_generic_t *inode,
- uint64_t offset, void *buffer, size_t size);
+ssize_t sqfs_data_reader_read(sqfs_data_reader_t *data,
+ const sqfs_inode_generic_t *inode,
+ uint64_t offset, void *buffer, size_t size);
#endif /* DATA_READER_H */
diff --git a/lib/sqfshelper/data_reader.c b/lib/sqfshelper/data_reader.c
index d054069..bf808ba 100644
--- a/lib/sqfshelper/data_reader.c
+++ b/lib/sqfshelper/data_reader.c
@@ -18,7 +18,7 @@
#include <string.h>
#include <stdio.h>
-struct data_reader_t {
+struct sqfs_data_reader_t {
sqfs_fragment_t *frag;
sqfs_compressor_t *cmp;
sqfs_block_t *data_block;
@@ -35,7 +35,7 @@ struct data_reader_t {
uint8_t scratch[];
};
-static int get_block(data_reader_t *data, uint64_t off, uint32_t size,
+static int get_block(sqfs_data_reader_t *data, uint64_t off, uint32_t size,
size_t unpacked_size, sqfs_block_t **out)
{
sqfs_block_t *blk = alloc_flex(sizeof(*blk), 1, unpacked_size);
@@ -84,7 +84,7 @@ static int get_block(data_reader_t *data, uint64_t off, uint32_t size,
return 0;
}
-static int precache_data_block(data_reader_t *data, uint64_t location,
+static int precache_data_block(sqfs_data_reader_t *data, uint64_t location,
uint32_t size)
{
int ret;
@@ -106,7 +106,7 @@ static int precache_data_block(data_reader_t *data, uint64_t location,
return 0;
}
-static int precache_fragment_block(data_reader_t *data, size_t idx)
+static int precache_fragment_block(sqfs_data_reader_t *data, size_t idx)
{
int ret;
@@ -130,10 +130,11 @@ static int precache_fragment_block(data_reader_t *data, size_t idx)
return 0;
}
-data_reader_t *data_reader_create(sqfs_file_t *file, size_t block_size,
- sqfs_compressor_t *cmp)
+sqfs_data_reader_t *sqfs_data_reader_create(sqfs_file_t *file,
+ size_t block_size,
+ sqfs_compressor_t *cmp)
{
- data_reader_t *data = alloc_flex(sizeof(*data), 1, block_size);
+ sqfs_data_reader_t *data = alloc_flex(sizeof(*data), 1, block_size);
if (data != NULL) {
data->file = file;
@@ -144,8 +145,8 @@ data_reader_t *data_reader_create(sqfs_file_t *file, size_t block_size,
return data;
}
-int data_reader_load_fragment_table(data_reader_t *data,
- const sqfs_super_t *super)
+int sqfs_data_reader_load_fragment_table(sqfs_data_reader_t *data,
+ const sqfs_super_t *super)
{
void *raw_frag;
size_t size;
@@ -193,7 +194,7 @@ int data_reader_load_fragment_table(data_reader_t *data,
return 0;
}
-void data_reader_destroy(data_reader_t *data)
+void sqfs_data_reader_destroy(sqfs_data_reader_t *data)
{
free(data->data_block);
free(data->frag_block);
@@ -201,9 +202,9 @@ void data_reader_destroy(data_reader_t *data)
free(data);
}
-int data_reader_get_block(data_reader_t *data,
- const sqfs_inode_generic_t *inode,
- size_t index, sqfs_block_t **out)
+int sqfs_data_reader_get_block(sqfs_data_reader_t *data,
+ const sqfs_inode_generic_t *inode,
+ size_t index, sqfs_block_t **out)
{
size_t i, unpacked_size;
uint64_t off, filesz;
@@ -232,9 +233,9 @@ int data_reader_get_block(data_reader_t *data,
unpacked_size, out);
}
-int data_reader_get_fragment(data_reader_t *data,
- const sqfs_inode_generic_t *inode,
- sqfs_block_t **out)
+int sqfs_data_reader_get_fragment(sqfs_data_reader_t *data,
+ const sqfs_inode_generic_t *inode,
+ sqfs_block_t **out)
{
uint32_t frag_idx, frag_off, frag_sz;
sqfs_block_t *blk;
@@ -276,9 +277,9 @@ int data_reader_get_fragment(data_reader_t *data,
return 0;
}
-ssize_t data_reader_read(data_reader_t *data,
- const sqfs_inode_generic_t *inode,
- uint64_t offset, void *buffer, size_t size)
+ssize_t sqfs_data_reader_read(sqfs_data_reader_t *data,
+ const sqfs_inode_generic_t *inode,
+ uint64_t offset, void *buffer, size_t size)
{
uint32_t frag_idx, frag_off;
size_t i, diff, total = 0;
diff --git a/lib/sqfshelper/data_reader_dump.c b/lib/sqfshelper/data_reader_dump.c
index 23cd482..0c7a0cc 100644
--- a/lib/sqfshelper/data_reader_dump.c
+++ b/lib/sqfshelper/data_reader_dump.c
@@ -16,8 +16,9 @@
#include <string.h>
#include <stdio.h>
-int data_reader_dump(data_reader_t *data, const sqfs_inode_generic_t *inode,
- int outfd, size_t block_size, bool allow_sparse)
+int sqfs_data_reader_dump(sqfs_data_reader_t *data,
+ const sqfs_inode_generic_t *inode,
+ int outfd, size_t block_size, bool allow_sparse)
{
sqfs_block_t *blk;
uint64_t filesz;
@@ -47,7 +48,7 @@ int data_reader_dump(data_reader_t *data, const sqfs_inode_generic_t *inode,
if (lseek(outfd, diff, SEEK_CUR) == (off_t)-1)
goto fail_sparse;
} else {
- err = data_reader_get_block(data, inode, i, &blk);
+ err = sqfs_data_reader_get_block(data, inode, i, &blk);
if (err) {
fprintf(stderr, "error reading "
"data block: %d\n", err);
@@ -66,7 +67,7 @@ int data_reader_dump(data_reader_t *data, const sqfs_inode_generic_t *inode,
}
if (filesz > 0) {
- if (data_reader_get_fragment(data, inode, &blk)) {
+ if (sqfs_data_reader_get_fragment(data, inode, &blk)) {
fputs("error reading fragment block", stderr);
return -1;
}
diff --git a/tar/sqfs2tar.c b/tar/sqfs2tar.c
index 7f388fe..f628807 100644
--- a/tar/sqfs2tar.c
+++ b/tar/sqfs2tar.c
@@ -79,7 +79,7 @@ static size_t num_subdirs = 0;
static size_t max_subdirs = 0;
static sqfs_xattr_reader_t *xr;
-static data_reader_t *data;
+static sqfs_data_reader_t *data;
static sqfs_file_t *file;
static sqfs_super_t super;
@@ -317,8 +317,8 @@ static int write_tree_dfs(const sqfs_tree_node_t *n)
return -1;
if (S_ISREG(sb.st_mode)) {
- if (data_reader_dump(data, n->inode, STDOUT_FILENO,
- super.block_size, false))
+ if (sqfs_data_reader_dump(data, n->inode, STDOUT_FILENO,
+ super.block_size, false))
return -1;
if (padd_file(STDOUT_FILENO, sb.st_size, 512))
@@ -434,11 +434,11 @@ int main(int argc, char **argv)
goto out_id;
}
- data = data_reader_create(file, super.block_size, cmp);
+ data = sqfs_data_reader_create(file, super.block_size, cmp);
if (data == NULL)
goto out_id;
- if (data_reader_load_fragment_table(data, &super))
+ if (sqfs_data_reader_load_fragment_table(data, &super))
goto out_data;
dr = sqfs_dir_reader_create(&super, cmp, file);
@@ -507,7 +507,7 @@ out_xr:
out_dr:
sqfs_dir_reader_destroy(dr);
out_data:
- data_reader_destroy(data);
+ sqfs_data_reader_destroy(data);
out_id:
sqfs_id_table_destroy(idtbl);
out_cmp:
diff --git a/unpack/fill_files.c b/unpack/fill_files.c
index f98a801..2c20ab0 100644
--- a/unpack/fill_files.c
+++ b/unpack/fill_files.c
@@ -156,7 +156,7 @@ static int gen_file_list_dfs(const sqfs_tree_node_t *n)
return 0;
}
-static int fill_files(data_reader_t *data, int flags)
+static int fill_files(sqfs_data_reader_t *data, int flags)
{
size_t i;
int fd;
@@ -172,8 +172,8 @@ static int fill_files(data_reader_t *data, int flags)
if (!(flags & UNPACK_QUIET))
printf("unpacking %s\n", files[i].path);
- if (data_reader_dump(data, files[i].inode, fd, block_size,
- (flags & UNPACK_NO_SPARSE) == 0)) {
+ if (sqfs_data_reader_dump(data, files[i].inode, fd, block_size,
+ (flags & UNPACK_NO_SPARSE) == 0)) {
close(fd);
return -1;
}
@@ -185,7 +185,7 @@ static int fill_files(data_reader_t *data, int flags)
}
int fill_unpacked_files(size_t blk_sz, const sqfs_tree_node_t *root,
- data_reader_t *data, int flags)
+ sqfs_data_reader_t *data, int flags)
{
int status;
diff --git a/unpack/rdsquashfs.c b/unpack/rdsquashfs.c
index 29f9b79..7bb1ab4 100644
--- a/unpack/rdsquashfs.c
+++ b/unpack/rdsquashfs.c
@@ -11,11 +11,11 @@ int main(int argc, char **argv)
sqfs_xattr_reader_t *xattr = NULL;
sqfs_compressor_config_t cfg;
int status = EXIT_FAILURE;
+ sqfs_data_reader_t *data;
sqfs_dir_reader_t *dirrd;
sqfs_compressor_t *cmp;
sqfs_id_table_t *idtbl;
sqfs_tree_node_t *n;
- data_reader_t *data;
sqfs_super_t super;
sqfs_file_t *file;
options_t opt;
@@ -80,11 +80,11 @@ int main(int argc, char **argv)
goto out_id;
}
- data = data_reader_create(file, super.block_size, cmp);
+ data = sqfs_data_reader_create(file, super.block_size, cmp);
if (data == NULL)
goto out_dr;
- if (data_reader_load_fragment_table(data, &super))
+ if (sqfs_data_reader_load_fragment_table(data, &super))
goto out_data;
ret = sqfs_dir_reader_get_full_hierarchy(dirrd, idtbl, opt.cmdpath,
@@ -105,8 +105,8 @@ int main(int argc, char **argv)
goto out;
}
- if (data_reader_dump(data, n->inode, STDOUT_FILENO,
- super.block_size, false))
+ if (sqfs_data_reader_dump(data, n->inode, STDOUT_FILENO,
+ super.block_size, false))
goto out;
break;
case OP_UNPACK:
@@ -144,7 +144,7 @@ int main(int argc, char **argv)
out:
sqfs_dir_tree_destroy(n);
out_data:
- data_reader_destroy(data);
+ sqfs_data_reader_destroy(data);
out_dr:
sqfs_dir_reader_destroy(dirrd);
out_id:
diff --git a/unpack/rdsquashfs.h b/unpack/rdsquashfs.h
index e348293..dafb73d 100644
--- a/unpack/rdsquashfs.h
+++ b/unpack/rdsquashfs.h
@@ -72,7 +72,7 @@ int update_tree_attribs(sqfs_xattr_reader_t *xattr,
const sqfs_tree_node_t *root, int flags);
int fill_unpacked_files(size_t blk_sz, const sqfs_tree_node_t *root,
- data_reader_t *data, int flags);
+ sqfs_data_reader_t *data, int flags);
int describe_tree(const sqfs_tree_node_t *root, const char *unpack_root);