aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-15 15:16:03 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-15 15:16:03 +0200
commit484cd01590ec488cca1f8a5c7c76cd223609e299 (patch)
tree0e3bc268688c2feb8773871a43381a998ce846e7
parent8cf84b4995552bad4e77eb795e36c0b1d65a720a (diff)
Migrate file istream/ostream from libio to libsquashfs
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--bin/gensquashfs/src/filemap_xattr.c2
-rw-r--r--bin/gensquashfs/src/fstree_from_file.c2
-rw-r--r--bin/gensquashfs/src/mkfs.c2
-rw-r--r--bin/gensquashfs/src/mkfs.h1
-rw-r--r--bin/rdsquashfs/src/fill_files.c2
-rw-r--r--bin/sqfsdiff/src/extract.c2
-rw-r--r--include/common.h1
-rw-r--r--include/io/file.h94
-rw-r--r--include/sqfs/io.h74
-rw-r--r--lib/io/Makemodule.am4
-rw-r--r--lib/io/src/internal.h1
-rw-r--r--lib/io/src/std.c7
-rw-r--r--lib/sqfs/Makemodule.am7
-rw-r--r--lib/sqfs/src/unix/istream.c (renamed from lib/io/src/unix/istream.c)28
-rw-r--r--lib/sqfs/src/unix/ostream.c (renamed from lib/io/src/unix/ostream.c)20
-rw-r--r--lib/sqfs/src/win32/istream.c (renamed from lib/io/src/win32/istream.c)16
-rw-r--r--lib/sqfs/src/win32/ostream.c (renamed from lib/io/src/win32/ostream.c)14
-rw-r--r--lib/tar/test/tar_big_file.c5
-rw-r--r--lib/tar/test/tar_fuzz.c4
-rw-r--r--lib/tar/test/tar_iterator.c6
-rw-r--r--lib/tar/test/tar_iterator2.c4
-rw-r--r--lib/tar/test/tar_iterator3.c4
-rw-r--r--lib/tar/test/tar_simple.c5
-rw-r--r--lib/tar/test/tar_sparse.c4
-rw-r--r--lib/tar/test/tar_sparse_gnu.c4
-rw-r--r--lib/tar/test/tar_target_filled.c4
-rw-r--r--lib/tar/test/tar_write_simple.c4
-rw-r--r--lib/tar/test/tar_xattr.c5
-rw-r--r--lib/tar/test/tar_xattr_bin.c5
-rw-r--r--lib/util/test/str_table.c6
30 files changed, 174 insertions, 163 deletions
diff --git a/bin/gensquashfs/src/filemap_xattr.c b/bin/gensquashfs/src/filemap_xattr.c
index 8843c46..b9a8835 100644
--- a/bin/gensquashfs/src/filemap_xattr.c
+++ b/bin/gensquashfs/src/filemap_xattr.c
@@ -162,7 +162,7 @@ xattr_open_map_file(const char *path) {
sqfs_istream_t *file = NULL;
int ret;
- ret = istream_open_file(&file, path);
+ ret = sqfs_istream_open_file(&file, path);
if (ret) {
sqfs_perror(path, NULL, ret);
return NULL;
diff --git a/bin/gensquashfs/src/fstree_from_file.c b/bin/gensquashfs/src/fstree_from_file.c
index f392b34..c0b4571 100644
--- a/bin/gensquashfs/src/fstree_from_file.c
+++ b/bin/gensquashfs/src/fstree_from_file.c
@@ -313,7 +313,7 @@ int fstree_from_file(fstree_t *fs, const char *filename, const char *basepath)
sqfs_istream_t *fp;
int ret;
- ret = istream_open_file(&fp, filename);
+ ret = sqfs_istream_open_file(&fp, filename);
if (ret) {
sqfs_perror(filename, NULL, ret);
return -1;
diff --git a/bin/gensquashfs/src/mkfs.c b/bin/gensquashfs/src/mkfs.c
index de291fa..87ad6fc 100644
--- a/bin/gensquashfs/src/mkfs.c
+++ b/bin/gensquashfs/src/mkfs.c
@@ -160,7 +160,7 @@ int main(int argc, char **argv)
}
if (opt.sortfile != NULL) {
- int ret = istream_open_file(&sortfile, opt.sortfile);
+ int ret = sqfs_istream_open_file(&sortfile, opt.sortfile);
if (ret) {
sqfs_perror(opt.sortfile, NULL, ret);
goto out;
diff --git a/bin/gensquashfs/src/mkfs.h b/bin/gensquashfs/src/mkfs.h
index 5c97750..fd6de7f 100644
--- a/bin/gensquashfs/src/mkfs.h
+++ b/bin/gensquashfs/src/mkfs.h
@@ -13,7 +13,6 @@
#include "common.h"
#include "io/dir_iterator.h"
#include "util/util.h"
-#include "io/file.h"
#ifdef HAVE_SYS_XATTR_H
#include <sys/xattr.h>
diff --git a/bin/rdsquashfs/src/fill_files.c b/bin/rdsquashfs/src/fill_files.c
index f0ad7e2..7087883 100644
--- a/bin/rdsquashfs/src/fill_files.c
+++ b/bin/rdsquashfs/src/fill_files.c
@@ -145,7 +145,7 @@ static int fill_files(sqfs_data_reader_t *data, int flags)
openflags |= SQFS_FILE_OPEN_NO_SPARSE;
for (i = 0; i < num_files; ++i) {
- ret = ostream_open_file(&fp, files[i].path, openflags);
+ ret = sqfs_ostream_open_file(&fp, files[i].path, openflags);
if (ret) {
sqfs_perror(files[i].path, NULL, ret);
return -1;
diff --git a/bin/sqfsdiff/src/extract.c b/bin/sqfsdiff/src/extract.c
index d51096f..cbc4381 100644
--- a/bin/sqfsdiff/src/extract.c
+++ b/bin/sqfsdiff/src/extract.c
@@ -22,7 +22,7 @@ static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode,
return -1;
*ptr = '/';
- ret = ostream_open_file(&fp, temp, SQFS_FILE_OPEN_OVERWRITE);
+ ret = sqfs_ostream_open_file(&fp, temp, SQFS_FILE_OPEN_OVERWRITE);
if (ret) {
sqfs_perror(temp, NULL, ret);
return -1;
diff --git a/include/common.h b/include/common.h
index d2e3f73..d4827a8 100644
--- a/include/common.h
+++ b/include/common.h
@@ -21,7 +21,6 @@
#include "simple_writer.h"
#include "compress_cli.h"
-#include "io/file.h"
#include "io/std.h"
#include "compat.h"
#include "fstree.h"
diff --git a/include/io/file.h b/include/io/file.h
deleted file mode 100644
index e7ffb0d..0000000
--- a/include/io/file.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * file.h
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#ifndef IO_FILE_H
-#define IO_FILE_H
-
-#include "sqfs/io.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @brief Create an input stream for an OS native file handle.
- *
- * @memberof sqfs_istream_t
- *
- * The functions takes up ownership of the file handle and takes care
- * of cleaning it up. On failure, the handle remains usable, and ownership
- * remains with the caller.
- *
- * @param out Returns a pointer to an input stream on success.
- * @param path The name to associate with the handle.
- * @param fd A native file handle.
- *
- * @return Zero on success, a negative @ref SQFS_ERROR number on failure
- */
-SQFS_INTERNAL
-int istream_open_handle(sqfs_istream_t **out, const char *path,
- sqfs_file_handle_t fd);
-
-/**
- * @brief Create an output stream that writes to an OS native file handle.
- *
- * @memberof sqfs_ostream_t
- *
- * If the flag SQFS_FILE_OPEN_NO_SPARSE is set, the underlying implementation
- * always writes chunks of zero bytes when passing a NULL pointer to append.
- * Otherwise, it tries to use seek/truncate style APIs to create sparse output
- * files.
- *
- * @param out Returns a pointer to an output stream on success.
- * @param path The name to associate with the handle.
- * @param fd A native file handle.
- * @param flags A combination of flags.
- *
- * @return Zero on success, a negative @ref SQFS_ERROR number on failure
- */
-SQFS_INTERNAL int ostream_open_handle(sqfs_ostream_t **out, const char *path,
- sqfs_file_handle_t hnd, int flags);
-
-/**
- * @brief Create an input stream that reads from a file.
- *
- * @memberof sqfs_istream_t
- *
- * @param out Returns a pointer to an input stream on success.
- * @param path A path to the file to open or create.
- *
- * @return Zero on success, a negative @ref SQFS_ERROR number on failure
- */
-SQFS_INTERNAL int istream_open_file(sqfs_istream_t **out, const char *path);
-
-/**
- * @brief Create an output stream that writes to a file.
- *
- * @memberof sqfs_ostream_t
- *
- * If the file does not yet exist, it is created. If it does exist this
- * function fails, unless the flag SQFS_FILE_OPEN_OVERWRITE is set, in which
- * case the file is opened and its contents are discarded.
- *
- * If the flag SQFS_FILE_OPEN_NO_SPARSE is set, the underlying implementation
- * always writes chunks of zero bytes when passing a NULL pointer to append.
- * Otherwise, it tries to use seek/truncate style APIs to create sparse output
- * files.
- *
- * @param out Returns a pointer to an output stream on success.
- * @param path A path to the file to open or create.
- * @param flags A combination of flags controling how to open/create the file.
- *
- * @return Zero on success, a negative @ref SQFS_ERROR number on failure
- */
-SQFS_INTERNAL int ostream_open_file(sqfs_ostream_t **out,
- const char *path, int flags);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* IO_FILE_H */
diff --git a/include/sqfs/io.h b/include/sqfs/io.h
index 1138fc0..eaf74a6 100644
--- a/include/sqfs/io.h
+++ b/include/sqfs/io.h
@@ -330,6 +330,80 @@ SQFS_API int sqfs_open_native_file(sqfs_file_handle_t *out,
SQFS_API sqfs_file_t *sqfs_open_file(const char *filename, sqfs_u32 flags);
/**
+ * @brief Create an input stream for an OS native file handle.
+ *
+ * @memberof sqfs_istream_t
+ *
+ * The functions takes up ownership of the file handle and takes care
+ * of cleaning it up. On failure, the handle remains usable, and ownership
+ * remains with the caller.
+ *
+ * @param out Returns a pointer to an input stream on success.
+ * @param path The name to associate with the handle.
+ * @param fd A native file handle.
+ *
+ * @return Zero on success, a negative @ref SQFS_ERROR number on failure
+ */
+SQFS_API
+int sqfs_istream_open_handle(sqfs_istream_t **out, const char *path,
+ sqfs_file_handle_t fd);
+
+/**
+ * @brief Create an output stream that writes to an OS native file handle.
+ *
+ * @memberof sqfs_ostream_t
+ *
+ * If the flag SQFS_FILE_OPEN_NO_SPARSE is set, the underlying implementation
+ * always writes chunks of zero bytes when passing a NULL pointer to append.
+ * Otherwise, it tries to use seek/truncate style APIs to create sparse output
+ * files.
+ *
+ * @param out Returns a pointer to an output stream on success.
+ * @param path The name to associate with the handle.
+ * @param fd A native file handle.
+ * @param flags A combination of flags.
+ *
+ * @return Zero on success, a negative @ref SQFS_ERROR number on failure
+ */
+SQFS_API int sqfs_ostream_open_handle(sqfs_ostream_t **out, const char *path,
+ sqfs_file_handle_t hnd, int flags);
+
+/**
+ * @brief Create an input stream that reads from a file.
+ *
+ * @memberof sqfs_istream_t
+ *
+ * @param out Returns a pointer to an input stream on success.
+ * @param path A path to the file to open or create.
+ *
+ * @return Zero on success, a negative @ref SQFS_ERROR number on failure
+ */
+SQFS_API int sqfs_istream_open_file(sqfs_istream_t **out, const char *path);
+
+/**
+ * @brief Create an output stream that writes to a file.
+ *
+ * @memberof sqfs_ostream_t
+ *
+ * If the file does not yet exist, it is created. If it does exist this
+ * function fails, unless the flag SQFS_FILE_OPEN_OVERWRITE is set, in which
+ * case the file is opened and its contents are discarded.
+ *
+ * If the flag SQFS_FILE_OPEN_NO_SPARSE is set, the underlying implementation
+ * always writes chunks of zero bytes when passing a NULL pointer to append.
+ * Otherwise, it tries to use seek/truncate style APIs to create sparse output
+ * files.
+ *
+ * @param out Returns a pointer to an output stream on success.
+ * @param path A path to the file to open or create.
+ * @param flags A combination of flags controling how to open/create the file.
+ *
+ * @return Zero on success, a negative @ref SQFS_ERROR number on failure
+ */
+SQFS_API int sqfs_ostream_open_file(sqfs_ostream_t **out,
+ const char *path, int flags);
+
+/**
* @brief Read data from an input stream
*
* @memberof sqfs_istream_t
diff --git a/lib/io/Makemodule.am b/lib/io/Makemodule.am
index e128eef..4f2c180 100644
--- a/lib/io/Makemodule.am
+++ b/lib/io/Makemodule.am
@@ -1,5 +1,5 @@
libio_a_SOURCES = include/io/istream.h include/io/xfrm.h \
- include/io/file.h include/io/std.h include/io/dir_entry.h \
+ include/io/std.h include/io/dir_entry.h \
include/io/dir_iterator.h include/io/mem.h lib/io/src/internal.h \
lib/io/src/get_line.c lib/io/src/xfrm/ostream.c \
lib/io/src/xfrm/istream.c lib/io/src/dir_tree_iterator.c \
@@ -8,11 +8,9 @@ libio_a_CFLAGS = $(AM_CFLAGS) $(ZLIB_CFLAGS) $(XZ_CFLAGS)
libio_a_CFLAGS += $(ZSTD_CFLAGS) $(BZIP2_CFLAGS)
if WINDOWS
-libio_a_SOURCES += lib/io/src/win32/ostream.c lib/io/src/win32/istream.c
libio_a_SOURCES += lib/io/src/win32/dir_iterator.c
libio_a_CFLAGS += -DWINVER=0x0600 -D_WIN32_WINNT=0x0600
else
-libio_a_SOURCES += lib/io/src/unix/ostream.c lib/io/src/unix/istream.c
libio_a_SOURCES += lib/io/src/unix/dir_iterator.c
endif
diff --git a/lib/io/src/internal.h b/lib/io/src/internal.h
index e010727..a618ed3 100644
--- a/lib/io/src/internal.h
+++ b/lib/io/src/internal.h
@@ -10,7 +10,6 @@
#include "config.h"
#include "compat.h"
#include "io/istream.h"
-#include "io/file.h"
#include "io/xfrm.h"
#include "io/std.h"
#include "xfrm/compress.h"
diff --git a/lib/io/src/std.c b/lib/io/src/std.c
index 212fa6f..c52b4c5 100644
--- a/lib/io/src/std.c
+++ b/lib/io/src/std.c
@@ -6,7 +6,6 @@
*/
#include "config.h"
#include "compat.h"
-#include "io/file.h"
#include "io/std.h"
#include "sqfs/io.h"
@@ -24,13 +23,13 @@ int istream_open_stdin(sqfs_istream_t **out)
{
sqfs_file_handle_t hnd = GetStdHandle(STD_INPUT_HANDLE);
- return istream_open_handle(out, "stdin", hnd);
+ return sqfs_istream_open_handle(out, "stdin", hnd);
}
int ostream_open_stdout(sqfs_ostream_t **out)
{
sqfs_file_handle_t hnd = GetStdHandle(STD_OUTPUT_HANDLE);
- return ostream_open_handle(out, "stdout", hnd,
- SQFS_FILE_OPEN_NO_SPARSE);
+ return sqfs_ostream_open_handle(out, "stdout", hnd,
+ SQFS_FILE_OPEN_NO_SPARSE);
}
diff --git a/lib/sqfs/Makemodule.am b/lib/sqfs/Makemodule.am
index 2727b11..83ca478 100644
--- a/lib/sqfs/Makemodule.am
+++ b/lib/sqfs/Makemodule.am
@@ -57,12 +57,15 @@ libsquashfs_la_SOURCES += lib/util/src/mempool.c include/util/mempool.h
endif
if WINDOWS
-libsquashfs_la_SOURCES += lib/sqfs/src/win32/io_file.c
+libsquashfs_la_SOURCES += lib/sqfs/src/win32/io_file.c \
+ lib/sqfs/src/win32/ostream.c lib/sqfs/src/win32/istream.c
+
libsquashfs_la_CFLAGS += -DWINVER=0x0600 -D_WIN32_WINNT=0x0600
libsquashfs_la_CFLAGS += -Wc,-static-libgcc
libsquashfs_la_LDFLAGS += -no-undefined -avoid-version
else
-libsquashfs_la_SOURCES += lib/sqfs/src/unix/io_file.c
+libsquashfs_la_SOURCES += lib/sqfs/src/unix/io_file.c \
+ lib/sqfs/src/unix/ostream.c lib/sqfs/src/unix/istream.c
endif
if HAVE_PTHREAD
diff --git a/lib/io/src/unix/istream.c b/lib/sqfs/src/unix/istream.c
index 55b467e..fd2f120 100644
--- a/lib/io/src/unix/istream.c
+++ b/lib/sqfs/src/unix/istream.c
@@ -1,13 +1,24 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
+/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
* istream.c
*
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
-#include "../internal.h"
+#define SQFS_BUILDING_DLL
+#include "config.h"
+
#include "sqfs/io.h"
#include "sqfs/error.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#define BUFSZ (131072)
+
typedef struct {
sqfs_istream_t base;
char *path;
@@ -101,8 +112,8 @@ static void file_destroy(sqfs_object_t *obj)
free(file);
}
-int istream_open_handle(sqfs_istream_t **out, const char *path,
- sqfs_file_handle_t fd)
+int sqfs_istream_open_handle(sqfs_istream_t **out, const char *path,
+ sqfs_file_handle_t fd)
{
file_istream_t *file = calloc(1, sizeof(*file));
sqfs_istream_t *strm = (sqfs_istream_t *)file;
@@ -138,7 +149,7 @@ int istream_open_handle(sqfs_istream_t **out, const char *path,
return 0;
}
-int istream_open_file(sqfs_istream_t **out, const char *path)
+int sqfs_istream_open_file(sqfs_istream_t **out, const char *path)
{
sqfs_file_handle_t fd;
int ret;
@@ -147,9 +158,12 @@ int istream_open_file(sqfs_istream_t **out, const char *path)
if (ret)
return ret;
- ret = istream_open_handle(out, path, fd);
- if (ret != 0)
+ ret = sqfs_istream_open_handle(out, path, fd);
+ if (ret != 0) {
+ int temp = errno;
close(fd);
+ errno = temp;
+ }
return ret;
}
diff --git a/lib/io/src/unix/ostream.c b/lib/sqfs/src/unix/ostream.c
index 57467f5..89982c1 100644
--- a/lib/io/src/unix/ostream.c
+++ b/lib/sqfs/src/unix/ostream.c
@@ -1,13 +1,21 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
+/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
* ostream.c
*
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
-#include "../internal.h"
+#define SQFS_BUILDING_DLL
+#include "config.h"
+
#include "sqfs/io.h"
#include "sqfs/error.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+
typedef struct {
sqfs_ostream_t base;
char *path;
@@ -135,8 +143,8 @@ static const char *file_get_filename(sqfs_ostream_t *strm)
return ((file_ostream_t *)strm)->path;
}
-int ostream_open_handle(sqfs_ostream_t **out, const char *path,
- sqfs_file_handle_t fd, int flags)
+int sqfs_ostream_open_handle(sqfs_ostream_t **out, const char *path,
+ sqfs_file_handle_t fd, int flags)
{
file_ostream_t *file = calloc(1, sizeof(*file));
sqfs_ostream_t *strm = (sqfs_ostream_t *)file;
@@ -175,7 +183,7 @@ int ostream_open_handle(sqfs_ostream_t **out, const char *path,
return 0;
}
-int ostream_open_file(sqfs_ostream_t **out, const char *path, int flags)
+int sqfs_ostream_open_file(sqfs_ostream_t **out, const char *path, int flags)
{
sqfs_file_handle_t fd;
int ret;
@@ -185,7 +193,7 @@ int ostream_open_file(sqfs_ostream_t **out, const char *path, int flags)
if (ret)
return ret;
- ret = ostream_open_handle(out, path, fd, flags);
+ ret = sqfs_ostream_open_handle(out, path, fd, flags);
if (ret) {
int temp = errno;
close(fd);
diff --git a/lib/io/src/win32/istream.c b/lib/sqfs/src/win32/istream.c
index a09f3c3..ba44c0b 100644
--- a/lib/io/src/win32/istream.c
+++ b/lib/sqfs/src/win32/istream.c
@@ -1,15 +1,20 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
+/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
* istream.c
*
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
-#include "../internal.h"
+#define SQFS_BUILDING_DLL
+#include "config.h"
+
#include "sqfs/io.h"
#include "sqfs/error.h"
+#define BUFSZ (131072)
+
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
+#include <assert.h>
typedef struct {
sqfs_istream_t base;
@@ -112,7 +117,8 @@ static void file_destroy(sqfs_object_t *obj)
free(file);
}
-int istream_open_handle(sqfs_istream_t **out, const char *path, HANDLE hnd)
+int sqfs_istream_open_handle(sqfs_istream_t **out, const char *path,
+ sqfs_file_handle_t hnd)
{
file_istream_t *file = calloc(1, sizeof(*file));
sqfs_istream_t *strm = (sqfs_istream_t *)file;
@@ -152,7 +158,7 @@ int istream_open_handle(sqfs_istream_t **out, const char *path, HANDLE hnd)
return 0;
}
-int istream_open_file(sqfs_istream_t **out, const char *path)
+int sqfs_istream_open_file(sqfs_istream_t **out, const char *path)
{
sqfs_file_handle_t hnd;
int ret;
@@ -161,7 +167,7 @@ int istream_open_file(sqfs_istream_t **out, const char *path)
if (ret)
return ret;
- ret = istream_open_handle(out, path, hnd);
+ ret = sqfs_istream_open_handle(out, path, hnd);
if (ret) {
DWORD temp = GetLastError();
CloseHandle(hnd);
diff --git a/lib/io/src/win32/ostream.c b/lib/sqfs/src/win32/ostream.c
index b7f0e06..3e6a8a7 100644
--- a/lib/io/src/win32/ostream.c
+++ b/lib/sqfs/src/win32/ostream.c
@@ -1,10 +1,12 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
+/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
* ostream.c
*
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
-#include "../internal.h"
+#define SQFS_BUILDING_DLL
+#include "config.h"
+
#include "sqfs/io.h"
#include "sqfs/error.h"
@@ -128,8 +130,8 @@ static const char *file_get_filename(sqfs_ostream_t *strm)
return ((file_ostream_t *)strm)->path;
}
-int ostream_open_handle(sqfs_ostream_t **out, const char *path,
- sqfs_file_handle_t hnd, int flags)
+int sqfs_ostream_open_handle(sqfs_ostream_t **out, const char *path,
+ sqfs_file_handle_t hnd, int flags)
{
file_ostream_t *file = calloc(1, sizeof(*file));
sqfs_ostream_t *strm = (sqfs_ostream_t *)file;
@@ -168,7 +170,7 @@ int ostream_open_handle(sqfs_ostream_t **out, const char *path,
return 0;
}
-int ostream_open_file(sqfs_ostream_t **out, const char *path, int flags)
+int sqfs_ostream_open_file(sqfs_ostream_t **out, const char *path, int flags)
{
sqfs_file_handle_t hnd;
int ret;
@@ -178,7 +180,7 @@ int ostream_open_file(sqfs_ostream_t **out, const char *path, int flags)
if (ret)
return ret;
- ret = ostream_open_handle(out, path, hnd, flags);
+ ret = sqfs_ostream_open_handle(out, path, hnd, flags);
if (ret) {
DWORD temp = GetLastError();
CloseHandle(hnd);
diff --git a/lib/tar/test/tar_big_file.c b/lib/tar/test/tar_big_file.c
index 6a88d4c..2c8a176 100644
--- a/lib/tar/test/tar_big_file.c
+++ b/lib/tar/test/tar_big_file.c
@@ -6,8 +6,8 @@
*/
#include "config.h"
#include "tar/tar.h"
-#include "io/file.h"
#include "util/test.h"
+#include "sqfs/io.h"
int main(int argc, char **argv)
{
@@ -16,7 +16,8 @@ int main(int argc, char **argv)
int ret;
(void)argc; (void)argv;
- ret = istream_open_file(&fp, STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
+ ret = sqfs_istream_open_file(&fp,
+ STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
TEST_EQUAL_I(ret, 0);
TEST_NOT_NULL(fp);
TEST_ASSERT(read_header(fp, &hdr) == 0);
diff --git a/lib/tar/test/tar_fuzz.c b/lib/tar/test/tar_fuzz.c
index 42fe73d..1c4b52e 100644
--- a/lib/tar/test/tar_fuzz.c
+++ b/lib/tar/test/tar_fuzz.c
@@ -6,7 +6,7 @@
*/
#include "config.h"
-#include "io/file.h"
+#include "sqfs/io.h"
#include "tar/tar.h"
#include "common.h"
@@ -24,7 +24,7 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
- ret = istream_open_file(&fp, argv[1]);
+ ret = sqfs_istream_open_file(&fp, argv[1]);
if (ret) {
sqfs_perror("stdint", NULL, ret);
return EXIT_FAILURE;
diff --git a/lib/tar/test/tar_iterator.c b/lib/tar/test/tar_iterator.c
index 8de50ed..d4c2a35 100644
--- a/lib/tar/test/tar_iterator.c
+++ b/lib/tar/test/tar_iterator.c
@@ -5,10 +5,10 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "io/file.h"
#include "tar/tar.h"
#include "util/test.h"
#include "sqfs/error.h"
+#include "sqfs/io.h"
#ifndef TESTUID
#define TESTUID 1000
@@ -40,7 +40,7 @@ int main(int argc, char **argv)
(void)argc; (void)argv;
/* Open the file, create an iterator */
- iret = istream_open_file(&fp,
+ iret = sqfs_istream_open_file(&fp,
STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
TEST_EQUAL_I(iret, 0);
TEST_NOT_NULL(fp);
@@ -109,7 +109,7 @@ int main(int argc, char **argv)
sqfs_drop(fp);
/* re-open the tar iterator */
- iret = istream_open_file(&fp,
+ iret = sqfs_istream_open_file(&fp,
STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
TEST_EQUAL_I(iret, 0);
TEST_NOT_NULL(fp);
diff --git a/lib/tar/test/tar_iterator2.c b/lib/tar/test/tar_iterator2.c
index 8826762..8bbaf62 100644
--- a/lib/tar/test/tar_iterator2.c
+++ b/lib/tar/test/tar_iterator2.c
@@ -5,9 +5,9 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "io/file.h"
#include "tar/tar.h"
#include "util/test.h"
+#include "sqfs/io.h"
static const struct {
uint64_t offset;
@@ -52,7 +52,7 @@ int main(int argc, char **argv)
int iret;
(void)argc; (void)argv;
- iret = istream_open_file(&fp,
+ iret = sqfs_istream_open_file(&fp,
STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
TEST_EQUAL_I(iret, 0);
TEST_NOT_NULL(fp);
diff --git a/lib/tar/test/tar_iterator3.c b/lib/tar/test/tar_iterator3.c
index 0aee0e3..9fd5f59 100644
--- a/lib/tar/test/tar_iterator3.c
+++ b/lib/tar/test/tar_iterator3.c
@@ -6,10 +6,10 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "io/file.h"
#include "tar/tar.h"
#include "util/test.h"
#include "sqfs/error.h"
+#include "sqfs/io.h"
int main(int argc, char **argv)
{
@@ -23,7 +23,7 @@ int main(int argc, char **argv)
TEST_ASSERT(chdir(TEST_PATH) == 0);
- ret = istream_open_file(&fp, "format-acceptance/link_filled.tar");
+ ret = sqfs_istream_open_file(&fp, "format-acceptance/link_filled.tar");
TEST_EQUAL_I(ret, 0);
TEST_NOT_NULL(fp);
TEST_EQUAL_UI(((sqfs_object_t *)fp)->refcount, 1);
diff --git a/lib/tar/test/tar_simple.c b/lib/tar/test/tar_simple.c
index 8ee5b84..ad9fdde 100644
--- a/lib/tar/test/tar_simple.c
+++ b/lib/tar/test/tar_simple.c
@@ -5,9 +5,9 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "io/file.h"
#include "tar/tar.h"
#include "util/test.h"
+#include "sqfs/io.h"
#ifndef TESTUID
#define TESTUID 1000
@@ -43,7 +43,8 @@ int main(int argc, char **argv)
int ret;
(void)argc; (void)argv;
- ret = istream_open_file(&fp, STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
+ ret = sqfs_istream_open_file(&fp,
+ STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
TEST_EQUAL_I(ret, 0);
TEST_NOT_NULL(fp);
TEST_ASSERT(read_header(fp, &hdr) == 0);
diff --git a/lib/tar/test/tar_sparse.c b/lib/tar/test/tar_sparse.c
index d93482d..49b2064 100644
--- a/lib/tar/test/tar_sparse.c
+++ b/lib/tar/test/tar_sparse.c
@@ -5,9 +5,9 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "io/file.h"
#include "tar/tar.h"
#include "util/test.h"
+#include "sqfs/io.h"
static void test_case_sparse(const char *path)
{
@@ -16,7 +16,7 @@ static void test_case_sparse(const char *path)
sqfs_istream_t *fp;
int ret;
- ret = istream_open_file(&fp, path);
+ ret = sqfs_istream_open_file(&fp, path);
TEST_EQUAL_I(ret, 0);
TEST_NOT_NULL(fp);
TEST_ASSERT(read_header(fp, &hdr) == 0);
diff --git a/lib/tar/test/tar_sparse_gnu.c b/lib/tar/test/tar_sparse_gnu.c
index 6effb52..a2f8332 100644
--- a/lib/tar/test/tar_sparse_gnu.c
+++ b/lib/tar/test/tar_sparse_gnu.c
@@ -5,9 +5,9 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "io/file.h"
#include "tar/tar.h"
#include "util/test.h"
+#include "sqfs/io.h"
int main(int argc, char **argv)
{
@@ -19,7 +19,7 @@ int main(int argc, char **argv)
TEST_ASSERT(chdir(TEST_PATH) == 0);
- ret = istream_open_file(&fp, "sparse-files/gnu-small.tar");
+ ret = sqfs_istream_open_file(&fp, "sparse-files/gnu-small.tar");
TEST_EQUAL_I(ret, 0);
TEST_NOT_NULL(fp);
TEST_ASSERT(read_header(fp, &hdr) == 0);
diff --git a/lib/tar/test/tar_target_filled.c b/lib/tar/test/tar_target_filled.c
index 85a1af4..93c3b02 100644
--- a/lib/tar/test/tar_target_filled.c
+++ b/lib/tar/test/tar_target_filled.c
@@ -5,9 +5,9 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "io/file.h"
#include "tar/tar.h"
#include "util/test.h"
+#include "sqfs/io.h"
int main(int argc, char **argv)
{
@@ -19,7 +19,7 @@ int main(int argc, char **argv)
TEST_ASSERT(chdir(TEST_PATH) == 0);
- ret = istream_open_file(&fp, "format-acceptance/link_filled.tar");
+ ret = sqfs_istream_open_file(&fp, "format-acceptance/link_filled.tar");
TEST_EQUAL_I(ret, 0);
TEST_NOT_NULL(fp);
diff --git a/lib/tar/test/tar_write_simple.c b/lib/tar/test/tar_write_simple.c
index 28f199f..bc1b93e 100644
--- a/lib/tar/test/tar_write_simple.c
+++ b/lib/tar/test/tar_write_simple.c
@@ -7,7 +7,6 @@
#include "config.h"
#include "tar/tar.h"
#include "sqfs/io.h"
-#include "io/file.h"
#include "util/test.h"
#include "sqfs/xattr.h"
#include "compat.h"
@@ -188,7 +187,8 @@ int main(int argc, char **argv)
TEST_EQUAL_UI(wr_offset, sizeof(wr_buffer));
TEST_EQUAL_UI(sizeof(rd_buffer), sizeof(wr_buffer));
- ret = istream_open_file(&fp, STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
+ ret = sqfs_istream_open_file(&fp,
+ STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
TEST_EQUAL_I(ret, 0);
TEST_NOT_NULL(fp);
diff --git a/lib/tar/test/tar_xattr.c b/lib/tar/test/tar_xattr.c
index 0e0579c..d074e31 100644
--- a/lib/tar/test/tar_xattr.c
+++ b/lib/tar/test/tar_xattr.c
@@ -5,10 +5,10 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "io/file.h"
#include "tar/tar.h"
#include "util/test.h"
#include "sqfs/xattr.h"
+#include "sqfs/io.h"
int main(int argc, char **argv)
{
@@ -18,7 +18,8 @@ int main(int argc, char **argv)
int ret;
(void)argc; (void)argv;
- ret = istream_open_file(&fp, STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
+ ret = sqfs_istream_open_file(&fp,
+ STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
TEST_EQUAL_I(ret, 0);
TEST_NOT_NULL(fp);
TEST_ASSERT(read_header(fp, &hdr) == 0);
diff --git a/lib/tar/test/tar_xattr_bin.c b/lib/tar/test/tar_xattr_bin.c
index 617c356..68f23fe 100644
--- a/lib/tar/test/tar_xattr_bin.c
+++ b/lib/tar/test/tar_xattr_bin.c
@@ -5,10 +5,10 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "io/file.h"
#include "tar/tar.h"
#include "util/test.h"
#include "sqfs/xattr.h"
+#include "sqfs/io.h"
static const uint8_t value[] = {
0x00, 0x00, 0x00, 0x02,
@@ -26,7 +26,8 @@ int main(int argc, char **argv)
int ret;
(void)argc; (void)argv;
- ret = istream_open_file(&fp, STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
+ ret = sqfs_istream_open_file(&fp,
+ STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
TEST_EQUAL_I(ret, 0);
TEST_NOT_NULL(fp);
TEST_ASSERT(read_header(fp, &hdr) == 0);
diff --git a/lib/util/test/str_table.c b/lib/util/test/str_table.c
index 4a62b59..02e5e67 100644
--- a/lib/util/test/str_table.c
+++ b/lib/util/test/str_table.c
@@ -7,10 +7,10 @@
#include "config.h"
#include "util/str_table.h"
-#include "io/istream.h"
-#include "io/file.h"
#include "compat.h"
+#include "io/istream.h"
#include "util/test.h"
+#include "sqfs/io.h"
static char *strings[1000];
@@ -21,7 +21,7 @@ static int read_strings(void)
char *line;
int i;
- i = istream_open_file(&fp, "words.txt");
+ i = sqfs_istream_open_file(&fp, "words.txt");
TEST_EQUAL_I(i, 0);
TEST_NOT_NULL(fp);