From f8a92529ec04b560b5b9e647b976892412f78134 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 5 Sep 2019 19:08:10 +0200 Subject: Fix API visibility for libsquashfs.so This commit adds a "predef.h" header to libsquashfs that exposes two macros, SQFS_API and SQFS_INTERNAL that are used to explicilty set the visibiliy of stuff that ends up in libsquashfs to default or hidden. For compatibillity with Windows which may at some point eventually be considered, the SQFS_API define is set to dllexport IF the cpp symbol SQFS_BUILDING_DLL is defined and set to import otherwise. Signed-off-by: David Oberhollenzer --- include/sqfs/block_processor.h | 14 ++++++++------ include/sqfs/compress.h | 13 ++++++++----- include/sqfs/dir.h | 32 +++++++++++++++++--------------- include/sqfs/id_table.h | 22 ++++++++++++---------- include/sqfs/inode.h | 6 ++++-- include/sqfs/meta_reader.h | 22 +++++++++++++--------- include/sqfs/meta_writer.h | 24 +++++++++++++----------- include/sqfs/predef.h | 36 ++++++++++++++++++++++++++++++++++++ include/sqfs/super.h | 11 +++++++---- include/sqfs/table.h | 15 +++++++++------ include/sqfs/xattr.h | 24 ++++++++++++++---------- include/str_table.h | 14 +++++++++----- include/util.h | 13 +++++++++++++ 13 files changed, 163 insertions(+), 83 deletions(-) create mode 100644 include/sqfs/predef.h (limited to 'include') diff --git a/include/sqfs/block_processor.h b/include/sqfs/block_processor.h index bde0a2e..97bfd34 100644 --- a/include/sqfs/block_processor.h +++ b/include/sqfs/block_processor.h @@ -8,6 +8,7 @@ #define SFQS_BLOCK_PROCESSOR_H #include "config.h" +#include "sqfs/predef.h" #include "sqfs/compress.h" enum { @@ -67,13 +68,14 @@ typedef int (*sqfs_block_cb)(void *user, sqfs_block_t *blk); extern "C" { #endif +SQFS_API sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size, sqfs_compressor_t *cmp, unsigned int num_workers, void *user, sqfs_block_cb callback); -void sqfs_block_processor_destroy(sqfs_block_processor_t *proc); +SQFS_API void sqfs_block_processor_destroy(sqfs_block_processor_t *proc); /* Add a block to be processed. Returns non-zero on error and prints a message @@ -85,22 +87,22 @@ void sqfs_block_processor_destroy(sqfs_block_processor_t *proc); Even on failure, the workers may still be running and sqfs_block_processor_finish must be called before cleaning up. */ -int sqfs_block_processor_enqueue(sqfs_block_processor_t *proc, - sqfs_block_t *block); +SQFS_API int sqfs_block_processor_enqueue(sqfs_block_processor_t *proc, + sqfs_block_t *block); /* Wait for the compressor workers to finish. Returns zero on success, non-zero if an internal error occoured or one of the block callbacks returned a non-zero value. */ -int sqfs_block_processor_finish(sqfs_block_processor_t *proc); +SQFS_API int sqfs_block_processor_finish(sqfs_block_processor_t *proc); /* Convenience function to process a data block. Returns 0 on success, prints to stderr on failure. */ -int sqfs_block_process(sqfs_block_t *block, sqfs_compressor_t *cmp, - uint8_t *scratch, size_t scratch_size); +SQFS_API int sqfs_block_process(sqfs_block_t *block, sqfs_compressor_t *cmp, + uint8_t *scratch, size_t scratch_size); #ifdef __cplusplus } diff --git a/include/sqfs/compress.h b/include/sqfs/compress.h index c826c84..27c603d 100644 --- a/include/sqfs/compress.h +++ b/include/sqfs/compress.h @@ -14,6 +14,7 @@ #include #include +#include "sqfs/predef.h" #include "sqfs/super.h" typedef struct sqfs_compressor_t sqfs_compressor_t; @@ -132,16 +133,18 @@ typedef enum { extern "C" { #endif -int sqfs_compressor_config_init(sqfs_compressor_config_t *cfg, - E_SQFS_COMPRESSOR id, - size_t block_size, uint16_t flags); +SQFS_API int sqfs_compressor_config_init(sqfs_compressor_config_t *cfg, + E_SQFS_COMPRESSOR id, + size_t block_size, uint16_t flags); -bool sqfs_compressor_exists(E_SQFS_COMPRESSOR id); +SQFS_API bool sqfs_compressor_exists(E_SQFS_COMPRESSOR id); +SQFS_API sqfs_compressor_t *sqfs_compressor_create(const sqfs_compressor_config_t *cfg); -const char *sqfs_compressor_name_from_id(E_SQFS_COMPRESSOR id); +SQFS_API const char *sqfs_compressor_name_from_id(E_SQFS_COMPRESSOR id); +SQFS_API int sqfs_compressor_id_from_name(const char *name, E_SQFS_COMPRESSOR *out); #ifdef __cplusplus diff --git a/include/sqfs/dir.h b/include/sqfs/dir.h index c57831c..3a65102 100644 --- a/include/sqfs/dir.h +++ b/include/sqfs/dir.h @@ -9,6 +9,7 @@ #include "config.h" +#include "sqfs/predef.h" #include "sqfs/meta_reader.h" #include "sqfs/meta_writer.h" @@ -44,33 +45,34 @@ extern "C" { #endif /* Returns 0 on success. Internally prints to stderr on failure */ -int sqfs_meta_reader_read_dir_header(sqfs_meta_reader_t *m, - sqfs_dir_header_t *hdr); +SQFS_API 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 *sqfs_meta_reader_read_dir_ent(sqfs_meta_reader_t *m); +SQFS_API 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); +SQFS_API sqfs_dir_writer_t *sqfs_dir_writer_create(sqfs_meta_writer_t *dm); -void sqfs_dir_writer_destroy(sqfs_dir_writer_t *writer); +SQFS_API void sqfs_dir_writer_destroy(sqfs_dir_writer_t *writer); -int sqfs_dir_writer_begin(sqfs_dir_writer_t *writer); +SQFS_API int sqfs_dir_writer_begin(sqfs_dir_writer_t *writer); -int sqfs_dir_writer_add_entry(sqfs_dir_writer_t *writer, const char *name, - uint32_t inode_num, uint64_t inode_ref, - mode_t mode); +SQFS_API int sqfs_dir_writer_add_entry(sqfs_dir_writer_t *writer, + const char *name, + uint32_t inode_num, uint64_t inode_ref, + mode_t mode); -int sqfs_dir_writer_end(sqfs_dir_writer_t *writer); +SQFS_API int sqfs_dir_writer_end(sqfs_dir_writer_t *writer); -size_t sqfs_dir_writer_get_size(sqfs_dir_writer_t *writer); +SQFS_API size_t sqfs_dir_writer_get_size(sqfs_dir_writer_t *writer); -uint64_t sqfs_dir_writer_get_dir_reference(sqfs_dir_writer_t *writer); +SQFS_API uint64_t sqfs_dir_writer_get_dir_reference(sqfs_dir_writer_t *writer); -size_t sqfs_dir_writer_get_index_size(sqfs_dir_writer_t *writer); +SQFS_API size_t sqfs_dir_writer_get_index_size(sqfs_dir_writer_t *writer); -int sqfs_dir_writer_write_index(sqfs_dir_writer_t *writer, - sqfs_meta_writer_t *im); +SQFS_API int sqfs_dir_writer_write_index(sqfs_dir_writer_t *writer, + sqfs_meta_writer_t *im); #ifdef __cplusplus } diff --git a/include/sqfs/id_table.h b/include/sqfs/id_table.h index 0e652ec..f8b3b5c 100644 --- a/include/sqfs/id_table.h +++ b/include/sqfs/id_table.h @@ -12,7 +12,8 @@ #include #include -#include "compress.h" +#include "sqfs/predef.h" +#include "sqfs/compress.h" typedef struct sqfs_id_table_t sqfs_id_table_t; @@ -21,26 +22,27 @@ extern "C" { #endif /* Prints error message to stderr on failure. */ -sqfs_id_table_t *sqfs_id_table_create(void); +SQFS_API sqfs_id_table_t *sqfs_id_table_create(void); -void sqfs_id_table_destroy(sqfs_id_table_t *tbl); +SQFS_API void sqfs_id_table_destroy(sqfs_id_table_t *tbl); /* Resolve a 32 bit to a 16 bit table index. Returns 0 on success. Internally prints errors to stderr. */ -int sqfs_id_table_id_to_index(sqfs_id_table_t *tbl, uint32_t id, uint16_t *out); +SQFS_API int sqfs_id_table_id_to_index(sqfs_id_table_t *tbl, uint32_t id, + uint16_t *out); /* Write an ID table to a SquashFS image. Returns 0 on success. Internally prints error message to stderr. */ -int sqfs_id_table_write(sqfs_id_table_t *tbl, int outfd, sqfs_super_t *super, - sqfs_compressor_t *cmp); +SQFS_API int sqfs_id_table_write(sqfs_id_table_t *tbl, int outfd, + sqfs_super_t *super, sqfs_compressor_t *cmp); /* Read an ID table from a SquashFS image. Returns 0 on success. Internally prints error messages to stderr. */ -int sqfs_id_table_read(sqfs_id_table_t *tbl, int fd, sqfs_super_t *super, - sqfs_compressor_t *cmp); +SQFS_API int sqfs_id_table_read(sqfs_id_table_t *tbl, int fd, + sqfs_super_t *super, sqfs_compressor_t *cmp); -int sqfs_id_table_index_to_id(const sqfs_id_table_t *tbl, uint16_t index, - uint32_t *out); +SQFS_API int sqfs_id_table_index_to_id(const sqfs_id_table_t *tbl, + uint16_t index, uint32_t *out); #ifdef __cplusplus } diff --git a/include/sqfs/inode.h b/include/sqfs/inode.h index d693aec..37a088c 100644 --- a/include/sqfs/inode.h +++ b/include/sqfs/inode.h @@ -9,6 +9,7 @@ #include "config.h" +#include "sqfs/predef.h" #include "sqfs/meta_reader.h" #include "sqfs/meta_writer.h" @@ -138,13 +139,14 @@ extern "C" { /* Inode can be freed with a single free() call. The function internally prints error message to stderr on failure. */ +SQFS_API 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); +SQFS_API int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *iw, + sqfs_inode_generic_t *n); #ifdef __cplusplus } diff --git a/include/sqfs/meta_reader.h b/include/sqfs/meta_reader.h index 6f0d184..1e5e027 100644 --- a/include/sqfs/meta_reader.h +++ b/include/sqfs/meta_reader.h @@ -9,6 +9,7 @@ #include "config.h" +#include "sqfs/predef.h" #include "sqfs/compress.h" #include "sqfs/data.h" @@ -24,21 +25,24 @@ extern "C" { Start offset and limit can be specified to do bounds checking against a subregion of the filesystem image. */ -sqfs_meta_reader_t *sqfs_meta_reader_create(int fd, sqfs_compressor_t *cmp, - uint64_t start, uint64_t limit); +SQFS_API sqfs_meta_reader_t *sqfs_meta_reader_create(int fd, + sqfs_compressor_t *cmp, + uint64_t start, + uint64_t limit); -void sqfs_meta_reader_destroy(sqfs_meta_reader_t *m); +SQFS_API void sqfs_meta_reader_destroy(sqfs_meta_reader_t *m); /* Returns 0 on success. Internally prints to stderr on failure */ -int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, uint64_t block_start, - size_t offset); +SQFS_API int sqfs_meta_reader_seek(sqfs_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); +SQFS_API 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 sqfs_meta_reader_read(sqfs_meta_reader_t *m, void *data, size_t size); +SQFS_API int sqfs_meta_reader_read(sqfs_meta_reader_t *m, void *data, + size_t size); #ifdef __cplusplus } diff --git a/include/sqfs/meta_writer.h b/include/sqfs/meta_writer.h index bb14993..3611984 100644 --- a/include/sqfs/meta_writer.h +++ b/include/sqfs/meta_writer.h @@ -9,6 +9,7 @@ #include "config.h" +#include "sqfs/predef.h" #include "sqfs/compress.h" #include "sqfs/id_table.h" #include "sqfs/data.h" @@ -24,31 +25,32 @@ extern "C" { If keep_in_mem is true, the blocks are collected in memory and must be explicitly flushed to disk using meta_write_write_to_file. */ -sqfs_meta_writer_t *sqfs_meta_writer_create(int fd, sqfs_compressor_t *cmp, - bool keep_in_mem); +SQFS_API sqfs_meta_writer_t *sqfs_meta_writer_create(int fd, + sqfs_compressor_t *cmp, + bool keep_in_mem); -void sqfs_meta_writer_destroy(sqfs_meta_writer_t *m); +SQFS_API void sqfs_meta_writer_destroy(sqfs_meta_writer_t *m); /* Compress and flush the currently unfinished block to disk. Returns 0 on success, internally prints error message to stderr on failure */ -int sqfs_meta_writer_flush(sqfs_meta_writer_t *m); +SQFS_API int sqfs_meta_writer_flush(sqfs_meta_writer_t *m); /* Returns 0 on success. Prints error message to stderr on failure. */ -int sqfs_meta_writer_append(sqfs_meta_writer_t *m, const void *data, - size_t size); +SQFS_API int sqfs_meta_writer_append(sqfs_meta_writer_t *m, const void *data, + size_t size); /* Query the current block start position and offset within the block */ -void sqfs_meta_writer_get_position(const sqfs_meta_writer_t *m, - uint64_t *block_start, - uint32_t *offset); +SQFS_API void sqfs_meta_writer_get_position(const sqfs_meta_writer_t *m, + uint64_t *block_start, + uint32_t *offset); /* Reset all internal state, including the current block start position. */ -void sqfs_meta_writer_reset(sqfs_meta_writer_t *m); +SQFS_API void sqfs_meta_writer_reset(sqfs_meta_writer_t *m); /* If created with keep_in_mem true, write the collected blocks to disk. Does not flush the current block. Writes error messages to stderr and returns non-zero on failure. */ -int sqfs_meta_write_write_to_file(sqfs_meta_writer_t *m); +SQFS_API int sqfs_meta_write_write_to_file(sqfs_meta_writer_t *m); #ifdef __cplusplus } diff --git a/include/sqfs/predef.h b/include/sqfs/predef.h new file mode 100644 index 0000000..210f306 --- /dev/null +++ b/include/sqfs/predef.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * predef.h + * + * Copyright (C) 2019 David Oberhollenzer + */ +#ifndef SQFS_PREDEF_H +#define SQFS_PREDEF_H + +#if defined(_WIN32) || defined(__CYGWIN__) + #ifdef SQFS_BUILDING_DLL + #if defined(__GNUC__) || defined(__clang__) + #define SQFS_API __attribute__ ((dllexport)) + #else + #define SQFS_API __declspec(dllexport) + #endif + #else + #if defined(__GNUC__) || defined(__clang__) + #define SQFS_API __attribute__ ((dllimport)) + #else + #define SQFS_API __declspec(dllimport) + #endif + #endif + + #define SQFS_INTERNAL +#else + #if defined(__GNUC__) || defined(__clang__) + #define SQFS_API __attribute__ ((visibility ("default"))) + #define SQFS_INTERNAL __attribute__ ((visibility ("hidden"))) + #else + #define SQFS_API + #define SQFS_INTERNAL + #endif +#endif + +#endif /* SQFS_PREDEF_H */ diff --git a/include/sqfs/super.h b/include/sqfs/super.h index 0df1691..6593555 100644 --- a/include/sqfs/super.h +++ b/include/sqfs/super.h @@ -9,6 +9,8 @@ #include "config.h" +#include "sqfs/predef.h" + #include #include @@ -71,14 +73,15 @@ extern "C" { #endif /* Returns 0 on success. Prints error messages to stderr on failure. */ -int sqfs_super_init(sqfs_super_t *super, size_t block_size, uint32_t mtime, - E_SQFS_COMPRESSOR compressor); +SQFS_API int sqfs_super_init(sqfs_super_t *super, size_t block_size, + uint32_t mtime, + E_SQFS_COMPRESSOR compressor); /* Returns 0 on success. Prints error messages to stderr on failure. */ -int sqfs_super_write(sqfs_super_t *super, int fd); +SQFS_API int sqfs_super_write(sqfs_super_t *super, int fd); /* Returns 0 on success. Prints error messages to stderr on failure. */ -int sqfs_super_read(sqfs_super_t *super, int fd); +SQFS_API int sqfs_super_read(sqfs_super_t *super, int fd); #ifdef __cplusplus } diff --git a/include/sqfs/table.h b/include/sqfs/table.h index b5eeb54..0bd3112 100644 --- a/include/sqfs/table.h +++ b/include/sqfs/table.h @@ -7,6 +7,7 @@ #ifndef SQFS_TABLE_H #define SQFS_TABLE_H +#include "sqfs/predef.h" #include "sqfs/compress.h" #include "sqfs/super.h" @@ -28,12 +29,14 @@ extern "C" { Returns 0 on success. Internally prints error messages to stderr. */ -int sqfs_write_table(int outfd, sqfs_super_t *super, sqfs_compressor_t *cmp, - const void *data, size_t table_size, uint64_t *start); - -void *sqfs_read_table(int fd, sqfs_compressor_t *cmp, size_t table_size, - uint64_t location, uint64_t lower_limit, - uint64_t upper_limit); +SQFS_API int sqfs_write_table(int outfd, sqfs_super_t *super, + sqfs_compressor_t *cmp, + const void *data, size_t table_size, + uint64_t *start); + +SQFS_API void *sqfs_read_table(int fd, sqfs_compressor_t *cmp, + size_t table_size, uint64_t location, + uint64_t lower_limit, uint64_t upper_limit); #ifdef __cplusplus } diff --git a/include/sqfs/xattr.h b/include/sqfs/xattr.h index 5350534..d1b3bdd 100644 --- a/include/sqfs/xattr.h +++ b/include/sqfs/xattr.h @@ -9,6 +9,7 @@ #include "config.h" +#include "sqfs/predef.h" #include "sqfs/compress.h" #include @@ -54,28 +55,31 @@ extern "C" { #endif /* Get a prefix string from the ID or NULL if unknown */ -const char *sqfs_get_xattr_prefix(E_SQFS_XATTR_TYPE id); +SQFS_API const char *sqfs_get_xattr_prefix(E_SQFS_XATTR_TYPE id); /* Get id from xattr key prefix or -1 if not supported */ -int sqfs_get_xattr_prefix_id(const char *key); +SQFS_API int sqfs_get_xattr_prefix_id(const char *key); /* Check if a given xattr key can be encoded in squashfs at all. */ -bool sqfs_has_xattr(const char *key); +SQFS_API bool sqfs_has_xattr(const char *key); -void sqfs_xattr_reader_destroy(sqfs_xattr_reader_t *xr); +SQFS_API void sqfs_xattr_reader_destroy(sqfs_xattr_reader_t *xr); -sqfs_xattr_reader_t *sqfs_xattr_reader_create(int sqfsfd, sqfs_super_t *super, - sqfs_compressor_t *cmp); +SQFS_API sqfs_xattr_reader_t *sqfs_xattr_reader_create(int sqfsfd, + sqfs_super_t *super, + sqfs_compressor_t *cmp); -int sqfs_xattr_reader_get_desc(sqfs_xattr_reader_t *xr, uint32_t idx, - sqfs_xattr_id_t *desc); +SQFS_API int sqfs_xattr_reader_get_desc(sqfs_xattr_reader_t *xr, uint32_t idx, + sqfs_xattr_id_t *desc); -int sqfs_xattr_reader_seek_kv(sqfs_xattr_reader_t *xr, - const sqfs_xattr_id_t *desc); +SQFS_API int sqfs_xattr_reader_seek_kv(sqfs_xattr_reader_t *xr, + const sqfs_xattr_id_t *desc); +SQFS_API sqfs_xattr_value_t *sqfs_xattr_reader_read_value(sqfs_xattr_reader_t *xr, const sqfs_xattr_entry_t *key); +SQFS_API sqfs_xattr_entry_t *sqfs_xattr_reader_read_key(sqfs_xattr_reader_t *xr); #ifdef __cplusplus diff --git a/include/str_table.h b/include/str_table.h index 634854a..1f836cc 100644 --- a/include/str_table.h +++ b/include/str_table.h @@ -7,6 +7,8 @@ #ifndef STR_TABLE_H #define STR_TABLE_H +#include "sqfs/predef.h" + typedef struct str_bucket_t { struct str_bucket_t *next; char *str; @@ -28,22 +30,24 @@ typedef struct { /* `size` is the number of hash table buckets to use internally. Returns 0 on success. Internally writes errors to stderr. */ -int str_table_init(str_table_t *table, size_t size); +SQFS_INTERNAL int str_table_init(str_table_t *table, size_t size); -void str_table_cleanup(str_table_t *table); +SQFS_INTERNAL void str_table_cleanup(str_table_t *table); /* Resolve a string to an incremental, unique ID Returns 0 on success. Internally writes errors to stderr. */ +SQFS_INTERNAL int str_table_get_index(str_table_t *table, const char *str, size_t *idx); /* Resolve a unique ID to the string it represents. Returns NULL if the ID is unknown, i.e. out of bounds. */ +SQFS_INTERNAL const char *str_table_get_string(str_table_t *table, size_t index); -void str_table_reset_ref_count(str_table_t *table); +SQFS_INTERNAL void str_table_reset_ref_count(str_table_t *table); -void str_table_add_ref(str_table_t *table, size_t index); +SQFS_INTERNAL void str_table_add_ref(str_table_t *table, size_t index); -size_t str_table_get_ref_count(str_table_t *table, size_t index); +SQFS_INTERNAL size_t str_table_get_ref_count(str_table_t *table, size_t index); #endif /* STR_TABLE_H */ diff --git a/include/util.h b/include/util.h index 651a958..93b8a04 100644 --- a/include/util.h +++ b/include/util.h @@ -8,6 +8,7 @@ #define UTIL_H #include "config.h" +#include "sqfs/predef.h" #include #include @@ -52,6 +53,7 @@ typedef struct sparse_map_t { on success. Writes to stderr on failure using 'errstr' as a perror style error prefix. */ +SQFS_INTERNAL int write_data(const char *errstr, int fd, const void *data, size_t size); /* @@ -60,11 +62,13 @@ int write_data(const char *errstr, int fd, const void *data, size_t size); on success. Writes to stderr on failure using 'errstr' as a perror style error prefix. */ +SQFS_INTERNAL int read_data(const char *errstr, int fd, void *buffer, size_t size); /* Similar to read_data but wrapps pread() instead of read(). */ +SQFS_INTERNAL int read_data_at(const char *errstr, off_t location, int fd, void *buffer, size_t size); @@ -74,6 +78,7 @@ int read_data_at(const char *errstr, off_t location, Prints out version information. The program name is extracted from the BSD style __progname global variable. */ +SQFS_INTERNAL void print_version(void); /* @@ -82,21 +87,26 @@ void print_version(void); Returns 0 on success. */ +SQFS_INTERNAL int mkdir_p(const char *path); /* Returns 0 on success. On failure, prints error message to stderr. */ +SQFS_INTERNAL int pushd(const char *path); /* Same as pushd, but the string doesn't have to be null-terminated. */ +SQFS_INTERNAL int pushdn(const char *path, size_t len); /* Returns 0 on success. On failure, prints error message to stderr. */ +SQFS_INTERNAL int popd(void); /* Write zero bytes to an output file to padd it to specified block size. Returns 0 on success. On failure, prints error message to stderr. */ +SQFS_INTERNAL int padd_file(int outfd, uint64_t size, size_t blocksize); /* @@ -107,12 +117,15 @@ int padd_file(int outfd, uint64_t size, size_t blocksize); Iternally checks for arithmetic overflows when allocating the combined thing. */ +SQFS_INTERNAL void *alloc_flex(size_t base_size, size_t item_size, size_t nmemb); /* Basically the same as calloc, but *ALWAYS* does overflow checking */ +SQFS_INTERNAL void *alloc_array(size_t item_size, size_t nmemb); /* allocates len + 1 (for the null-terminator) and does overflow checking */ +SQFS_INTERNAL void *alloc_string(size_t len); #endif /* UTIL_H */ -- cgit v1.2.3