summaryrefslogtreecommitdiff
path: root/lib/sqfs/read_table.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-08 14:53:30 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-08 14:53:30 +0200
commit3a851dfe87c88ac1d4dddc2a26cc48b037f852f9 (patch)
treea8a8f34291aa58b25737088d247a91a7f60b4fec /lib/sqfs/read_table.c
parent60064dd0412a149fe00cfc4e2f2361c22656db57 (diff)
Replace direct file I/O with abstraction layer
This should make it easier to use libsquashfs with custom setups that embedd a squashfs image inside something else. Also, it should make it easier to port to non unix-like platforms. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/read_table.c')
-rw-r--r--lib/sqfs/read_table.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/sqfs/read_table.c b/lib/sqfs/read_table.c
index 843247e..129ecaf 100644
--- a/lib/sqfs/read_table.c
+++ b/lib/sqfs/read_table.c
@@ -11,13 +11,14 @@
#include "sqfs/error.h"
#include "sqfs/table.h"
#include "sqfs/data.h"
+#include "sqfs/io.h"
#include "util.h"
#include <endian.h>
#include <stdlib.h>
-int sqfs_read_table(int fd, sqfs_compressor_t *cmp, size_t table_size,
- uint64_t location, uint64_t lower_limit,
+int sqfs_read_table(sqfs_file_t *file, sqfs_compressor_t *cmp,
+ size_t table_size, uint64_t location, uint64_t lower_limit,
uint64_t upper_limit, void **out)
{
size_t diff, block_count, blk_idx = 0;
@@ -43,14 +44,13 @@ int sqfs_read_table(int fd, sqfs_compressor_t *cmp, size_t table_size,
goto fail_data;
}
- if (read_data_at("reading table locations", location,
- fd, locations, sizeof(uint64_t) * block_count)) {
- err = SQFS_ERROR_IO;
+ err = file->read_at(file, location, locations,
+ sizeof(uint64_t) * block_count);
+ if (err)
goto fail_idx;
- }
/* Read the actual data */
- m = sqfs_meta_reader_create(fd, cmp, lower_limit, upper_limit);
+ m = sqfs_meta_reader_create(file, cmp, lower_limit, upper_limit);
if (m == NULL) {
err = SQFS_ERROR_ALLOC;
goto fail_idx;