summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-27 18:15:40 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-27 18:15:40 +0200
commit40232f4bd4d7e8e001f7d1e8f120606f59b2c147 (patch)
tree5d763f4f22a487fd2e669efe0970615096f1f5fd /lib
parentf6904a98bffe0bce5fc6aac408c141a25c0e05ab (diff)
Cleanup: replace fixed with data types with typedefs
This is a fully automated search and replace, i.e. I ran this: git grep -l uint8_t | xargs sed -i 's/uint8_t/sqfs_u8/g' git grep -l uint16_t | xargs sed -i 's/uint16_t/sqfs_u16/g' git grep -l uint32_t | xargs sed -i 's/uint32_t/sqfs_u32/g' git grep -l uint64_t | xargs sed -i 's/uint64_t/sqfs_u64/g' git grep -l int8_t | xargs sed -i 's/int8_t/sqfs_s8/g' git grep -l int16_t | xargs sed -i 's/int16_t/sqfs_s16/g' git grep -l int32_t | xargs sed -i 's/int32_t/sqfs_s32/g' git grep -l int64_t | xargs sed -i 's/int64_t/sqfs_s64/g' and than added the appropriate definitions to sqfs/predef.h The whole point being better compatibillity with platforms that may not have an stdint.h with the propper definitions. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/fstree/fstree.c2
-rw-r--r--lib/fstree/source_date_epoch.c4
-rw-r--r--lib/fstree/xattr.c8
-rw-r--r--lib/sqfs/comp/compressor.c10
-rw-r--r--lib/sqfs/comp/gzip.c14
-rw-r--r--lib/sqfs/comp/lz4.c12
-rw-r--r--lib/sqfs/comp/lzma.c10
-rw-r--r--lib/sqfs/comp/lzo.c14
-rw-r--r--lib/sqfs/comp/xz.c18
-rw-r--r--lib/sqfs/comp/zstd.c10
-rw-r--r--lib/sqfs/data_reader.c30
-rw-r--r--lib/sqfs/data_writer/block.c8
-rw-r--r--lib/sqfs/data_writer/common.c4
-rw-r--r--lib/sqfs/data_writer/fileapi.c2
-rw-r--r--lib/sqfs/data_writer/fragment.c4
-rw-r--r--lib/sqfs/data_writer/internal.h26
-rw-r--r--lib/sqfs/dir_reader.c16
-rw-r--r--lib/sqfs/dir_writer.c42
-rw-r--r--lib/sqfs/id_table.c14
-rw-r--r--lib/sqfs/inode.c16
-rw-r--r--lib/sqfs/io_file.c10
-rw-r--r--lib/sqfs/meta_reader.c20
-rw-r--r--lib/sqfs/meta_writer.c16
-rw-r--r--lib/sqfs/read_inode.c26
-rw-r--r--lib/sqfs/read_table.c10
-rw-r--r--lib/sqfs/read_tree.c2
-rw-r--r--lib/sqfs/readdir.c4
-rw-r--r--lib/sqfs/super.c2
-rw-r--r--lib/sqfs/write_inode.c6
-rw-r--r--lib/sqfs/write_table.c8
-rw-r--r--lib/sqfs/xattr_reader.c16
-rw-r--r--lib/sqfshelper/comp_opt.c4
-rw-r--r--lib/sqfshelper/data_reader_dump.c2
-rw-r--r--lib/sqfshelper/data_writer.c4
-rw-r--r--lib/sqfshelper/io_stdin.c24
-rw-r--r--lib/sqfshelper/serialize_fstree.c6
-rw-r--r--lib/sqfshelper/statistics.c2
-rw-r--r--lib/sqfshelper/tree_node_to_inode.c4
-rw-r--r--lib/sqfshelper/write_export_table.c6
-rw-r--r--lib/sqfshelper/write_xattr.c30
-rw-r--r--lib/tar/base64.c4
-rw-r--r--lib/tar/checksum.c2
-rw-r--r--lib/tar/internal.h10
-rw-r--r--lib/tar/number.c14
-rw-r--r--lib/tar/read_header.c22
-rw-r--r--lib/tar/read_sparse_map_old.c2
-rw-r--r--lib/tar/skip.c6
-rw-r--r--lib/tar/write_header.c12
-rw-r--r--lib/util/padd_file.c8
-rw-r--r--lib/util/str_table.c8
50 files changed, 277 insertions, 277 deletions
diff --git a/lib/fstree/fstree.c b/lib/fstree/fstree.c
index c7c4a23..357fd3d 100644
--- a/lib/fstree/fstree.c
+++ b/lib/fstree/fstree.c
@@ -66,7 +66,7 @@ static int process_defaults(struct stat *sb, char *subopts)
goto fail_uv;
if (lval > 07777)
goto fail_ov;
- sb->st_mode = S_IFDIR | (uint16_t)lval;
+ sb->st_mode = S_IFDIR | (sqfs_u16)lval;
break;
case DEF_MTIME:
lval = strtol(value, NULL, 0);
diff --git a/lib/fstree/source_date_epoch.c b/lib/fstree/source_date_epoch.c
index bbf2e42..9b47d56 100644
--- a/lib/fstree/source_date_epoch.c
+++ b/lib/fstree/source_date_epoch.c
@@ -11,10 +11,10 @@
#include <stdio.h>
#include <ctype.h>
-uint32_t get_source_date_epoch(void)
+sqfs_u32 get_source_date_epoch(void)
{
const char *str, *ptr;
- uint32_t x, tval = 0;
+ sqfs_u32 x, tval = 0;
str = getenv("SOURCE_DATE_EPOCH");
diff --git a/lib/fstree/xattr.c b/lib/fstree/xattr.c
index c37c734..45ea8a6 100644
--- a/lib/fstree/xattr.c
+++ b/lib/fstree/xattr.c
@@ -38,10 +38,10 @@ static tree_xattr_t *grow_xattr_block(tree_xattr_t *xattr)
if (xattr != NULL) {
if (SZ_MUL_OV(xattr->max_attr, 2, &new_count))
goto fail_ov;
- old_size = sizeof(*xattr) + sizeof(uint64_t) * xattr->max_attr;
+ old_size = sizeof(*xattr) + sizeof(sqfs_u64) * xattr->max_attr;
}
- if (SZ_MUL_OV(sizeof(uint64_t), new_count, &new_size) ||
+ if (SZ_MUL_OV(sizeof(sqfs_u64), new_count, &new_size) ||
SZ_ADD_OV(sizeof(*xattr), new_size, &new_size)) {
goto fail_ov;
}
@@ -75,7 +75,7 @@ int fstree_add_xattr(fstree_t *fs, tree_node_t *node,
if (str_table_get_index(&fs->xattr_values, value, &value_idx))
return -1;
- if (sizeof(size_t) > sizeof(uint32_t)) {
+ if (sizeof(size_t) > sizeof(sqfs_u32)) {
if (key_idx > 0xFFFFFFFFUL) {
fputs("Too many unique xattr keys\n", stderr);
return -1;
@@ -116,7 +116,7 @@ static int cmp_attr(const void *lhs, const void *rhs)
void fstree_xattr_reindex(fstree_t *fs)
{
- uint32_t key_idx, value_idx;
+ sqfs_u32 key_idx, value_idx;
size_t i, index = 0;
tree_xattr_t *it;
diff --git a/lib/sqfs/comp/compressor.c b/lib/sqfs/comp/compressor.c
index 37f852c..bfc20b7 100644
--- a/lib/sqfs/comp/compressor.c
+++ b/lib/sqfs/comp/compressor.c
@@ -46,10 +46,10 @@ static const char *names[] = {
int sqfs_generic_write_options(sqfs_file_t *file, const void *data, size_t size)
{
- uint8_t buffer[size + 2];
+ sqfs_u8 buffer[size + 2];
int ret;
- *((uint16_t *)buffer) = htole16(0x8000 | size);
+ *((sqfs_u16 *)buffer) = htole16(0x8000 | size);
memcpy(buffer + 2, data, size);
ret = file->write_at(file, sizeof(sqfs_super_t),
@@ -62,7 +62,7 @@ int sqfs_generic_write_options(sqfs_file_t *file, const void *data, size_t size)
int sqfs_generic_read_options(sqfs_file_t *file, void *data, size_t size)
{
- uint8_t buffer[size + 2];
+ sqfs_u8 buffer[size + 2];
int ret;
ret = file->read_at(file, sizeof(sqfs_super_t),
@@ -70,7 +70,7 @@ int sqfs_generic_read_options(sqfs_file_t *file, void *data, size_t size)
if (ret)
return ret;
- if (le16toh(*((uint16_t *)buffer)) != (0x8000 | size))
+ if (le16toh(*((sqfs_u16 *)buffer)) != (0x8000 | size))
return SQFS_ERROR_CORRUPTED;
memcpy(data, buffer + 2, size);
@@ -120,7 +120,7 @@ int sqfs_compressor_id_from_name(const char *name, E_SQFS_COMPRESSOR *out)
int sqfs_compressor_config_init(sqfs_compressor_config_t *cfg,
E_SQFS_COMPRESSOR id,
- size_t block_size, uint16_t flags)
+ size_t block_size, sqfs_u16 flags)
{
memset(cfg, 0, sizeof(*cfg));
diff --git a/lib/sqfs/comp/gzip.c b/lib/sqfs/comp/gzip.c
index 0c6f944..3dd8d10 100644
--- a/lib/sqfs/comp/gzip.c
+++ b/lib/sqfs/comp/gzip.c
@@ -16,9 +16,9 @@
#include "internal.h"
typedef struct {
- uint32_t level;
- uint16_t window;
- uint16_t strategies;
+ sqfs_u32 level;
+ sqfs_u16 window;
+ sqfs_u16 strategies;
} gzip_options_t;
typedef struct {
@@ -106,8 +106,8 @@ static int flag_to_zlib_strategy(int flag)
return 0;
}
-static int find_strategy(gzip_compressor_t *gzip, const uint8_t *in,
- size_t size, uint8_t *out, size_t outsize)
+static int find_strategy(gzip_compressor_t *gzip, const sqfs_u8 *in,
+ size_t size, sqfs_u8 *out, size_t outsize)
{
int ret, strategy, selected = Z_DEFAULT_STRATEGY;
size_t i, length, minlength = 0;
@@ -148,8 +148,8 @@ static int find_strategy(gzip_compressor_t *gzip, const uint8_t *in,
return selected;
}
-static ssize_t gzip_do_block(sqfs_compressor_t *base, const uint8_t *in,
- size_t size, uint8_t *out, size_t outsize)
+static ssize_t gzip_do_block(sqfs_compressor_t *base, const sqfs_u8 *in,
+ size_t size, sqfs_u8 *out, size_t outsize)
{
gzip_compressor_t *gzip = (gzip_compressor_t *)base;
int ret, strategy = 0;
diff --git a/lib/sqfs/comp/lz4.c b/lib/sqfs/comp/lz4.c
index db44bc4..35fd629 100644
--- a/lib/sqfs/comp/lz4.c
+++ b/lib/sqfs/comp/lz4.c
@@ -22,8 +22,8 @@ typedef struct {
} lz4_compressor_t;
typedef struct {
- uint32_t version;
- uint32_t flags;
+ sqfs_u32 version;
+ sqfs_u32 flags;
} lz4_options;
#define LZ4LEGACY 1
@@ -59,8 +59,8 @@ static int lz4_read_options(sqfs_compressor_t *base, sqfs_file_t *file)
return 0;
}
-static ssize_t lz4_comp_block(sqfs_compressor_t *base, const uint8_t *in,
- size_t size, uint8_t *out, size_t outsize)
+static ssize_t lz4_comp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
+ size_t size, sqfs_u8 *out, size_t outsize)
{
lz4_compressor_t *lz4 = (lz4_compressor_t *)base;
int ret;
@@ -79,8 +79,8 @@ static ssize_t lz4_comp_block(sqfs_compressor_t *base, const uint8_t *in,
return ret;
}
-static ssize_t lz4_uncomp_block(sqfs_compressor_t *base, const uint8_t *in,
- size_t size, uint8_t *out, size_t outsize)
+static ssize_t lz4_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
+ size_t size, sqfs_u8 *out, size_t outsize)
{
int ret;
(void)base;
diff --git a/lib/sqfs/comp/lzma.c b/lib/sqfs/comp/lzma.c
index 57a942e..f4211fb 100644
--- a/lib/sqfs/comp/lzma.c
+++ b/lib/sqfs/comp/lzma.c
@@ -39,8 +39,8 @@ static int lzma_read_options(sqfs_compressor_t *base, sqfs_file_t *file)
return SQFS_ERROR_UNSUPPORTED;
}
-static ssize_t lzma_comp_block(sqfs_compressor_t *base, const uint8_t *in,
- size_t size, uint8_t *out, size_t outsize)
+static ssize_t lzma_comp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
+ size_t size, sqfs_u8 *out, size_t outsize)
{
lzma_compressor_t *lzma = (lzma_compressor_t *)base;
lzma_stream strm = LZMA_STREAM_INIT;
@@ -83,10 +83,10 @@ static ssize_t lzma_comp_block(sqfs_compressor_t *base, const uint8_t *in,
return strm.total_out;
}
-static ssize_t lzma_uncomp_block(sqfs_compressor_t *base, const uint8_t *in,
- size_t size, uint8_t *out, size_t outsize)
+static ssize_t lzma_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
+ size_t size, sqfs_u8 *out, size_t outsize)
{
- uint8_t lzma_header[LZMA_HEADER_SIZE];
+ sqfs_u8 lzma_header[LZMA_HEADER_SIZE];
lzma_stream strm = LZMA_STREAM_INIT;
size_t hdrsize;
int ret;
diff --git a/lib/sqfs/comp/lzo.c b/lib/sqfs/comp/lzo.c
index 0b140b8..9af3321 100644
--- a/lib/sqfs/comp/lzo.c
+++ b/lib/sqfs/comp/lzo.c
@@ -51,12 +51,12 @@ typedef struct {
int algorithm;
int level;
- uint8_t buffer[];
+ sqfs_u8 buffer[];
} lzo_compressor_t;
typedef struct {
- uint32_t algorithm;
- uint32_t level;
+ sqfs_u32 algorithm;
+ sqfs_u32 level;
} lzo_options_t;
static int lzo_write_options(sqfs_compressor_t *base, sqfs_file_t *file)
@@ -112,8 +112,8 @@ static int lzo_read_options(sqfs_compressor_t *base, sqfs_file_t *file)
return 0;
}
-static ssize_t lzo_comp_block(sqfs_compressor_t *base, const uint8_t *in,
- size_t size, uint8_t *out, size_t outsize)
+static ssize_t lzo_comp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
+ size_t size, sqfs_u8 *out, size_t outsize)
{
lzo_compressor_t *lzo = (lzo_compressor_t *)base;
lzo_uint len = outsize;
@@ -138,8 +138,8 @@ static ssize_t lzo_comp_block(sqfs_compressor_t *base, const uint8_t *in,
return 0;
}
-static ssize_t lzo_uncomp_block(sqfs_compressor_t *base, const uint8_t *in,
- size_t size, uint8_t *out, size_t outsize)
+static ssize_t lzo_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
+ size_t size, sqfs_u8 *out, size_t outsize)
{
lzo_compressor_t *lzo = (lzo_compressor_t *)base;
lzo_uint len = outsize;
diff --git a/lib/sqfs/comp/xz.c b/lib/sqfs/comp/xz.c
index f0229e0..d905f2d 100644
--- a/lib/sqfs/comp/xz.c
+++ b/lib/sqfs/comp/xz.c
@@ -22,8 +22,8 @@ typedef struct {
} xz_compressor_t;
typedef struct {
- uint32_t dict_size;
- uint32_t flags;
+ sqfs_u32 dict_size;
+ sqfs_u32 flags;
} xz_options_t;
static bool is_dict_size_valid(size_t size)
@@ -75,8 +75,8 @@ static int xz_read_options(sqfs_compressor_t *base, sqfs_file_t *file)
}
static ssize_t compress(xz_compressor_t *xz, lzma_vli filter,
- const uint8_t *in, size_t size,
- uint8_t *out, size_t outsize)
+ const sqfs_u8 *in, size_t size,
+ sqfs_u8 *out, size_t outsize)
{
lzma_filter filters[5];
lzma_options_lzma opt;
@@ -135,8 +135,8 @@ static lzma_vli flag_to_vli(int flag)
return LZMA_VLI_UNKNOWN;
}
-static ssize_t xz_comp_block(sqfs_compressor_t *base, const uint8_t *in,
- size_t size, uint8_t *out, size_t outsize)
+static ssize_t xz_comp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
+ size_t size, sqfs_u8 *out, size_t outsize)
{
xz_compressor_t *xz = (xz_compressor_t *)base;
lzma_vli filter, selected = LZMA_VLI_UNKNOWN;
@@ -171,10 +171,10 @@ static ssize_t xz_comp_block(sqfs_compressor_t *base, const uint8_t *in,
return compress(xz, selected, in, size, out, outsize);
}
-static ssize_t xz_uncomp_block(sqfs_compressor_t *base, const uint8_t *in,
- size_t size, uint8_t *out, size_t outsize)
+static ssize_t xz_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
+ size_t size, sqfs_u8 *out, size_t outsize)
{
- uint64_t memlimit = 32 * 1024 * 1024;
+ sqfs_u64 memlimit = 32 * 1024 * 1024;
size_t dest_pos = 0;
size_t src_pos = 0;
lzma_ret ret;
diff --git a/lib/sqfs/comp/zstd.c b/lib/sqfs/comp/zstd.c
index 50440a0..81e369b 100644
--- a/lib/sqfs/comp/zstd.c
+++ b/lib/sqfs/comp/zstd.c
@@ -22,7 +22,7 @@ typedef struct {
} zstd_compressor_t;
typedef struct {
- uint32_t level;
+ sqfs_u32 level;
} zstd_options_t;
static int zstd_write_options(sqfs_compressor_t *base, sqfs_file_t *file)
@@ -51,8 +51,8 @@ static int zstd_read_options(sqfs_compressor_t *base, sqfs_file_t *file)
return 0;
}
-static ssize_t zstd_comp_block(sqfs_compressor_t *base, const uint8_t *in,
- size_t size, uint8_t *out, size_t outsize)
+static ssize_t zstd_comp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
+ size_t size, sqfs_u8 *out, size_t outsize)
{
zstd_compressor_t *zstd = (zstd_compressor_t *)base;
size_t ret;
@@ -66,8 +66,8 @@ static ssize_t zstd_comp_block(sqfs_compressor_t *base, const uint8_t *in,
return ret < size ? ret : 0;
}
-static ssize_t zstd_uncomp_block(sqfs_compressor_t *base, const uint8_t *in,
- size_t size, uint8_t *out, size_t outsize)
+static ssize_t zstd_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
+ size_t size, sqfs_u8 *out, size_t outsize)
{
size_t ret;
(void)base;
diff --git a/lib/sqfs/data_reader.c b/lib/sqfs/data_reader.c
index 862723d..0befb9d 100644
--- a/lib/sqfs/data_reader.c
+++ b/lib/sqfs/data_reader.c
@@ -25,18 +25,18 @@ struct sqfs_data_reader_t {
sqfs_block_t *data_block;
sqfs_block_t *frag_block;
- uint64_t current_block;
+ sqfs_u64 current_block;
sqfs_file_t *file;
- uint32_t num_fragments;
- uint32_t current_frag_index;
- uint32_t block_size;
+ sqfs_u32 num_fragments;
+ sqfs_u32 current_frag_index;
+ sqfs_u32 block_size;
- uint8_t scratch[];
+ sqfs_u8 scratch[];
};
-static int get_block(sqfs_data_reader_t *data, uint64_t off, uint32_t size,
+static int get_block(sqfs_data_reader_t *data, sqfs_u64 off, sqfs_u32 size,
size_t unpacked_size, sqfs_block_t **out)
{
sqfs_block_t *blk = alloc_flex(sizeof(*blk), 1, unpacked_size);
@@ -87,8 +87,8 @@ static int get_block(sqfs_data_reader_t *data, uint64_t off, uint32_t size,
return 0;
}
-static int precache_data_block(sqfs_data_reader_t *data, uint64_t location,
- uint32_t size)
+static int precache_data_block(sqfs_data_reader_t *data, sqfs_u64 location,
+ sqfs_u32 size)
{
int ret;
@@ -153,7 +153,7 @@ int sqfs_data_reader_load_fragment_table(sqfs_data_reader_t *data,
{
void *raw_frag;
size_t size;
- uint32_t i;
+ sqfs_u32 i;
int ret;
free(data->frag_block);
@@ -210,7 +210,7 @@ int sqfs_data_reader_get_block(sqfs_data_reader_t *data,
size_t index, sqfs_block_t **out)
{
size_t i, unpacked_size;
- uint64_t off, filesz;
+ sqfs_u64 off, filesz;
sqfs_inode_get_file_block_start(inode, &off);
sqfs_inode_get_file_size(inode, &filesz);
@@ -233,9 +233,9 @@ 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_u32 frag_idx, frag_off, frag_sz;
sqfs_block_t *blk;
- uint64_t filesz;
+ sqfs_u64 filesz;
sqfs_inode_get_file_size(inode, &filesz);
sqfs_inode_get_frag_location(inode, &frag_idx, &frag_off);
@@ -266,11 +266,11 @@ int sqfs_data_reader_get_fragment(sqfs_data_reader_t *data,
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)
+ sqfs_u64 offset, void *buffer, size_t size)
{
- uint32_t frag_idx, frag_off;
+ sqfs_u32 frag_idx, frag_off;
size_t i, diff, total = 0;
- uint64_t off, filesz;
+ sqfs_u64 off, filesz;
char *ptr;
/* work out file location and size */
diff --git a/lib/sqfs/data_writer/block.c b/lib/sqfs/data_writer/block.c
index 9c40793..5dce26c 100644
--- a/lib/sqfs/data_writer/block.c
+++ b/lib/sqfs/data_writer/block.c
@@ -9,8 +9,8 @@
#include <string.h>
-static int store_block_location(sqfs_data_writer_t *proc, uint64_t offset,
- uint32_t size, uint32_t chksum)
+static int store_block_location(sqfs_data_writer_t *proc, sqfs_u64 offset,
+ sqfs_u32 size, sqfs_u32 chksum)
{
size_t new_sz;
void *new;
@@ -61,9 +61,9 @@ static int allign_file(sqfs_data_writer_t *proc, sqfs_block_t *blk)
int process_completed_block(sqfs_data_writer_t *proc, sqfs_block_t *blk)
{
- uint64_t offset, bytes;
+ sqfs_u64 offset, bytes;
size_t start, count;
- uint32_t out;
+ sqfs_u32 out;
int err;
if (proc->hooks != NULL && proc->hooks->pre_block_write != NULL) {
diff --git a/lib/sqfs/data_writer/common.c b/lib/sqfs/data_writer/common.c
index 9e11e36..059ef41 100644
--- a/lib/sqfs/data_writer/common.c
+++ b/lib/sqfs/data_writer/common.c
@@ -99,7 +99,7 @@ sqfs_block_t *data_writer_next_work_item(sqfs_data_writer_t *proc)
}
int data_writer_do_block(sqfs_block_t *block, sqfs_compressor_t *cmp,
- uint8_t *scratch, size_t scratch_size)
+ sqfs_u8 *scratch, size_t scratch_size)
{
ssize_t ret;
@@ -132,7 +132,7 @@ int data_writer_do_block(sqfs_block_t *block, sqfs_compressor_t *cmp,
int sqfs_data_writer_write_fragment_table(sqfs_data_writer_t *proc,
sqfs_super_t *super)
{
- uint64_t start;
+ sqfs_u64 start;
size_t size;
int ret;
diff --git a/lib/sqfs/data_writer/fileapi.c b/lib/sqfs/data_writer/fileapi.c
index 712fd29..2a5d02a 100644
--- a/lib/sqfs/data_writer/fileapi.c
+++ b/lib/sqfs/data_writer/fileapi.c
@@ -26,7 +26,7 @@ static int add_sentinel_block(sqfs_data_writer_t *proc)
}
int sqfs_data_writer_begin_file(sqfs_data_writer_t *proc,
- sqfs_inode_generic_t *inode, uint32_t flags)
+ sqfs_inode_generic_t *inode, sqfs_u32 flags)
{
if (proc->inode != NULL)
return test_and_set_status(proc, SQFS_ERROR_INTERNAL);
diff --git a/lib/sqfs/data_writer/fragment.c b/lib/sqfs/data_writer/fragment.c
index 9f169b7..1957983 100644
--- a/lib/sqfs/data_writer/fragment.c
+++ b/lib/sqfs/data_writer/fragment.c
@@ -49,7 +49,7 @@ static int grow_deduplication_list(sqfs_data_writer_t *proc)
}
static int store_fragment(sqfs_data_writer_t *proc, sqfs_block_t *frag,
- uint64_t hash)
+ sqfs_u64 hash)
{
int err = grow_deduplication_list(proc);
@@ -79,7 +79,7 @@ static int store_fragment(sqfs_data_writer_t *proc, sqfs_block_t *frag,
int process_completed_fragment(sqfs_data_writer_t *proc, sqfs_block_t *frag,
sqfs_block_t **blk_out)
{
- uint64_t hash;
+ sqfs_u64 hash;
size_t i, size;
int err;
diff --git a/lib/sqfs/data_writer/internal.h b/lib/sqfs/data_writer/internal.h
index b1d9d8c..c12d89c 100644
--- a/lib/sqfs/data_writer/internal.h
+++ b/lib/sqfs/data_writer/internal.h
@@ -28,20 +28,20 @@
#define MK_BLK_HASH(chksum, size) \
- (((uint64_t)(size) << 32) | (uint64_t)(chksum))
+ (((sqfs_u64)(size) << 32) | (sqfs_u64)(chksum))
#define INIT_BLOCK_COUNT (128)
typedef struct {
- uint64_t offset;
- uint64_t hash;
+ sqfs_u64 offset;
+ sqfs_u64 hash;
} blk_info_t;
typedef struct {
- uint32_t index;
- uint32_t offset;
- uint64_t hash;
+ sqfs_u32 index;
+ sqfs_u32 offset;
+ sqfs_u64 hash;
} frag_info_t;
@@ -50,7 +50,7 @@ typedef struct {
sqfs_data_writer_t *shared;
sqfs_compressor_t *cmp;
pthread_t thread;
- uint8_t scratch[];
+ sqfs_u8 scratch[];
} compress_worker_t;
#endif
@@ -71,8 +71,8 @@ struct sqfs_data_writer_t {
int status;
/* used by main thread only */
- uint32_t enqueue_id;
- uint32_t dequeue_id;
+ sqfs_u32 enqueue_id;
+ sqfs_u32 dequeue_id;
unsigned int num_workers;
size_t max_backlog;
@@ -84,7 +84,7 @@ struct sqfs_data_writer_t {
size_t num_fragments;
size_t max_fragments;
- uint64_t start;
+ sqfs_u64 start;
size_t file_start;
size_t num_blocks;
@@ -103,7 +103,7 @@ struct sqfs_data_writer_t {
/* file API */
sqfs_inode_generic_t *inode;
sqfs_block_t *blk_current;
- uint32_t blk_flags;
+ sqfs_u32 blk_flags;
size_t blk_index;
/* used only by workers */
@@ -112,7 +112,7 @@ struct sqfs_data_writer_t {
#ifdef WITH_PTHREAD
compress_worker_t *workers[];
#else
- uint8_t scratch[];
+ sqfs_u8 scratch[];
#endif
};
@@ -141,7 +141,7 @@ sqfs_block_t *data_writer_next_work_item(sqfs_data_writer_t *proc);
SQFS_INTERNAL
int data_writer_do_block(sqfs_block_t *block, sqfs_compressor_t *cmp,
- uint8_t *scratch, size_t scratch_size);
+ sqfs_u8 *scratch, size_t scratch_size);
SQFS_INTERNAL
int test_and_set_status(sqfs_data_writer_t *proc, int status);
diff --git a/lib/sqfs/dir_reader.c b/lib/sqfs/dir_reader.c
index aa9e1a4..a353069 100644
--- a/lib/sqfs/dir_reader.c
+++ b/lib/sqfs/dir_reader.c
@@ -25,13 +25,13 @@ struct sqfs_dir_reader_t {
const sqfs_super_t *super;
sqfs_dir_header_t hdr;
- uint64_t dir_block_start;
+ sqfs_u64 dir_block_start;
size_t entries;
size_t size;
size_t start_size;
- uint16_t dir_offset;
- uint16_t inode_offset;
+ sqfs_u16 dir_offset;
+ sqfs_u16 inode_offset;
};
sqfs_dir_reader_t *sqfs_dir_reader_create(const sqfs_super_t *super,
@@ -39,7 +39,7 @@ sqfs_dir_reader_t *sqfs_dir_reader_create(const sqfs_super_t *super,
sqfs_file_t *file)
{
sqfs_dir_reader_t *rd = calloc(1, sizeof(*rd));
- uint64_t start, limit;
+ sqfs_u64 start, limit;
if (rd == NULL)
return NULL;
@@ -85,7 +85,7 @@ void sqfs_dir_reader_destroy(sqfs_dir_reader_t *rd)
int sqfs_dir_reader_open_dir(sqfs_dir_reader_t *rd,
const sqfs_inode_generic_t *inode)
{
- uint64_t block_start;
+ sqfs_u64 block_start;
size_t size, offset;
if (inode->base.type == SQFS_INODE_DIR) {
@@ -191,7 +191,7 @@ int sqfs_dir_reader_find(sqfs_dir_reader_t *rd, const char *name)
int sqfs_dir_reader_get_inode(sqfs_dir_reader_t *rd,
sqfs_inode_generic_t **inode)
{
- uint64_t block_start;
+ sqfs_u64 block_start;
block_start = rd->hdr.start_block;
@@ -203,8 +203,8 @@ int sqfs_dir_reader_get_inode(sqfs_dir_reader_t *rd,
int sqfs_dir_reader_get_root_inode(sqfs_dir_reader_t *rd,
sqfs_inode_generic_t **inode)
{
- uint64_t block_start = rd->super->root_inode_ref >> 16;
- uint16_t offset = rd->super->root_inode_ref & 0xFFFF;
+ sqfs_u64 block_start = rd->super->root_inode_ref >> 16;
+ sqfs_u16 offset = rd->super->root_inode_ref & 0xFFFF;
return sqfs_meta_reader_read_inode(rd->meta_inode, rd->super,
block_start, offset, inode);
diff --git a/lib/sqfs/dir_writer.c b/lib/sqfs/dir_writer.c
index 6b38c04..cae1e63 100644
--- a/lib/sqfs/dir_writer.c
+++ b/lib/sqfs/dir_writer.c
@@ -22,9 +22,9 @@
typedef struct dir_entry_t {
struct dir_entry_t *next;
- uint64_t inode_ref;
- uint32_t inode_num;
- uint16_t type;
+ sqfs_u64 inode_ref;
+ sqfs_u32 inode_num;
+ sqfs_u16 type;
size_t name_len;
char name[];
} dir_entry_t;
@@ -32,8 +32,8 @@ typedef struct dir_entry_t {
typedef struct index_ent_t {
struct index_ent_t *next;
dir_entry_t *ent;
- uint64_t block;
- uint32_t index;
+ sqfs_u64 block;
+ sqfs_u32 index;
} index_ent_t;
struct sqfs_dir_writer_t {
@@ -43,7 +43,7 @@ struct sqfs_dir_writer_t {
index_ent_t *idx;
index_ent_t *idx_end;
- uint64_t dir_ref;
+ sqfs_u64 dir_ref;
size_t dir_size;
size_t idx_size;
size_t ent_count;
@@ -109,8 +109,8 @@ void sqfs_dir_writer_destroy(sqfs_dir_writer_t *writer)
int sqfs_dir_writer_begin(sqfs_dir_writer_t *writer)
{
- uint32_t offset;
- uint64_t block;
+ sqfs_u32 offset;
+ sqfs_u64 block;
writer_reset(writer);
@@ -120,7 +120,7 @@ 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,
+ sqfs_u32 inode_num, sqfs_u64 inode_ref,
mode_t mode)
{
dir_entry_t *ent;
@@ -152,11 +152,11 @@ int sqfs_dir_writer_add_entry(sqfs_dir_writer_t *writer, const char *name,
return 0;
}
-static size_t get_conseq_entry_count(uint32_t offset, dir_entry_t *head)
+static size_t get_conseq_entry_count(sqfs_u32 offset, dir_entry_t *head)
{
size_t size, count = 0;
dir_entry_t *it;
- int32_t diff;
+ sqfs_s32 diff;
size = (offset + sizeof(sqfs_dir_header_t)) % SQFS_META_BLOCK_SIZE;
@@ -184,7 +184,7 @@ static size_t get_conseq_entry_count(uint32_t offset, dir_entry_t *head)
}
static int add_header(sqfs_dir_writer_t *writer, size_t count,
- dir_entry_t *ref, uint64_t block)
+ dir_entry_t *ref, sqfs_u64 block)
{
sqfs_dir_header_t hdr;
index_ent_t *idx;
@@ -222,10 +222,10 @@ int sqfs_dir_writer_end(sqfs_dir_writer_t *writer)
{
dir_entry_t *it, *first;
sqfs_dir_entry_t ent;
- uint16_t *diff_u16;
+ sqfs_u16 *diff_u16;
size_t i, count;
- uint32_t offset;
- uint64_t block;
+ sqfs_u32 offset;
+ sqfs_u64 block;
int err;
for (it = writer->list; it != NULL; ) {
@@ -244,7 +244,7 @@ int sqfs_dir_writer_end(sqfs_dir_writer_t *writer)
ent.type = htole16(it->type);
ent.size = htole16(it->name_len - 1);
- diff_u16 = (uint16_t *)&ent.inode_diff;
+ diff_u16 = (sqfs_u16 *)&ent.inode_diff;
*diff_u16 = htole16(*diff_u16);
err = sqfs_meta_writer_append(writer->dm, &ent,
@@ -269,7 +269,7 @@ size_t sqfs_dir_writer_get_size(const sqfs_dir_writer_t *writer)
return writer->dir_size;
}
-uint64_t sqfs_dir_writer_get_dir_reference(const sqfs_dir_writer_t *writer)
+sqfs_u64 sqfs_dir_writer_get_dir_reference(const sqfs_dir_writer_t *writer)
{
return writer->dir_ref;
}
@@ -286,12 +286,12 @@ size_t sqfs_dir_writer_get_entry_count(const sqfs_dir_writer_t *writer)
sqfs_inode_generic_t
*sqfs_dir_writer_create_inode(const sqfs_dir_writer_t *writer,
- size_t hlinks, uint32_t xattr,
- uint32_t parent_ino)
+ size_t hlinks, sqfs_u32 xattr,
+ sqfs_u32 parent_ino)
{
sqfs_inode_generic_t *inode;
- uint64_t start_block;
- uint16_t block_offset;
+ sqfs_u64 start_block;
+ sqfs_u16 block_offset;
inode = calloc(1, sizeof(*inode));
if (inode == NULL)
diff --git a/lib/sqfs/id_table.c b/lib/sqfs/id_table.c
index a365a5f..78a5d26 100644
--- a/lib/sqfs/id_table.c
+++ b/lib/sqfs/id_table.c
@@ -16,7 +16,7 @@
#include <string.h>
struct sqfs_id_table_t {
- uint32_t *ids;
+ sqfs_u32 *ids;
size_t num_ids;
size_t max_ids;
};
@@ -32,7 +32,7 @@ void sqfs_id_table_destroy(sqfs_id_table_t *tbl)
free(tbl);
}
-int sqfs_id_table_id_to_index(sqfs_id_table_t *tbl, uint32_t id, uint16_t *out)
+int sqfs_id_table_id_to_index(sqfs_id_table_t *tbl, sqfs_u32 id, sqfs_u16 *out)
{
size_t i, sz;
void *ptr;
@@ -63,8 +63,8 @@ int sqfs_id_table_id_to_index(sqfs_id_table_t *tbl, uint32_t id, uint16_t *out)
return 0;
}
-int sqfs_id_table_index_to_id(const sqfs_id_table_t *tbl, uint16_t index,
- uint32_t *out)
+int sqfs_id_table_index_to_id(const sqfs_id_table_t *tbl, sqfs_u16 index,
+ sqfs_u32 *out)
{
if (index >= tbl->num_ids)
return SQFS_ERROR_OUT_OF_BOUNDS;
@@ -76,7 +76,7 @@ int sqfs_id_table_index_to_id(const sqfs_id_table_t *tbl, uint16_t index,
int sqfs_id_table_read(sqfs_id_table_t *tbl, sqfs_file_t *file,
const sqfs_super_t *super, sqfs_compressor_t *cmp)
{
- uint64_t upper_limit, lower_limit;
+ sqfs_u64 upper_limit, lower_limit;
void *raw_ids;
size_t i;
int ret;
@@ -106,7 +106,7 @@ int sqfs_id_table_read(sqfs_id_table_t *tbl, sqfs_file_t *file,
tbl->num_ids = super->id_count;
tbl->max_ids = super->id_count;
- ret = sqfs_read_table(file, cmp, tbl->num_ids * sizeof(uint32_t),
+ ret = sqfs_read_table(file, cmp, tbl->num_ids * sizeof(sqfs_u32),
super->id_table_start, lower_limit,
upper_limit, &raw_ids);
if (ret)
@@ -123,7 +123,7 @@ int sqfs_id_table_read(sqfs_id_table_t *tbl, sqfs_file_t *file,
int sqfs_id_table_write(sqfs_id_table_t *tbl, sqfs_file_t *file,
sqfs_super_t *super, sqfs_compressor_t *cmp)
{
- uint64_t start;
+ sqfs_u64 start;
size_t i;
int ret;
diff --git a/lib/sqfs/inode.c b/lib/sqfs/inode.c
index d6c013c..334ffd8 100644
--- a/lib/sqfs/inode.c
+++ b/lib/sqfs/inode.c
@@ -28,7 +28,7 @@ static int inverse_type[] = {
};
int sqfs_inode_get_xattr_index(const sqfs_inode_generic_t *inode,
- uint32_t *out)
+ sqfs_u32 *out)
{
switch (inode->base.type) {
case SQFS_INODE_DIR:
@@ -122,7 +122,7 @@ int sqfs_inode_make_extended(sqfs_inode_generic_t *inode)
int sqfs_inode_make_basic(sqfs_inode_generic_t *inode)
{
- uint32_t xattr;
+ sqfs_u32 xattr;
int err;
err = sqfs_inode_get_xattr_index(inode, &xattr);
@@ -187,7 +187,7 @@ int sqfs_inode_make_basic(sqfs_inode_generic_t *inode)
return 0;
}
-int sqfs_inode_set_file_size(sqfs_inode_generic_t *inode, uint64_t size)
+int sqfs_inode_set_file_size(sqfs_inode_generic_t *inode, sqfs_u64 size)
{
if (inode->base.type == SQFS_INODE_EXT_FILE) {
inode->data.file_ext.file_size = size;
@@ -209,7 +209,7 @@ int sqfs_inode_set_file_size(sqfs_inode_generic_t *inode, uint64_t size)
}
int sqfs_inode_set_frag_location(sqfs_inode_generic_t *inode,
- uint32_t index, uint32_t offset)
+ sqfs_u32 index, sqfs_u32 offset)
{
if (inode->base.type == SQFS_INODE_EXT_FILE) {
inode->data.file_ext.fragment_idx = index;
@@ -225,7 +225,7 @@ int sqfs_inode_set_frag_location(sqfs_inode_generic_t *inode,
}
int sqfs_inode_set_file_block_start(sqfs_inode_generic_t *inode,
- uint64_t location)
+ sqfs_u64 location)
{
if (inode->base.type == SQFS_INODE_EXT_FILE) {
inode->data.file_ext.blocks_start = location;
@@ -246,7 +246,7 @@ int sqfs_inode_set_file_block_start(sqfs_inode_generic_t *inode,
return 0;
}
-int sqfs_inode_get_file_size(const sqfs_inode_generic_t *inode, uint64_t *size)
+int sqfs_inode_get_file_size(const sqfs_inode_generic_t *inode, sqfs_u64 *size)
{
if (inode->base.type == SQFS_INODE_EXT_FILE) {
*size = inode->data.file_ext.file_size;
@@ -260,7 +260,7 @@ int sqfs_inode_get_file_size(const sqfs_inode_generic_t *inode, uint64_t *size)
}
int sqfs_inode_get_frag_location(const sqfs_inode_generic_t *inode,
- uint32_t *index, uint32_t *offset)
+ sqfs_u32 *index, sqfs_u32 *offset)
{
if (inode->base.type == SQFS_INODE_EXT_FILE) {
*index = inode->data.file_ext.fragment_idx;
@@ -276,7 +276,7 @@ int sqfs_inode_get_frag_location(const sqfs_inode_generic_t *inode,
}
int sqfs_inode_get_file_block_start(const sqfs_inode_generic_t *inode,
- uint64_t *location)
+ sqfs_u64 *location)
{
if (inode->base.type == SQFS_INODE_EXT_FILE) {
*location = inode->data.file_ext.blocks_start;
diff --git a/lib/sqfs/io_file.c b/lib/sqfs/io_file.c
index bb5ef48..b07ae24 100644
--- a/lib/sqfs/io_file.c
+++ b/lib/sqfs/io_file.c
@@ -20,7 +20,7 @@
typedef struct {
sqfs_file_t base;
- uint64_t size;
+ sqfs_u64 size;
int fd;
} sqfs_file_stdio_t;
@@ -33,7 +33,7 @@ static void stdio_destroy(sqfs_file_t *base)
free(file);
}
-static int stdio_read_at(sqfs_file_t *base, uint64_t offset,
+static int stdio_read_at(sqfs_file_t *base, sqfs_u64 offset,
void *buffer, size_t size)
{
sqfs_file_stdio_t *file = (sqfs_file_stdio_t *)base;
@@ -59,7 +59,7 @@ static int stdio_read_at(sqfs_file_t *base, uint64_t offset,
return 0;
}
-static int stdio_write_at(sqfs_file_t *base, uint64_t offset,
+static int stdio_write_at(sqfs_file_t *base, sqfs_u64 offset,
const void *buffer, size_t size)
{
sqfs_file_stdio_t *file = (sqfs_file_stdio_t *)base;
@@ -88,14 +88,14 @@ static int stdio_write_at(sqfs_file_t *base, uint64_t offset,
return 0;
}
-static uint64_t stdio_get_size(const sqfs_file_t *base)
+static sqfs_u64 stdio_get_size(const sqfs_file_t *base)
{
const sqfs_file_stdio_t *file = (const sqfs_file_stdio_t *)base;
return file->size;
}
-static int stdio_truncate(sqfs_file_t *base, uint64_t size)
+static int stdio_truncate(sqfs_file_t *base, sqfs_u64 size)
{
sqfs_file_stdio_t *file = (sqfs_file_stdio_t *)base;
diff --git a/lib/sqfs/meta_reader.c b/lib/sqfs/meta_reader.c
index 89d698b..d3c3565 100644
--- a/lib/sqfs/meta_reader.c
+++ b/lib/sqfs/meta_reader.c
@@ -19,15 +19,15 @@
#include <string.h>
struct sqfs_meta_reader_t {
- uint64_t start;
- uint64_t limit;
+ sqfs_u64 start;
+ sqfs_u64 limit;
size_t data_used;
/* The location of the current block in the image */
- uint64_t block_offset;
+ sqfs_u64 block_offset;
/* The location of the next block after the current one */
- uint64_t next_block;
+ sqfs_u64 next_block;
/* A byte offset into the uncompressed data of the current block */
size_t offset;
@@ -39,15 +39,15 @@ struct sqfs_meta_reader_t {
sqfs_compressor_t *cmp;
/* The raw data read from the input file */
- uint8_t data[SQFS_META_BLOCK_SIZE];
+ sqfs_u8 data[SQFS_META_BLOCK_SIZE];
/* The uncompressed data read from the input file */
- uint8_t scratch[SQFS_META_BLOCK_SIZE];
+ sqfs_u8 scratch[SQFS_META_BLOCK_SIZE];
};
sqfs_meta_reader_t *sqfs_meta_reader_create(sqfs_file_t *file,
sqfs_compressor_t *cmp,
- uint64_t start, uint64_t limit)
+ sqfs_u64 start, sqfs_u64 limit)
{
sqfs_meta_reader_t *m = calloc(1, sizeof(*m));
@@ -66,11 +66,11 @@ void sqfs_meta_reader_destroy(sqfs_meta_reader_t *m)
free(m);
}
-int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, uint64_t block_start,
+int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, sqfs_u64 block_start,
size_t offset)
{
bool compressed;
- uint16_t header;
+ sqfs_u16 header;
ssize_t ret;
size_t size;
int err;
@@ -127,7 +127,7 @@ int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, uint64_t block_start,
}
void sqfs_meta_reader_get_position(const sqfs_meta_reader_t *m,
- uint64_t *block_start, size_t *offset)
+ sqfs_u64 *block_start, size_t *offset)
{
*block_start = m->block_offset;
*offset = m->offset;
diff --git a/lib/sqfs/meta_writer.c b/lib/sqfs/meta_writer.c
index 2edc91a..a5ce366 100644
--- a/lib/sqfs/meta_writer.c
+++ b/lib/sqfs/meta_writer.c
@@ -22,7 +22,7 @@ typedef struct meta_block_t {
struct meta_block_t *next;
/* possibly compressed data with 2 byte header */
- uint8_t data[SQFS_META_BLOCK_SIZE + 2];
+ sqfs_u8 data[SQFS_META_BLOCK_SIZE + 2];
} meta_block_t;
struct sqfs_meta_writer_t {
@@ -39,7 +39,7 @@ struct sqfs_meta_writer_t {
sqfs_compressor_t *cmp;
/* The raw data chunk that data is appended to */
- uint8_t data[SQFS_META_BLOCK_SIZE];
+ sqfs_u8 data[SQFS_META_BLOCK_SIZE];
int flags;
meta_block_t *list;
@@ -48,8 +48,8 @@ struct sqfs_meta_writer_t {
static int write_block(sqfs_file_t *file, meta_block_t *outblk)
{
- size_t count = le16toh(((uint16_t *)outblk->data)[0]) & 0x7FFF;
- uint64_t off = file->get_size(file);
+ size_t count = le16toh(((sqfs_u16 *)outblk->data)[0]) & 0x7FFF;
+ sqfs_u64 off = file->get_size(file);
return file->write_at(file, off, outblk->data, count + 2);
}
@@ -107,10 +107,10 @@ int sqfs_meta_writer_flush(sqfs_meta_writer_t *m)
}
if (ret > 0) {
- ((uint16_t *)outblk->data)[0] = htole16(ret);
+ ((sqfs_u16 *)outblk->data)[0] = htole16(ret);
count = ret + 2;
} else {
- ((uint16_t *)outblk->data)[0] = htole16(m->offset | 0x8000);
+ ((sqfs_u16 *)outblk->data)[0] = htole16(m->offset | 0x8000);
memcpy(outblk->data + 2, m->data, m->offset);
count = m->offset + 2;
}
@@ -167,8 +167,8 @@ int sqfs_meta_writer_append(sqfs_meta_writer_t *m, const void *data,
}
void sqfs_meta_writer_get_position(const sqfs_meta_writer_t *m,
- uint64_t *block_start,
- uint32_t *offset)
+ sqfs_u64 *block_start,
+ sqfs_u32 *offset)
{
*block_start = m->block_offset;
*offset = m->offset;
diff --git a/lib/sqfs/read_inode.c b/lib/sqfs/read_inode.c
index 5a87a45..1916c96 100644
--- a/lib/sqfs/read_inode.c
+++ b/lib/sqfs/read_inode.c
@@ -61,10 +61,10 @@ static int set_mode(sqfs_inode_t *inode)
return 0;
}
-static uint64_t get_block_count(uint64_t size, uint64_t block_size,
- uint32_t frag_index, uint32_t frag_offset)
+static sqfs_u64 get_block_count(sqfs_u64 size, sqfs_u64 block_size,
+ sqfs_u32 frag_index, sqfs_u32 frag_offset)
{
- uint64_t count = size / block_size;
+ sqfs_u64 count = size / block_size;
if ((size % block_size) != 0 &&
(frag_index == 0xFFFFFFFF || frag_offset == 0xFFFFFFFF)) {
@@ -79,7 +79,7 @@ static int read_inode_file(sqfs_meta_reader_t *ir, sqfs_inode_t *base,
{
sqfs_inode_generic_t *out;
sqfs_inode_file_t file;
- uint64_t i, count;
+ sqfs_u64 i, count;
int err;
err = sqfs_meta_reader_read(ir, &file, sizeof(file));
@@ -94,17 +94,17 @@ static int read_inode_file(sqfs_meta_reader_t *ir, sqfs_inode_t *base,
count = get_block_count(file.file_size, block_size,
file.fragment_index, file.fragment_offset);
- out = alloc_flex(sizeof(*out), sizeof(uint32_t), count);
+ out = alloc_flex(sizeof(*out), sizeof(sqfs_u32), count);
if (out == NULL)
return SQFS_ERROR_ALLOC;
out->base = *base;
out->data.file = file;
- out->block_sizes = (uint32_t *)out->extra;
+ out->block_sizes = (sqfs_u32 *)out->extra;
out->num_file_blocks = count;
err = sqfs_meta_reader_read(ir, out->block_sizes,
- count * sizeof(uint32_t));
+ count * sizeof(sqfs_u32));
if (err) {
free(out);
return err;
@@ -122,7 +122,7 @@ static int read_inode_file_ext(sqfs_meta_reader_t *ir, sqfs_inode_t *base,
{
sqfs_inode_file_ext_t file;
sqfs_inode_generic_t *out;
- uint64_t i, count;
+ sqfs_u64 i, count;
int err;
err = sqfs_meta_reader_read(ir, &file, sizeof(file));
@@ -140,7 +140,7 @@ static int read_inode_file_ext(sqfs_meta_reader_t *ir, sqfs_inode_t *base,
count = get_block_count(file.file_size, block_size,
file.fragment_idx, file.fragment_offset);
- out = alloc_flex(sizeof(*out), sizeof(uint32_t), count);
+ out = alloc_flex(sizeof(*out), sizeof(sqfs_u32), count);
if (out == NULL) {
return errno == EOVERFLOW ? SQFS_ERROR_OVERFLOW :
SQFS_ERROR_ALLOC;
@@ -148,11 +148,11 @@ static int read_inode_file_ext(sqfs_meta_reader_t *ir, sqfs_inode_t *base,
out->base = *base;
out->data.file_ext = file;
- out->block_sizes = (uint32_t *)out->extra;
+ out->block_sizes = (sqfs_u32 *)out->extra;
out->num_file_blocks = count;
err = sqfs_meta_reader_read(ir, out->block_sizes,
- count * sizeof(uint32_t));
+ count * sizeof(sqfs_u32));
if (err) {
free(out);
return err;
@@ -206,7 +206,7 @@ static int read_inode_slink(sqfs_meta_reader_t *ir, sqfs_inode_t *base,
static int read_inode_slink_ext(sqfs_meta_reader_t *ir, sqfs_inode_t *base,
sqfs_inode_generic_t **result)
{
- uint32_t xattr;
+ sqfs_u32 xattr;
int err;
err = read_inode_slink(ir, base, result);
@@ -225,7 +225,7 @@ static int read_inode_slink_ext(sqfs_meta_reader_t *ir, sqfs_inode_t *base,
int sqfs_meta_reader_read_inode(sqfs_meta_reader_t *ir,
const sqfs_super_t *super,
- uint64_t block_start, size_t offset,
+ sqfs_u64 block_start, size_t offset,
sqfs_inode_generic_t **result)
{
sqfs_inode_generic_t *out;
diff --git a/lib/sqfs/read_table.c b/lib/sqfs/read_table.c
index 239607e..4c5a5cc 100644
--- a/lib/sqfs/read_table.c
+++ b/lib/sqfs/read_table.c
@@ -18,11 +18,11 @@
#include <stdlib.h>
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 table_size, sqfs_u64 location, sqfs_u64 lower_limit,
+ sqfs_u64 upper_limit, void **out)
{
size_t diff, block_count, blk_idx = 0;
- uint64_t start, *locations;
+ sqfs_u64 start, *locations;
sqfs_meta_reader_t *m;
void *data, *ptr;
int err;
@@ -37,7 +37,7 @@ int sqfs_read_table(sqfs_file_t *file, sqfs_compressor_t *cmp,
if ((table_size % SQFS_META_BLOCK_SIZE) != 0)
++block_count;
- locations = alloc_array(sizeof(uint64_t), block_count);
+ locations = alloc_array(sizeof(sqfs_u64), block_count);
if (locations == NULL) {
err = SQFS_ERROR_ALLOC;
@@ -45,7 +45,7 @@ int sqfs_read_table(sqfs_file_t *file, sqfs_compressor_t *cmp,
}
err = file->read_at(file, location, locations,
- sizeof(uint64_t) * block_count);
+ sizeof(sqfs_u64) * block_count);
if (err)
goto fail_idx;
diff --git a/lib/sqfs/read_tree.c b/lib/sqfs/read_tree.c
index f32f63c..4672a4e 100644
--- a/lib/sqfs/read_tree.c
+++ b/lib/sqfs/read_tree.c
@@ -44,7 +44,7 @@ static int should_skip(int type, unsigned int flags)
static bool would_be_own_parent(sqfs_tree_node_t *parent, sqfs_tree_node_t *n)
{
- uint32_t inum = n->inode->base.inode_number;
+ sqfs_u32 inum = n->inode->base.inode_number;
while (parent != NULL) {
if (parent->inode->base.inode_number == inum)
diff --git a/lib/sqfs/readdir.c b/lib/sqfs/readdir.c
index 9db316e..6b549b7 100644
--- a/lib/sqfs/readdir.c
+++ b/lib/sqfs/readdir.c
@@ -35,14 +35,14 @@ int sqfs_meta_reader_read_dir_ent(sqfs_meta_reader_t *m,
sqfs_dir_entry_t **result)
{
sqfs_dir_entry_t ent, *out;
- uint16_t *diff_u16;
+ sqfs_u16 *diff_u16;
int err;
err = sqfs_meta_reader_read(m, &ent, sizeof(ent));
if (err)
return err;
- diff_u16 = (uint16_t *)&ent.inode_diff;
+ diff_u16 = (sqfs_u16 *)&ent.inode_diff;
*diff_u16 = le16toh(*diff_u16);
ent.offset = le16toh(ent.offset);
diff --git a/lib/sqfs/super.c b/lib/sqfs/super.c
index ad42c9f..5cd5a87 100644
--- a/lib/sqfs/super.c
+++ b/lib/sqfs/super.c
@@ -16,7 +16,7 @@
#include <string.h>
#include <unistd.h>
-int sqfs_super_init(sqfs_super_t *super, size_t block_size, uint32_t mtime,
+int sqfs_super_init(sqfs_super_t *super, size_t block_size, sqfs_u32 mtime,
E_SQFS_COMPRESSOR compressor)
{
unsigned int i;
diff --git a/lib/sqfs/write_inode.c b/lib/sqfs/write_inode.c
index 422959e..b16ef65 100644
--- a/lib/sqfs/write_inode.c
+++ b/lib/sqfs/write_inode.c
@@ -14,14 +14,14 @@
static int write_block_sizes(sqfs_meta_writer_t *ir,
const sqfs_inode_generic_t *n)
{
- uint32_t sizes[n->num_file_blocks];
+ sqfs_u32 sizes[n->num_file_blocks];
size_t i;
for (i = 0; i < n->num_file_blocks; ++i)
sizes[i] = htole32(n->block_sizes[i]);
return sqfs_meta_writer_append(ir, sizes,
- sizeof(uint32_t) * n->num_file_blocks);
+ sizeof(sqfs_u32) * n->num_file_blocks);
}
int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *ir,
@@ -124,7 +124,7 @@ int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *ir,
.nlink = htole32(n->data.slink_ext.nlink),
.target_size = htole32(n->data.slink_ext.target_size),
};
- uint32_t xattr = htole32(n->data.slink_ext.xattr_idx);
+ sqfs_u32 xattr = htole32(n->data.slink_ext.xattr_idx);
ret = sqfs_meta_writer_append(ir, &slink, sizeof(slink));
if (ret)
diff --git a/lib/sqfs/write_table.c b/lib/sqfs/write_table.c
index 5f11769..c50cf06 100644
--- a/lib/sqfs/write_table.c
+++ b/lib/sqfs/write_table.c
@@ -19,10 +19,10 @@
#include <stdlib.h>
int sqfs_write_table(sqfs_file_t *file, sqfs_compressor_t *cmp,
- const void *data, size_t table_size, uint64_t *start)
+ const void *data, size_t table_size, sqfs_u64 *start)
{
size_t block_count, list_size, diff, blkidx = 0;
- uint64_t off, *locations;
+ sqfs_u64 off, *locations;
sqfs_meta_writer_t *m;
int ret;
@@ -30,7 +30,7 @@ int sqfs_write_table(sqfs_file_t *file, sqfs_compressor_t *cmp,
if ((table_size % SQFS_META_BLOCK_SIZE) != 0)
++block_count;
- locations = alloc_array(sizeof(uint64_t), block_count);
+ locations = alloc_array(sizeof(sqfs_u64), block_count);
if (locations == NULL)
return SQFS_ERROR_ALLOC;
@@ -64,7 +64,7 @@ int sqfs_write_table(sqfs_file_t *file, sqfs_compressor_t *cmp,
/* write location list */
*start = file->get_size(file);
- list_size = sizeof(uint64_t) * block_count;
+ list_size = sizeof(sqfs_u64) * block_count;
off = file->get_size(file);
diff --git a/lib/sqfs/xattr_reader.c b/lib/sqfs/xattr_reader.c
index 4164f66..fb9c36a 100644
--- a/lib/sqfs/xattr_reader.c
+++ b/lib/sqfs/xattr_reader.c
@@ -20,12 +20,12 @@
#include <errno.h>
struct sqfs_xattr_reader_t {
- uint64_t xattr_start;
+ sqfs_u64 xattr_start;
size_t num_id_blocks;
size_t num_ids;
- uint64_t *id_block_starts;
+ sqfs_u64 *id_block_starts;
sqfs_meta_reader_t *idrd;
sqfs_meta_reader_t *kvrd;
@@ -61,7 +61,7 @@ int sqfs_xattr_reader_load_locations(sqfs_xattr_reader_t *xr)
if ((xr->num_ids * sizeof(sqfs_xattr_id_t)) % SQFS_META_BLOCK_SIZE)
xr->num_id_blocks += 1;
- xr->id_block_starts = alloc_array(sizeof(uint64_t), xr->num_id_blocks);
+ xr->id_block_starts = alloc_array(sizeof(sqfs_u64), xr->num_id_blocks);
if (xr->id_block_starts == NULL) {
if (errno == EOVERFLOW)
return SQFS_ERROR_OVERFLOW;
@@ -71,7 +71,7 @@ int sqfs_xattr_reader_load_locations(sqfs_xattr_reader_t *xr)
err = xr->file->read_at(xr->file,
xr->super->xattr_id_table_start + sizeof(idtbl),
xr->id_block_starts,
- sizeof(uint64_t) * xr->num_id_blocks);
+ sizeof(sqfs_u64) * xr->num_id_blocks);
if (err)
goto fail;
@@ -140,7 +140,7 @@ int sqfs_xattr_reader_read_value(sqfs_xattr_reader_t *xr,
{
size_t offset, new_offset, size;
sqfs_xattr_value_t value, *out;
- uint64_t ref, start, new_start;
+ sqfs_u64 ref, start, new_start;
int ret;
ret = sqfs_meta_reader_read(xr->kvrd, &value, sizeof(value));
@@ -200,13 +200,13 @@ fail:
int sqfs_xattr_reader_seek_kv(sqfs_xattr_reader_t *xr,
const sqfs_xattr_id_t *desc)
{
- uint32_t offset = desc->xattr & 0xFFFF;
- uint64_t block = xr->xattr_start + (desc->xattr >> 16);
+ sqfs_u32 offset = desc->xattr & 0xFFFF;
+ sqfs_u64 block = xr->xattr_start + (desc->xattr >> 16);
return sqfs_meta_reader_seek(xr->kvrd, block, offset);
}
-int sqfs_xattr_reader_get_desc(sqfs_xattr_reader_t *xr, uint32_t idx,
+int sqfs_xattr_reader_get_desc(sqfs_xattr_reader_t *xr, sqfs_u32 idx,
sqfs_xattr_id_t *desc)
{
size_t block, offset;
diff --git a/lib/sqfshelper/comp_opt.c b/lib/sqfshelper/comp_opt.c
index c942d23..fa4157b 100644
--- a/lib/sqfshelper/comp_opt.c
+++ b/lib/sqfshelper/comp_opt.c
@@ -15,7 +15,7 @@
typedef struct {
const char *name;
- uint16_t flag;
+ sqfs_u16 flag;
} flag_t;
static const flag_t gzip_flags[] = {
@@ -76,7 +76,7 @@ static int find_lzo_alg(sqfs_compressor_config_t *cfg, const char *name)
return -1;
}
-static int get_size_value(const char *value, uint32_t *out, uint32_t block_size)
+static int get_size_value(const char *value, sqfs_u32 *out, sqfs_u32 block_size)
{
int i;
diff --git a/lib/sqfshelper/data_reader_dump.c b/lib/sqfshelper/data_reader_dump.c
index 5675469..160f7f0 100644
--- a/lib/sqfshelper/data_reader_dump.c
+++ b/lib/sqfshelper/data_reader_dump.c
@@ -21,7 +21,7 @@ int sqfs_data_reader_dump(sqfs_data_reader_t *data,
int outfd, size_t block_size, bool allow_sparse)
{
sqfs_block_t *blk;
- uint64_t filesz;
+ sqfs_u64 filesz;
size_t i, diff;
int err;
diff --git a/lib/sqfshelper/data_writer.c b/lib/sqfshelper/data_writer.c
index d9e11a6..aa51b26 100644
--- a/lib/sqfshelper/data_writer.c
+++ b/lib/sqfshelper/data_writer.c
@@ -9,12 +9,12 @@
#include "highlevel.h"
#include "util.h"
-static uint8_t buffer[4096];
+static sqfs_u8 buffer[4096];
int write_data_from_file(sqfs_data_writer_t *data, sqfs_inode_generic_t *inode,
sqfs_file_t *file, int flags)
{
- uint64_t filesz, offset;
+ sqfs_u64 filesz, offset;
size_t diff;
int ret;
diff --git a/lib/sqfshelper/io_stdin.c b/lib/sqfshelper/io_stdin.c
index 8568f5e..fec8db7 100644
--- a/lib/sqfshelper/io_stdin.c
+++ b/lib/sqfshelper/io_stdin.c
@@ -19,8 +19,8 @@ typedef struct {
sqfs_file_t base;
const sparse_map_t *map;
- uint64_t offset;
- uint64_t size;
+ sqfs_u64 offset;
+ sqfs_u64 size;
} sqfs_file_stdin_t;
@@ -29,13 +29,13 @@ static void stdin_destroy(sqfs_file_t *base)
free(base);
}
-static int stdin_read_at(sqfs_file_t *base, uint64_t offset,
+static int stdin_read_at(sqfs_file_t *base, sqfs_u64 offset,
void *buffer, size_t size)
{
sqfs_file_stdin_t *file = (sqfs_file_stdin_t *)base;
size_t temp_size = 0;
- uint8_t *temp = NULL;
- uint64_t diff;
+ sqfs_u8 *temp = NULL;
+ sqfs_u64 diff;
ssize_t ret;
if (offset < file->offset)
@@ -52,7 +52,7 @@ static int stdin_read_at(sqfs_file_t *base, uint64_t offset,
while (size > 0) {
if (offset > file->offset) {
diff = file->offset - offset;
- diff = diff > (uint64_t)temp_size ? temp_size : diff;
+ diff = diff > (sqfs_u64)temp_size ? temp_size : diff;
ret = read(STDIN_FILENO, temp, diff);
} else {
@@ -80,11 +80,11 @@ static int stdin_read_at(sqfs_file_t *base, uint64_t offset,
return 0;
}
-static int stdin_read_condensed(sqfs_file_t *base, uint64_t offset,
+static int stdin_read_condensed(sqfs_file_t *base, sqfs_u64 offset,
void *buffer, size_t size)
{
sqfs_file_stdin_t *file = (sqfs_file_stdin_t *)base;
- uint64_t poffset = 0, src_start;
+ sqfs_u64 poffset = 0, src_start;
size_t dst_start, diff, count;
const sparse_map_t *it;
int err;
@@ -134,25 +134,25 @@ static int stdin_read_condensed(sqfs_file_t *base, uint64_t offset,
return 0;
}
-static int stdin_write_at(sqfs_file_t *base, uint64_t offset,
+static int stdin_write_at(sqfs_file_t *base, sqfs_u64 offset,
const void *buffer, size_t size)
{
(void)base; (void)offset; (void)buffer; (void)size;
return SQFS_ERROR_IO;
}
-static uint64_t stdin_get_size(const sqfs_file_t *base)
+static sqfs_u64 stdin_get_size(const sqfs_file_t *base)
{
return ((const sqfs_file_stdin_t *)base)->size;
}
-static int stdin_truncate(sqfs_file_t *base, uint64_t size)
+static int stdin_truncate(sqfs_file_t *base, sqfs_u64 size)
{
(void)base; (void)size;
return SQFS_ERROR_IO;
}
-sqfs_file_t *sqfs_get_stdin_file(const sparse_map_t *map, uint64_t size)
+sqfs_file_t *sqfs_get_stdin_file(const sparse_map_t *map, sqfs_u64 size)
{
sqfs_file_stdin_t *file = calloc(1, sizeof(*file));
sqfs_file_t *base = (sqfs_file_t *)file;
diff --git a/lib/sqfshelper/serialize_fstree.c b/lib/sqfshelper/serialize_fstree.c
index 296f123..2ec7daa 100644
--- a/lib/sqfshelper/serialize_fstree.c
+++ b/lib/sqfshelper/serialize_fstree.c
@@ -18,7 +18,7 @@ static sqfs_inode_generic_t *write_dir_entries(sqfs_dir_writer_t *dirw,
tree_node_t *node,
sqfs_id_table_t *idtbl)
{
- uint32_t xattr, parent_inode;
+ sqfs_u32 xattr, parent_inode;
sqfs_inode_generic_t *inode;
tree_node_t *it;
int ret;
@@ -67,8 +67,8 @@ int sqfs_serialize_fstree(sqfs_file_t *file, sqfs_super_t *super, fstree_t *fs,
sqfs_inode_generic_t *inode;
sqfs_meta_writer_t *im, *dm;
sqfs_dir_writer_t *dirwr;
- uint32_t offset;
- uint64_t block;
+ sqfs_u32 offset;
+ sqfs_u64 block;
int ret = -1;
size_t i;
diff --git a/lib/sqfshelper/statistics.c b/lib/sqfshelper/statistics.c
index 26c121f..3f9f595 100644
--- a/lib/sqfshelper/statistics.c
+++ b/lib/sqfshelper/statistics.c
@@ -37,7 +37,7 @@ static void pre_fragment_store(void *user, sqfs_block_t *block)
stats->frag_count += 1;
}
-static void notify_blocks_erased(void *user, size_t count, uint64_t bytes)
+static void notify_blocks_erased(void *user, size_t count, sqfs_u64 bytes)
{
data_writer_stats_t *stats = user;
diff --git a/lib/sqfshelper/tree_node_to_inode.c b/lib/sqfshelper/tree_node_to_inode.c
index edcdee3..62a804d 100644
--- a/lib/sqfshelper/tree_node_to_inode.c
+++ b/lib/sqfshelper/tree_node_to_inode.c
@@ -47,8 +47,8 @@ sqfs_inode_generic_t *tree_node_to_inode(sqfs_id_table_t *idtbl,
tree_node_t *node)
{
sqfs_inode_generic_t *inode;
- uint16_t uid_idx, gid_idx;
- uint32_t xattr = 0xFFFFFFFF;
+ sqfs_u16 uid_idx, gid_idx;
+ sqfs_u32 xattr = 0xFFFFFFFF;
size_t extra = 0;
if (S_ISREG(node->mode)) {
diff --git a/lib/sqfshelper/write_export_table.c b/lib/sqfshelper/write_export_table.c
index b320381..566c509 100644
--- a/lib/sqfshelper/write_export_table.c
+++ b/lib/sqfshelper/write_export_table.c
@@ -15,14 +15,14 @@
int write_export_table(sqfs_file_t *file, fstree_t *fs, sqfs_super_t *super,
sqfs_compressor_t *cmp)
{
- uint64_t *table, start;
+ sqfs_u64 *table, start;
size_t i, size;
int ret;
if (fs->inode_tbl_size < 1)
return 0;
- table = alloc_array(sizeof(uint64_t), (fs->inode_tbl_size - 1));
+ table = alloc_array(sizeof(sqfs_u64), (fs->inode_tbl_size - 1));
if (table == NULL) {
perror("Allocating NFS export table");
@@ -37,7 +37,7 @@ int write_export_table(sqfs_file_t *file, fstree_t *fs, sqfs_super_t *super,
}
}
- size = sizeof(uint64_t) * (fs->inode_tbl_size - 1);
+ size = sizeof(sqfs_u64) * (fs->inode_tbl_size - 1);
ret = sqfs_write_table(file, cmp, table, size, &start);
super->export_table_start = start;
diff --git a/lib/sqfshelper/write_xattr.c b/lib/sqfshelper/write_xattr.c
index 8faa9ff..a3f5170 100644
--- a/lib/sqfshelper/write_xattr.c
+++ b/lib/sqfshelper/write_xattr.c
@@ -48,11 +48,11 @@ static int write_key(sqfs_meta_writer_t *mw, const char *key,
}
static int write_value(sqfs_meta_writer_t *mw, const char *value,
- tree_xattr_t *xattr, uint64_t *value_ref_out)
+ tree_xattr_t *xattr, sqfs_u64 *value_ref_out)
{
sqfs_xattr_value_t vent;
- uint32_t offset;
- uint64_t block;
+ sqfs_u32 offset;
+ sqfs_u64 block;
sqfs_meta_writer_get_position(mw, &block, &offset);
*value_ref_out = (block << 16) | (offset & 0xFFFF);
@@ -69,11 +69,11 @@ static int write_value(sqfs_meta_writer_t *mw, const char *value,
return 0;
}
-static int write_value_ool(sqfs_meta_writer_t *mw, uint64_t location,
+static int write_value_ool(sqfs_meta_writer_t *mw, sqfs_u64 location,
tree_xattr_t *xattr)
{
sqfs_xattr_value_t vent;
- uint64_t ref;
+ sqfs_u64 ref;
vent.size = htole32(sizeof(location));
if (sqfs_meta_writer_append(mw, &vent, sizeof(vent)))
@@ -109,15 +109,15 @@ static bool should_store_ool(fstree_t *fs, const char *value, size_t index)
Note that this only holds iff refcount - 1 != 0, i.e. refcount > 1,
otherwise we would be dividing by 0 in the 3rd step.
*/
- return strlen(value) > sizeof(uint64_t);
+ return strlen(value) > sizeof(sqfs_u64);
}
static int write_kv_pairs(fstree_t *fs, sqfs_meta_writer_t *mw,
- tree_xattr_t *xattr, uint64_t *ool_locations)
+ tree_xattr_t *xattr, sqfs_u64 *ool_locations)
{
- uint32_t key_idx, val_idx;
+ sqfs_u32 key_idx, val_idx;
const char *key, *value;
- uint64_t ref;
+ sqfs_u64 ref;
size_t i;
for (i = 0; i < xattr->num_attr; ++i) {
@@ -148,12 +148,12 @@ static int write_kv_pairs(fstree_t *fs, sqfs_meta_writer_t *mw,
return 0;
}
-static uint64_t *create_ool_locations_table(fstree_t *fs)
+static sqfs_u64 *create_ool_locations_table(fstree_t *fs)
{
- uint64_t *table;
+ sqfs_u64 *table;
size_t i;
- table = alloc_array(sizeof(uint64_t), fs->xattr_values.num_strings);
+ table = alloc_array(sizeof(sqfs_u64), fs->xattr_values.num_strings);
if (table == NULL) {
perror("allocating Xattr OOL locations table");
@@ -170,13 +170,13 @@ static uint64_t *create_ool_locations_table(fstree_t *fs)
int write_xattr(sqfs_file_t *file, fstree_t *fs, sqfs_super_t *super,
sqfs_compressor_t *cmp)
{
- uint64_t kv_start, id_start, block, off, *tbl, *ool_locations;
+ sqfs_u64 kv_start, id_start, block, off, *tbl, *ool_locations;
size_t i = 0, count = 0, blocks;
sqfs_xattr_id_table_t idtbl;
sqfs_xattr_id_t id_ent;
sqfs_meta_writer_t *mw;
tree_xattr_t *it;
- uint32_t offset;
+ sqfs_u32 offset;
if (fs->xattr == NULL)
return 0;
@@ -213,7 +213,7 @@ int write_xattr(sqfs_file_t *file, fstree_t *fs, sqfs_super_t *super,
if ((count * sizeof(id_ent)) % SQFS_META_BLOCK_SIZE)
++blocks;
- tbl = alloc_array(sizeof(uint64_t), blocks);
+ tbl = alloc_array(sizeof(sqfs_u64), blocks);
if (tbl == NULL) {
perror("generating xattr ID table");
diff --git a/lib/tar/base64.c b/lib/tar/base64.c
index edb2d61..0ccf3c4 100644
--- a/lib/tar/base64.c
+++ b/lib/tar/base64.c
@@ -8,7 +8,7 @@
#include "internal.h"
-static uint8_t convert(char in)
+static sqfs_u8 convert(char in)
{
if (isupper(in))
return in - 'A';
@@ -23,7 +23,7 @@ static uint8_t convert(char in)
return 0;
}
-void base64_decode(uint8_t *out, const char *in)
+void base64_decode(sqfs_u8 *out, const char *in)
{
char temp[4];
diff --git a/lib/tar/checksum.c b/lib/tar/checksum.c
index 6bbe5d8..144ba43 100644
--- a/lib/tar/checksum.c
+++ b/lib/tar/checksum.c
@@ -38,7 +38,7 @@ void update_checksum(tar_header_t *hdr)
bool is_checksum_valid(const tar_header_t *hdr)
{
unsigned int calculated_chksum = get_checksum(hdr);
- uint64_t read_chksum;
+ sqfs_u64 read_chksum;
if (read_octal(hdr->chksum, sizeof(hdr->chksum), &read_chksum))
return 0;
diff --git a/lib/tar/internal.h b/lib/tar/internal.h
index d95ef52..f30de29 100644
--- a/lib/tar/internal.h
+++ b/lib/tar/internal.h
@@ -43,13 +43,13 @@ enum {
#define TAR_MAX_PAX_LEN (65536)
-int read_octal(const char *str, int digits, uint64_t *out);
+int read_octal(const char *str, int digits, sqfs_u64 *out);
-int read_binary(const char *str, int digits, uint64_t *out);
+int read_binary(const char *str, int digits, sqfs_u64 *out);
-int read_number(const char *str, int digits, uint64_t *out);
+int read_number(const char *str, int digits, sqfs_u64 *out);
-int pax_read_decimal(const char *str, uint64_t *out);
+int pax_read_decimal(const char *str, sqfs_u64 *out);
void update_checksum(tar_header_t *hdr);
@@ -63,7 +63,7 @@ void free_sparse_list(sparse_map_t *sparse);
void free_xattr_list(tar_xattr_t *list);
-void base64_decode(uint8_t *out, const char *in);
+void base64_decode(sqfs_u8 *out, const char *in);
void urldecode(char *str);
diff --git a/lib/tar/number.c b/lib/tar/number.c
index e2a3dd4..06d5317 100644
--- a/lib/tar/number.c
+++ b/lib/tar/number.c
@@ -8,9 +8,9 @@
#include "internal.h"
-int read_octal(const char *str, int digits, uint64_t *out)
+int read_octal(const char *str, int digits, sqfs_u64 *out)
{
- uint64_t result = 0;
+ sqfs_u64 result = 0;
while (digits > 0 && isspace(*str)) {
++str;
@@ -31,9 +31,9 @@ int read_octal(const char *str, int digits, uint64_t *out)
return 0;
}
-int read_binary(const char *str, int digits, uint64_t *out)
+int read_binary(const char *str, int digits, sqfs_u64 *out)
{
- uint64_t x, ov, result = 0;
+ sqfs_u64 x, ov, result = 0;
bool first = true;
while (digits > 0) {
@@ -67,7 +67,7 @@ fail_ov:
return -1;
}
-int read_number(const char *str, int digits, uint64_t *out)
+int read_number(const char *str, int digits, sqfs_u64 *out)
{
if (*((unsigned char *)str) & 0x80)
return read_binary(str, digits, out);
@@ -75,9 +75,9 @@ int read_number(const char *str, int digits, uint64_t *out)
return read_octal(str, digits, out);
}
-int pax_read_decimal(const char *str, uint64_t *out)
+int pax_read_decimal(const char *str, sqfs_u64 *out)
{
- uint64_t result = 0;
+ sqfs_u64 result = 0;
while (*str >= '0' && *str <= '9') {
if (result > 0xFFFFFFFFFFFFFFFFUL / 10) {
diff --git a/lib/tar/read_header.c b/lib/tar/read_header.c
index 63de699..f6d746b 100644
--- a/lib/tar/read_header.c
+++ b/lib/tar/read_header.c
@@ -35,7 +35,7 @@ static int check_version(const tar_header_t *hdr)
return ETV_UNKNOWN;
}
-static char *record_to_memory(int fd, uint64_t size)
+static char *record_to_memory(int fd, sqfs_u64 size)
{
char *buffer = malloc(size + 1);
@@ -74,14 +74,14 @@ static tar_xattr_t *mkxattr(const char *key, size_t keylen,
return xattr;
}
-static int read_pax_header(int fd, uint64_t entsize, unsigned int *set_by_pax,
+static int read_pax_header(int fd, sqfs_u64 entsize, unsigned int *set_by_pax,
tar_header_decoded_t *out)
{
sparse_map_t *sparse_last = NULL, *sparse;
- uint64_t field, offset = 0, num_bytes = 0;
+ sqfs_u64 field, offset = 0, num_bytes = 0;
char *buffer, *line, *key, *ptr, *value;
tar_xattr_t *xattr;
- uint64_t i;
+ sqfs_u64 i;
buffer = record_to_memory(fd, entsize);
if (buffer == NULL)
@@ -134,7 +134,7 @@ static int read_pax_header(int fd, uint64_t entsize, unsigned int *set_by_pax,
if (line[6] == '-') {
if (pax_read_decimal(line + 7, &field))
goto fail;
- out->mtime = -((int64_t)field);
+ out->mtime = -((sqfs_s64)field);
} else {
if (pax_read_decimal(line + 6, &field))
goto fail;
@@ -205,7 +205,7 @@ static int read_pax_header(int fd, uint64_t entsize, unsigned int *set_by_pax,
goto fail_errno;
urldecode(xattr->key);
- base64_decode((uint8_t *)xattr->value, value);
+ base64_decode((sqfs_u8 *)xattr->value, value);
xattr->next = out->xattr;
out->xattr = xattr;
@@ -226,7 +226,7 @@ static int decode_header(const tar_header_t *hdr, unsigned int set_by_pax,
tar_header_decoded_t *out, int version)
{
size_t len1, len2;
- uint64_t field;
+ sqfs_u64 field;
if (!(set_by_pax & PAX_NAME)) {
if (hdr->tail.posix.prefix[0] != '\0' &&
@@ -289,7 +289,7 @@ static int decode_header(const tar_header_t *hdr, unsigned int set_by_pax,
return -1;
if (field & 0x8000000000000000UL) {
field = ~field + 1;
- out->mtime = -((int64_t)field);
+ out->mtime = -((sqfs_s64)field);
} else {
out->mtime = field;
}
@@ -344,9 +344,9 @@ static int decode_header(const tar_header_t *hdr, unsigned int set_by_pax,
}
#if SIZEOF_TIME_T < 8
- if (out->mtime > (int64_t)INT32_MAX) {
+ if (out->mtime > (sqfs_s64)INT32_MAX) {
out->sb.st_mtime = INT32_MAX;
- } else if (out->mtime < (int64_t)INT32_MIN) {
+ } else if (out->mtime < (sqfs_s64)INT32_MIN) {
out->sb.st_mtime = INT32_MIN;
} else {
out->sb.st_mtime = out->mtime;
@@ -361,7 +361,7 @@ int read_header(int fd, tar_header_decoded_t *out)
{
unsigned int set_by_pax = 0;
bool prev_was_zero = false;
- uint64_t pax_size;
+ sqfs_u64 pax_size;
tar_header_t hdr;
int version;
diff --git a/lib/tar/read_sparse_map_old.c b/lib/tar/read_sparse_map_old.c
index 5891bdb..fb79eca 100644
--- a/lib/tar/read_sparse_map_old.c
+++ b/lib/tar/read_sparse_map_old.c
@@ -12,7 +12,7 @@ sparse_map_t *read_gnu_old_sparse(int fd, tar_header_t *hdr)
{
sparse_map_t *list = NULL, *end = NULL, *node;
gnu_sparse_t sph;
- uint64_t off, sz;
+ sqfs_u64 off, sz;
int i;
for (i = 0; i < 4; ++i) {
diff --git a/lib/tar/skip.c b/lib/tar/skip.c
index 3cdfb8b..eb91416 100644
--- a/lib/tar/skip.c
+++ b/lib/tar/skip.c
@@ -11,7 +11,7 @@
#include <stdio.h>
-static int skip_bytes(int fd, uint64_t size)
+static int skip_bytes(int fd, sqfs_u64 size)
{
unsigned char buffer[1024];
size_t diff;
@@ -30,14 +30,14 @@ static int skip_bytes(int fd, uint64_t size)
return 0;
}
-int skip_padding(int fd, uint64_t size)
+int skip_padding(int fd, sqfs_u64 size)
{
size_t tail = size % 512;
return tail ? skip_bytes(fd, 512 - tail) : 0;
}
-int skip_entry(int fd, uint64_t size)
+int skip_entry(int fd, sqfs_u64 size)
{
size_t tail = size % 512;
diff --git a/lib/tar/write_header.c b/lib/tar/write_header.c
index d3a184a..4c8caa2 100644
--- a/lib/tar/write_header.c
+++ b/lib/tar/write_header.c
@@ -8,7 +8,7 @@
#include "internal.h"
-static void write_binary(char *dst, uint64_t value, int digits)
+static void write_binary(char *dst, sqfs_u64 value, int digits)
{
memset(dst, 0, digits);
@@ -21,9 +21,9 @@ static void write_binary(char *dst, uint64_t value, int digits)
((unsigned char *)dst)[0] |= 0x80;
}
-static void write_number(char *dst, uint64_t value, int digits)
+static void write_number(char *dst, sqfs_u64 value, int digits)
{
- uint64_t mask = 0;
+ sqfs_u64 mask = 0;
char buffer[64];
int i;
@@ -41,9 +41,9 @@ static void write_number(char *dst, uint64_t value, int digits)
}
}
-static void write_number_signed(char *dst, int64_t value, int digits)
+static void write_number_signed(char *dst, sqfs_s64 value, int digits)
{
- uint64_t neg;
+ sqfs_u64 neg;
if (value < 0) {
neg = -value;
@@ -57,7 +57,7 @@ static int write_header(int fd, const struct stat *sb, const char *name,
const char *slink_target, int type)
{
int maj = 0, min = 0;
- uint64_t size = 0;
+ sqfs_u64 size = 0;
tar_header_t hdr;
if (S_ISCHR(sb->st_mode) || S_ISBLK(sb->st_mode)) {
diff --git a/lib/util/padd_file.c b/lib/util/padd_file.c
index 8c7120b..53e1a42 100644
--- a/lib/util/padd_file.c
+++ b/lib/util/padd_file.c
@@ -12,11 +12,11 @@
#include <stdlib.h>
#include <stdio.h>
-int padd_file(int outfd, uint64_t size, size_t blocksize)
+int padd_file(int outfd, sqfs_u64 size, size_t blocksize)
{
size_t padd_sz = size % blocksize;
int status = -1;
- uint8_t *buffer;
+ sqfs_u8 *buffer;
if (padd_sz == 0)
return 0;
@@ -41,11 +41,11 @@ fail_errno:
goto out;
}
-int padd_sqfs(sqfs_file_t *file, uint64_t size, size_t blocksize)
+int padd_sqfs(sqfs_file_t *file, sqfs_u64 size, size_t blocksize)
{
size_t padd_sz = size % blocksize;
int status = -1;
- uint8_t *buffer;
+ sqfs_u8 *buffer;
if (padd_sz == 0)
return 0;
diff --git a/lib/util/str_table.c b/lib/util/str_table.c
index 5f6543e..dba61fe 100644
--- a/lib/util/str_table.c
+++ b/lib/util/str_table.c
@@ -15,10 +15,10 @@
#include "util.h"
/* R5 hash function (borrowed from reiserfs) */
-static uint32_t strhash(const char *s)
+static sqfs_u32 strhash(const char *s)
{
const signed char *str = (const signed char *)s;
- uint32_t a = 0;
+ sqfs_u32 a = 0;
while (*str != '\0') {
a += *str << 4;
@@ -89,7 +89,7 @@ void str_table_cleanup(str_table_t *table)
int str_table_get_index(str_table_t *table, const char *str, size_t *idx)
{
str_bucket_t *bucket;
- uint32_t hash;
+ sqfs_u32 hash;
size_t index;
hash = strhash(str);
@@ -140,7 +140,7 @@ const char *str_table_get_string(str_table_t *table, size_t index)
static str_bucket_t *bucket_by_index(str_table_t *table, size_t index)
{
str_bucket_t *bucket = NULL;
- uint32_t hash;
+ sqfs_u32 hash;
if (index < table->num_strings) {
hash = strhash(table->strings[index]);