aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-20 22:50:10 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-20 22:50:10 +0200
commit79498fa15227d4659489763ed2a9a1e806c11428 (patch)
treecaf6fcb8132b30afa260b4be1b853cca67cbd381 /lib
parent012a83c9466e8668fc08acb6a80fa4dd5c82997c (diff)
Integrate the data reader into libsquashfs
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/sqfs/Makemodule.am5
-rw-r--r--lib/sqfs/data_reader.c (renamed from lib/sqfshelper/data_reader.c)25
-rw-r--r--lib/sqfshelper/Makemodule.am1
-rw-r--r--lib/sqfshelper/data_reader_dump.c2
4 files changed, 15 insertions, 18 deletions
diff --git a/lib/sqfs/Makemodule.am b/lib/sqfs/Makemodule.am
index 66d49b6..cb003c0 100644
--- a/lib/sqfs/Makemodule.am
+++ b/lib/sqfs/Makemodule.am
@@ -5,7 +5,8 @@ LIBSQFS_HEARDS = include/sqfs/data.h include/sqfs/meta_writer.h \
include/sqfs/dir.h include/sqfs/xattr.h \
include/sqfs/table.h include/sqfs/predef.h \
include/sqfs/error.h include/sqfs/dir_reader.h \
- include/sqfs/dir_writer.h include/sqfs/io.h
+ include/sqfs/dir_writer.h include/sqfs/io.h \
+ include/sqfs/data_reader.h
libsquashfs_la_SOURCES = $(LIBSQFS_HEARDS) lib/sqfs/id_table.c lib/sqfs/super.c
libsquashfs_la_SOURCES += lib/sqfs/readdir.c lib/sqfs/io_file.c lib/sqfs/xattr.c
@@ -17,7 +18,7 @@ libsquashfs_la_SOURCES += lib/sqfs/read_table.c lib/sqfs/comp/compressor.c
libsquashfs_la_SOURCES += lib/sqfs/io_stdin.c lib/sqfs/comp/internal.h
libsquashfs_la_SOURCES += lib/sqfs/dir_reader.c lib/sqfs/read_tree.c
libsquashfs_la_SOURCES += lib/sqfs/blk_proc/process_block.c lib/sqfs/io.c
-libsquashfs_la_SOURCES += lib/sqfs/blk_proc/internal.h
+libsquashfs_la_SOURCES += lib/sqfs/blk_proc/internal.h lib/sqfs/data_reader.c
libsquashfs_la_CPPFLAGS = $(AM_CPPFLAGS)
libsquashfs_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) $(ZLIB_CFLAGS)
libsquashfs_la_CFLAGS += $(XZ_CFLAGS) $(LZO_CFLAGS) $(LZ4_CFLAGS)
diff --git a/lib/sqfshelper/data_reader.c b/lib/sqfs/data_reader.c
index bf808ba..3de59ff 100644
--- a/lib/sqfshelper/data_reader.c
+++ b/lib/sqfs/data_reader.c
@@ -1,22 +1,24 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
+/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
* data_reader.c
*
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
+#define SQFS_BUILDING_DLL
#include "config.h"
#include "sqfs/block_processor.h"
+#include "sqfs/data_reader.h"
+#include "sqfs/compress.h"
#include "sqfs/error.h"
-
-#include "data_reader.h"
-#include "highlevel.h"
+#include "sqfs/table.h"
+#include "sqfs/inode.h"
+#include "sqfs/data.h"
+#include "sqfs/io.h"
#include "util.h"
#include <stdlib.h>
-#include <unistd.h>
#include <string.h>
-#include <stdio.h>
struct sqfs_data_reader_t {
sqfs_fragment_t *frag;
@@ -113,10 +115,8 @@ static int precache_fragment_block(sqfs_data_reader_t *data, size_t idx)
if (data->frag_block != NULL && idx == data->current_frag_index)
return 0;
- if (idx >= data->num_fragments) {
- fputs("fragment index out of bounds\n", stderr);
- return -1;
- }
+ if (idx >= data->num_fragments)
+ return SQFS_ERROR_OUT_OF_BOUNDS;
free(data->frag_block);
@@ -351,7 +351,7 @@ ssize_t sqfs_data_reader_read(sqfs_data_reader_t *data,
return -1;
if (frag_off + filesz > data->block_size)
- goto fail_range;
+ return SQFS_ERROR_OUT_OF_BOUNDS;
if (offset >= filesz)
return total;
@@ -368,7 +368,4 @@ ssize_t sqfs_data_reader_read(sqfs_data_reader_t *data,
}
return total;
-fail_range:
- fputs("attempted to read past fragment block limits\n", stderr);
- return -1;
}
diff --git a/lib/sqfshelper/Makemodule.am b/lib/sqfshelper/Makemodule.am
index d711cf2..b85e6a5 100644
--- a/lib/sqfshelper/Makemodule.am
+++ b/lib/sqfshelper/Makemodule.am
@@ -6,7 +6,6 @@ libsqfshelper_a_SOURCES += lib/sqfshelper/print_version.c
libsqfshelper_a_SOURCES += lib/sqfshelper/inode_stat.c
libsqfshelper_a_SOURCES += lib/sqfshelper/data_reader_dump.c
libsqfshelper_a_SOURCES += lib/sqfshelper/compress.c lib/sqfshelper/comp_opt.c
-libsqfshelper_a_SOURCES += include/data_reader.h lib/sqfshelper/data_reader.c
libsqfshelper_a_SOURCES += include/data_writer.h lib/sqfshelper/data_writer.c
libsqfshelper_a_SOURCES += lib/sqfshelper/write_xattr.c include/highlevel.h
libsqfshelper_a_SOURCES += lib/sqfshelper/get_path.c
diff --git a/lib/sqfshelper/data_reader_dump.c b/lib/sqfshelper/data_reader_dump.c
index 0c7a0cc..e28bf20 100644
--- a/lib/sqfshelper/data_reader_dump.c
+++ b/lib/sqfshelper/data_reader_dump.c
@@ -7,7 +7,7 @@
#include "config.h"
#include "sqfs/block_processor.h"
-#include "data_reader.h"
+#include "sqfs/data_reader.h"
#include "highlevel.h"
#include "util.h"