summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--difftool/compare_files.c4
-rw-r--r--difftool/super.c12
-rw-r--r--include/fstree.h30
-rw-r--r--include/highlevel.h6
-rw-r--r--include/sqfs/block.h18
-rw-r--r--include/sqfs/compress.h24
-rw-r--r--include/sqfs/data_reader.h2
-rw-r--r--include/sqfs/data_writer.h4
-rw-r--r--include/sqfs/dir.h24
-rw-r--r--include/sqfs/dir_reader.h6
-rw-r--r--include/sqfs/dir_writer.h6
-rw-r--r--include/sqfs/id_table.h6
-rw-r--r--include/sqfs/inode.h110
-rw-r--r--include/sqfs/io.h8
-rw-r--r--include/sqfs/meta_reader.h10
-rw-r--r--include/sqfs/meta_writer.h4
-rw-r--r--include/sqfs/predef.h10
-rw-r--r--include/sqfs/super.h40
-rw-r--r--include/sqfs/table.h6
-rw-r--r--include/sqfs/xattr.h26
-rw-r--r--include/tar.h14
-rw-r--r--include/util.h4
-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
-rw-r--r--mkfs/mkfs.c6
-rw-r--r--tar/sqfs2tar.c2
-rw-r--r--tar/tar2sqfs.c10
-rw-r--r--unpack/describe.c2
-rw-r--r--unpack/dump_xattrs.c2
-rw-r--r--unpack/fill_files.c4
-rw-r--r--unpack/list_files.c8
-rw-r--r--unpack/restore_fstree.c4
80 files changed, 488 insertions, 478 deletions
diff --git a/difftool/compare_files.c b/difftool/compare_files.c
index aa11f43..51b66bb 100644
--- a/difftool/compare_files.c
+++ b/difftool/compare_files.c
@@ -11,7 +11,7 @@ static unsigned char new_buf[MAX_WINDOW_SIZE];
static int read_blob(const char *prefix, const char *path,
sqfs_data_reader_t *rd, const sqfs_inode_generic_t *inode,
- void *buffer, uint64_t offset, size_t size)
+ void *buffer, sqfs_u64 offset, size_t size)
{
ssize_t ret;
@@ -30,7 +30,7 @@ static int read_blob(const char *prefix, const char *path,
int compare_files(sqfsdiff_t *sd, const sqfs_inode_generic_t *old,
const sqfs_inode_generic_t *new, const char *path)
{
- uint64_t offset, diff, oldsz, newsz;
+ sqfs_u64 offset, diff, oldsz, newsz;
int status = 0, ret;
sqfs_inode_get_file_size(old, &oldsz);
diff --git a/difftool/super.c b/difftool/super.c
index 14609dc..d0e2993 100644
--- a/difftool/super.c
+++ b/difftool/super.c
@@ -7,7 +7,7 @@
#include "sqfsdiff.h"
static const struct {
- uint16_t mask;
+ sqfs_u16 mask;
const char *name;
} sqfs_flags[] = {
{ SQFS_FLAG_UNCOMPRESSED_INODES, "uncompressed inodes" },
@@ -23,9 +23,9 @@ static const struct {
{ SQFS_FLAG_UNCOMPRESSED_IDS, "uncompressed ids" },
};
-static void print_value_difference(const char *name, uint64_t a, uint64_t b)
+static void print_value_difference(const char *name, sqfs_u64 a, sqfs_u64 b)
{
- uint64_t diff;
+ sqfs_u64 diff;
char c;
if (a != b) {
@@ -41,15 +41,15 @@ static void print_value_difference(const char *name, uint64_t a, uint64_t b)
}
}
-static void print_offset_diff(const char *name, uint64_t a, uint64_t b)
+static void print_offset_diff(const char *name, sqfs_u64 a, sqfs_u64 b)
{
if (a != b)
fprintf(stdout, "Location of %s differs\n", name);
}
-static void print_flag_diff(uint16_t a, uint16_t b)
+static void print_flag_diff(sqfs_u16 a, sqfs_u16 b)
{
- uint16_t diff = a ^ b, mask;
+ sqfs_u16 diff = a ^ b, mask;
size_t i;
char c;
diff --git a/include/fstree.h b/include/fstree.h
index 11da854..dbd2cd6 100644
--- a/include/fstree.h
+++ b/include/fstree.h
@@ -44,13 +44,13 @@ struct tree_xattr_t {
size_t max_attr;
/* Offset of the meta data block where the pairs are stored */
- uint64_t block;
+ sqfs_u64 block;
/* Offset into a meta data block where the pairs start */
- uint32_t offset;
+ sqfs_u32 offset;
/* Number of bytes written to disk */
- uint32_t size;
+ sqfs_u32 size;
/* Incremental index within all xattr blocks */
size_t index;
@@ -63,8 +63,8 @@ struct tree_xattr_t {
/* Array with pairs of key-value tupples */
struct {
- uint32_t key_index;
- uint32_t value_index;
+ sqfs_u32 key_index;
+ sqfs_u32 value_index;
} attr[];
};
@@ -108,29 +108,29 @@ struct tree_node_t {
*/
tree_xattr_t *xattr;
- uint32_t uid;
- uint32_t gid;
- uint32_t inode_num;
- uint32_t mod_time;
- uint16_t mode;
- uint16_t pad0[3];
+ sqfs_u32 uid;
+ sqfs_u32 gid;
+ sqfs_u32 inode_num;
+ sqfs_u32 mod_time;
+ sqfs_u16 mode;
+ sqfs_u16 pad0[3];
/* SquashFS inode refernce number. 32 bit offset of the meta data
block start (relative to inode table start), shifted left by 16
and ored with a 13 bit offset into the uncompressed meta data block.
Generated on the fly when writing inodes. */
- uint64_t inode_ref;
+ sqfs_u64 inode_ref;
/* Type specific data. Pointers are into payload area blow. */
union {
dir_info_t dir;
file_info_t file;
char *slink_target;
- uint64_t devno;
+ sqfs_u64 devno;
} data;
- uint8_t payload[];
+ sqfs_u8 payload[];
};
/* Encapsulates a file system tree */
@@ -266,6 +266,6 @@ void tree_node_sort_recursive(tree_node_t *root);
that fits into an unsigned 32 bit value, return its value. Otherwise,
default to 0.
*/
-uint32_t get_source_date_epoch(void);
+sqfs_u32 get_source_date_epoch(void);
#endif /* FSTREE_H */
diff --git a/include/highlevel.h b/include/highlevel.h
index 498cb18..13c85a7 100644
--- a/include/highlevel.h
+++ b/include/highlevel.h
@@ -38,8 +38,8 @@ typedef struct {
size_t sparse_blocks;
size_t frag_count;
size_t frag_dup;
- uint64_t bytes_written;
- uint64_t bytes_read;
+ sqfs_u64 bytes_written;
+ sqfs_u64 bytes_read;
} data_writer_stats_t;
/*
@@ -97,7 +97,7 @@ int sqfs_data_reader_dump(sqfs_data_reader_t *data,
const sqfs_inode_generic_t *inode,
int outfd, size_t block_size, bool allow_sparse);
-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);
void register_stat_hooks(sqfs_data_writer_t *data, data_writer_stats_t *stats);
diff --git a/include/sqfs/block.h b/include/sqfs/block.h
index 2a765e0..84629eb 100644
--- a/include/sqfs/block.h
+++ b/include/sqfs/block.h
@@ -44,17 +44,17 @@ struct sqfs_fragment_t {
/**
* @brief Location of the fragment block on-disk.
*/
- uint64_t start_offset;
+ sqfs_u64 start_offset;
/**
* @brief Size of the fragment block in bytes.
*/
- uint32_t size;
+ sqfs_u32 size;
/**
* @brief Unused. Always initialize this to 0.
*/
- uint32_t pad0;
+ sqfs_u32 pad0;
};
/**
@@ -132,22 +132,22 @@ struct sqfs_block_t {
* @brief Used internally, existing value is ignored and overwritten
* when enqueueing a block.
*/
- uint32_t sequence_number;
+ sqfs_u32 sequence_number;
/**
* @brief Size of the data area.
*/
- uint32_t size;
+ sqfs_u32 size;
/**
* @brief Checksum of the input data.
*/
- uint32_t checksum;
+ sqfs_u32 checksum;
/**
* @brief Data block index within the inode.
*/
- uint32_t index;
+ sqfs_u32 index;
/**
* @brief The squashfs inode related to this block.
@@ -160,12 +160,12 @@ struct sqfs_block_t {
* A combination of @ref E_SQFS_BLK_FLAGS and custom, user
* settable flags.
*/
- uint32_t flags;
+ sqfs_u32 flags;
/**
* @brief Raw data to be processed.
*/
- uint8_t data[];
+ sqfs_u8 data[];
};
#endif /* SQFS_BLOCK_H */
diff --git a/include/sqfs/compress.h b/include/sqfs/compress.h
index 3d99617..76bbd4c 100644
--- a/include/sqfs/compress.h
+++ b/include/sqfs/compress.h
@@ -83,8 +83,8 @@ struct sqfs_compressor_t {
* the output buffer was too small when extracting or that
* the result is larger than the input when compressing.
*/
- ssize_t (*do_block)(sqfs_compressor_t *cmp, const uint8_t *in,
- size_t size, uint8_t *out, size_t outsize);
+ ssize_t (*do_block)(sqfs_compressor_t *cmp, const sqfs_u8 *in,
+ size_t size, sqfs_u8 *out, size_t outsize);
/**
* @brief Create an exact copt of agiven compressor
@@ -105,17 +105,17 @@ struct sqfs_compressor_config_t {
/**
* @brief An @ref E_SQFS_COMPRESSOR identifier
*/
- uint16_t id;
+ sqfs_u16 id;
/**
* @brief A combination of @ref SQFS_COMP_FLAG flags.
*/
- uint16_t flags;
+ sqfs_u16 flags;
/**
* @brief The intended data block size.
*/
- uint32_t block_size;
+ sqfs_u32 block_size;
/**
* @brief Backend specific options for fine tuing.
@@ -130,14 +130,14 @@ struct sqfs_compressor_config_t {
*
* Default is 9, i.e. best compression.
*/
- uint16_t level;
+ sqfs_u16 level;
/**
* @brief Deflate window size. Value between 8 and 15.
*
* Default is 15, i.e. 32k window.
*/
- uint16_t window_size;
+ sqfs_u16 window_size;
} gzip;
/**
@@ -149,7 +149,7 @@ struct sqfs_compressor_config_t {
*
* Default is 15.
*/
- uint16_t level;
+ sqfs_u16 level;
} zstd;
/**
@@ -162,7 +162,7 @@ struct sqfs_compressor_config_t {
* An @ref SQFS_LZO_ALGORITHM value. Default is
* @ref SQFS_LZO1X_999, i.e. best compression.
*/
- uint16_t algorithm;
+ sqfs_u16 algorithm;
/**
* @brief Compression level for @ref SQFS_LZO1X_999.
@@ -173,7 +173,7 @@ struct sqfs_compressor_config_t {
*
* Defaults to 9, i.e. best compression.
*/
- uint16_t level;
+ sqfs_u16 level;
} lzo;
/**
@@ -189,7 +189,7 @@ struct sqfs_compressor_config_t {
* Default is setting this to the same as the
* block size.
*/
- uint32_t dict_size;
+ sqfs_u32 dict_size;
} xz;
} opt;
};
@@ -324,7 +324,7 @@ extern "C" {
*/
SQFS_API 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);
/**
* @brief Check if a specified compressor implementation is available.
diff --git a/include/sqfs/data_reader.h b/include/sqfs/data_reader.h
index 7d0f9d7..f41abeb 100644
--- a/include/sqfs/data_reader.h
+++ b/include/sqfs/data_reader.h
@@ -142,7 +142,7 @@ SQFS_API int sqfs_data_reader_get_block(sqfs_data_reader_t *data,
*/
SQFS_API ssize_t sqfs_data_reader_read(sqfs_data_reader_t *data,
const sqfs_inode_generic_t *inode,
- uint64_t offset, void *buffer,
+ sqfs_u64 offset, void *buffer,
size_t size);
#ifdef __cplusplus
diff --git a/include/sqfs/data_writer.h b/include/sqfs/data_writer.h
index 8cf24ac..a895b7a 100644
--- a/include/sqfs/data_writer.h
+++ b/include/sqfs/data_writer.h
@@ -114,7 +114,7 @@ struct sqfs_block_hooks_t {
* potential padding before and after the end.
*/
void (*notify_blocks_erased)(void *user, size_t count,
- uint64_t bytes);
+ sqfs_u64 bytes);
/**
* @brief Gets called before throwing away a fragment that turned out
@@ -197,7 +197,7 @@ SQFS_API void sqfs_data_writer_destroy(sqfs_data_writer_t *proc);
*/
SQFS_API int sqfs_data_writer_begin_file(sqfs_data_writer_t *proc,
sqfs_inode_generic_t *inode,
- uint32_t flags);
+ sqfs_u32 flags);
/**
* @brief Append data to the current file.
diff --git a/include/sqfs/dir.h b/include/sqfs/dir.h
index 1357521..1a1ce01 100644
--- a/include/sqfs/dir.h
+++ b/include/sqfs/dir.h
@@ -47,19 +47,19 @@ struct sqfs_dir_header_t {
* This value is stored off by one and the total count must not
* exceed 256.
*/
- uint32_t count;
+ sqfs_u32 count;
/**
* @brief The location of the meta data block containing the inodes for
* the entries that follow, relative to the start of the inode
* table.
*/
- uint32_t start_block;
+ sqfs_u32 start_block;
/**
* @brief The inode number of the first entry.
*/
- uint32_t inode_number;
+ sqfs_u32 inode_number;
};
/**
@@ -76,31 +76,31 @@ struct sqfs_dir_entry_t {
* @brief An offset into the uncompressed meta data block containing
* the coresponding inode.
*/
- uint16_t offset;
+ sqfs_u16 offset;
/**
* @brief Signed difference of the inode number from the one
* in the @ref sqfs_dir_header_t.
*/
- int16_t inode_diff;
+ sqfs_s16 inode_diff;
/**
* @brief The @ref E_SQFS_INODE_TYPE value for the inode that this
* entry represents.
*/
- uint16_t type;
+ sqfs_u16 type;
/**
* @brief The size of the entry name
*
* This value is stored off-by-one.
*/
- uint16_t size;
+ sqfs_u16 size;
/**
* @brief The name of the directory entry (no trailing null-byte).
*/
- uint8_t name[];
+ sqfs_u8 name[];
};
/**
@@ -116,27 +116,27 @@ struct sqfs_dir_index_t {
/**
* @brief Linear byte offset into the decompressed directory listing.
*/
- uint32_t index;
+ sqfs_u32 index;
/**
* @brief Location of the meta data block, relative to the directory
* table start.
*/
- uint32_t start_block;
+ sqfs_u32 start_block;
/**
* @brief Size of the name of the first entry after the header.
*
* This value is stored off-by-one.
*/
- uint32_t size;
+ sqfs_u32 size;
/**
* @brief Name of the name of the first entry after the header.
*
* No trailing null-byte.
*/
- uint8_t name[];
+ sqfs_u8 name[];
};
#endif /* SQFS_DIR_H */
diff --git a/include/sqfs/dir_reader.h b/include/sqfs/dir_reader.h
index 57b91e6..8377fdd 100644
--- a/include/sqfs/dir_reader.h
+++ b/include/sqfs/dir_reader.h
@@ -131,17 +131,17 @@ struct sqfs_tree_node_t {
/**
* @brief Resolved 32 bit user ID from the inode
*/
- uint32_t uid;
+ sqfs_u32 uid;
/**
* @brief Resolved 32 bit group ID from the inode
*/
- uint32_t gid;
+ sqfs_u32 gid;
/**
* @brief null-terminated entry name.
*/
- uint8_t name[];
+ sqfs_u8 name[];
};
#ifdef __cplusplus
diff --git a/include/sqfs/dir_writer.h b/include/sqfs/dir_writer.h
index 09869a1..c015871 100644
--- a/include/sqfs/dir_writer.h
+++ b/include/sqfs/dir_writer.h
@@ -114,7 +114,7 @@ SQFS_API int sqfs_dir_writer_begin(sqfs_dir_writer_t *writer);
*/
SQFS_API 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);
/**
@@ -173,7 +173,7 @@ size_t sqfs_dir_writer_get_entry_count(const sqfs_dir_writer_t *writer);
* @return A meta data reference, i.e. bits 16 to 48 contain the block start
* and the lower 16 bit an offset into the uncompressed block.
*/
-SQFS_API uint64_t
+SQFS_API sqfs_u64
sqfs_dir_writer_get_dir_reference(const sqfs_dir_writer_t *writer);
/**
@@ -228,7 +228,7 @@ SQFS_API int sqfs_dir_writer_write_index(const sqfs_dir_writer_t *writer,
*/
SQFS_API 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);
+ sqfs_u32 xattr, sqfs_u32 parent_ino);
#ifdef __cplusplus
}
diff --git a/include/sqfs/id_table.h b/include/sqfs/id_table.h
index c9e6b9b..a280250 100644
--- a/include/sqfs/id_table.h
+++ b/include/sqfs/id_table.h
@@ -74,8 +74,8 @@ SQFS_API void sqfs_id_table_destroy(sqfs_id_table_t *tbl);
*
* @return Zero on success, an @ref E_SQFS_ERROR on failure.
*/
-SQFS_API 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, sqfs_u32 id,
+ sqfs_u16 *out);
/**
* @brief Write an ID table to disk.
@@ -122,7 +122,7 @@ SQFS_API int sqfs_id_table_read(sqfs_id_table_t *tbl, sqfs_file_t *file,
* @return Zero on success, an @ref E_SQFS_ERROR on failure.
*/
SQFS_API int sqfs_id_table_index_to_id(const sqfs_id_table_t *tbl,
- uint16_t index, uint32_t *out);
+ sqfs_u16 index, sqfs_u32 *out);
#ifdef __cplusplus
}
diff --git a/include/sqfs/inode.h b/include/sqfs/inode.h
index a65215b..477d4f2 100644
--- a/include/sqfs/inode.h
+++ b/include/sqfs/inode.h
@@ -62,23 +62,23 @@ struct sqfs_inode_t {
/**
* @brief An @ref E_SQFS_INODE_TYPE value.
*/
- uint16_t type;
+ sqfs_u16 type;
/**
* @brief Mode filed holding permission bits only. The type is derived
* from the type field.
*/
- uint16_t mode;
+ sqfs_u16 mode;
/**
* @brief An index into the ID table where the owner UID is located.
*/
- uint16_t uid_idx;
+ sqfs_u16 uid_idx;
/**
* @brief An index into the ID table where the owner GID is located.
*/
- uint16_t gid_idx;
+ sqfs_u16 gid_idx;
/**
* @brief Last modifcation time.
@@ -87,12 +87,12 @@ struct sqfs_inode_t {
* Jan 1 1970 UTC. This field is unsigned, so it expires in the year
* 2106 (as opposed to 2038).
*/
- uint32_t mod_time;
+ sqfs_u32 mod_time;
/**
* @brief Unique inode number
*/
- uint32_t inode_number;
+ sqfs_u32 inode_number;
};
/**
@@ -105,12 +105,12 @@ struct sqfs_inode_dev_t {
/**
* @brief Number of hard links to this node.
*/
- uint32_t nlink;
+ sqfs_u32 nlink;
/**
* @brief Device number.
*/
- uint32_t devno;
+ sqfs_u32 devno;
};
/**
@@ -123,17 +123,17 @@ struct sqfs_inode_dev_ext_t {
/**
* @brief Number of hard links to this node.
*/
- uint32_t nlink;
+ sqfs_u32 nlink;
/**
* @brief Device number.
*/
- uint32_t devno;
+ sqfs_u32 devno;
/**
* @brief Extended attribute index.
*/
- uint32_t xattr_idx;
+ sqfs_u32 xattr_idx;
};
/**
@@ -146,7 +146,7 @@ struct sqfs_inode_ipc_t {
/**
* @brief Number of hard links to this node.
*/
- uint32_t nlink;
+ sqfs_u32 nlink;
};
/**
@@ -159,12 +159,12 @@ struct sqfs_inode_ipc_ext_t {
/**
* @brief Number of hard links to this node.
*/
- uint32_t nlink;
+ sqfs_u32 nlink;
/**
* @brief Extended attribute index.
*/
- uint32_t xattr_idx;
+ sqfs_u32 xattr_idx;
};
/**
@@ -180,14 +180,14 @@ struct sqfs_inode_slink_t {
/**
* @brief Number of hard links to this node.
*/
- uint32_t nlink;
+ sqfs_u32 nlink;
/**
* @brief Size of the symlink target in bytes
*/
- uint32_t target_size;
+ sqfs_u32 target_size;
- /*uint8_t target[];*/
+ /*sqfs_u8 target[];*/
};
/**
@@ -203,19 +203,19 @@ struct sqfs_inode_slink_ext_t {
/**
* @brief Number of hard links to this node.
*/
- uint32_t nlink;
+ sqfs_u32 nlink;
/**
* @brief Size of the symlink target in bytes
*/
- uint32_t target_size;
+ sqfs_u32 target_size;
- /*uint8_t target[];*/
+ /*sqfs_u8 target[];*/
/**
* @brief Extended attribute index.
*/
- uint32_t xattr_idx;
+ sqfs_u32 xattr_idx;
};
/**
@@ -238,25 +238,25 @@ struct sqfs_inode_file_t {
/**
* @brief Absolute position of the first data block.
*/
- uint32_t blocks_start;
+ sqfs_u32 blocks_start;
/**
* @brief Index into the fragment table or 0xFFFFFFFF if unused.
*/
- uint32_t fragment_index;
+ sqfs_u32 fragment_index;
/**
* @brief Offset into the uncompressed fragment block or 0xFFFFFFFF
* if unused.
*/
- uint32_t fragment_offset;
+ sqfs_u32 fragment_offset;
/**
* @brief Total, uncompressed size of the file in bytes.
*/
- uint32_t file_size;
+ sqfs_u32 file_size;
- /*uint32_t block_sizes[];*/
+ /*sqfs_u32 block_sizes[];*/
};
/**
@@ -270,41 +270,41 @@ struct sqfs_inode_file_ext_t {
/**
* @brief Absolute position of the first data block.
*/
- uint64_t blocks_start;
+ sqfs_u64 blocks_start;
/**
* @brief Total, uncompressed size of the file in bytes.
*/
- uint64_t file_size;
+ sqfs_u64 file_size;
/**
* @brief If the file is sparse, holds the number of bytes not written
* to disk because of the omitted sparse blocks.
*/
- uint64_t sparse;
+ sqfs_u64 sparse;
/**
* @brief Number of hard links to this node.
*/
- uint32_t nlink;
+ sqfs_u32 nlink;
/**
* @brief Index into the fragment table or 0xFFFFFFFF if unused.
*/
- uint32_t fragment_idx;
+ sqfs_u32 fragment_idx;
/**
* @brief Offset into the uncompressed fragment block or 0xFFFFFFFF
* if unused.
*/
- uint32_t fragment_offset;
+ sqfs_u32 fragment_offset;
/**
* @brief Extended attribute index.
*/
- uint32_t xattr_idx;
+ sqfs_u32 xattr_idx;
- /*uint32_t block_sizes[];*/
+ /*sqfs_u32 block_sizes[];*/
};
/**
@@ -317,29 +317,29 @@ struct sqfs_inode_dir_t {
* @brief Offset from the directory table start to the location of the
* meta data block containing the first directory header.
*/
- uint32_t start_block;
+ sqfs_u32 start_block;
/**
* @brief Number of hard links to this node.
*/
- uint32_t nlink;
+ sqfs_u32 nlink;
/**
* @brief Combined size of all directory entries and headers in bytes.
*/
- uint16_t size;
+ sqfs_u16 size;
/**
* @brief Offset into the uncompressed start block where the header can
* be found.
*/
- uint16_t offset;
+ sqfs_u16 offset;
/**
* @brief Inode number of the parent directory containing
* this directory inode.
*/
- uint32_t parent_inode;
+ sqfs_u32 parent_inode;
};
/**
@@ -351,24 +351,24 @@ struct sqfs_inode_dir_ext_t {
/**
* @brief Number of hard links to this node.
*/
- uint32_t nlink;
+ sqfs_u32 nlink;
/**
* @brief Combined size of all directory entries and headers in bytes.
*/
- uint32_t size;
+ sqfs_u32 size;
/**
* @brief Offset from the directory table start to the location of the
* meta data block containing the first directory header.
*/
- uint32_t start_block;
+ sqfs_u32 start_block;
/**
* @brief Inode number of the parent directory containing
* this directory inode.
*/
- uint32_t parent_inode;
+ sqfs_u32 parent_inode;
/**
* @brief Number of directory index entries following the inode
@@ -376,18 +376,18 @@ struct sqfs_inode_dir_ext_t {
* This number is stored off-by one and counts the number of
* @ref sqfs_dir_index_t entries following the inode.
*/
- uint16_t inodex_count;
+ sqfs_u16 inodex_count;
/**
* @brief Offset into the uncompressed start block where the header can
* be found.
*/
- uint16_t offset;
+ sqfs_u16 offset;
/**
* @brief Extended attribute index.
*/
- uint32_t xattr_idx;
+ sqfs_u32 xattr_idx;
};
/**
@@ -423,7 +423,7 @@ struct sqfs_inode_generic_t {
* set if the block is stored uncompressed. If it the size is zero,
* the block is sparse.
*/
- uint32_t *block_sizes;
+ sqfs_u32 *block_sizes;
/**
* @brief For file inodes, stores the number of blocks used.
@@ -449,7 +449,7 @@ struct sqfs_inode_generic_t {
/**
* @brief Holds type specific extra data, such as symlink target.
*/
- uint8_t extra[];
+ sqfs_u8 extra[];
};
#ifdef __cplusplus
@@ -469,7 +469,7 @@ extern "C" {
* an unknown type set.
*/
SQFS_API int sqfs_inode_get_xattr_index(const sqfs_inode_generic_t *inode,
- uint32_t *out);
+ sqfs_u32 *out);
/**
* @brief Convert a basic inode to an extended inode.
@@ -513,7 +513,7 @@ SQFS_API int sqfs_inode_make_basic(sqfs_inode_generic_t *inode);
* not a regular file.
*/
SQFS_API int sqfs_inode_set_file_size(sqfs_inode_generic_t *inode,
- uint64_t size);
+ sqfs_u64 size);
/**
* @brief Update the location of the first data block of a regular file inode.
@@ -530,7 +530,7 @@ SQFS_API int sqfs_inode_set_file_size(sqfs_inode_generic_t *inode,
* not a regular file.
*/
SQFS_API int sqfs_inode_set_file_block_start(sqfs_inode_generic_t *inode,
- uint64_t location);
+ sqfs_u64 location);
/**
* @brief Update the file fragment location of a regular file inode.
@@ -543,7 +543,7 @@ SQFS_API int sqfs_inode_set_file_block_start(sqfs_inode_generic_t *inode,
* not a regular file.
*/
SQFS_API int sqfs_inode_set_frag_location(sqfs_inode_generic_t *inode,
- uint32_t index, uint32_t offset);
+ sqfs_u32 index, sqfs_u32 offset);
/**
* @brief Get the file size of a regular file inode.
@@ -555,7 +555,7 @@ SQFS_API int sqfs_inode_set_frag_location(sqfs_inode_generic_t *inode,
* not a regular file.
*/
SQFS_API int sqfs_inode_get_file_size(const sqfs_inode_generic_t *inode,
- uint64_t *size);
+ sqfs_u64 *size);
/**
* @brief Get the file fragment location of a regular file inode.
@@ -568,7 +568,7 @@ SQFS_API int sqfs_inode_get_file_size(const sqfs_inode_generic_t *inode,
* not a regular file.
*/
SQFS_API int sqfs_inode_get_frag_location(const sqfs_inode_generic_t *inode,
- uint32_t *index, uint32_t *offset);
+ sqfs_u32 *index, sqfs_u32 *offset);
/**
* @brief Get the location of the first data block of a regular file inode.
@@ -580,7 +580,7 @@ SQFS_API int sqfs_inode_get_frag_location(const sqfs_inode_generic_t *inode,
* not a regular file.
*/
SQFS_API int sqfs_inode_get_file_block_start(const sqfs_inode_generic_t *inode,
- uint64_t *location);
+ sqfs_u64 *location);
#ifdef __cplusplus
}
diff --git a/include/sqfs/io.h b/include/sqfs/io.h
index 0f980d6..866389b 100644
--- a/include/sqfs/io.h
+++ b/include/sqfs/io.h
@@ -82,7 +82,7 @@ struct sqfs_file_t {
* that the data structures in libsquashfs that use this return
* directly to the caller.
*/
- int (*read_at)(sqfs_file_t *file, uint64_t offset,
+ int (*read_at)(sqfs_file_t *file, sqfs_u64 offset,
void *buffer, size_t size);
/**
@@ -97,7 +97,7 @@ struct sqfs_file_t {
* that the data structures in libsquashfs that use this return
* directly to the caller.
*/
- int (*write_at)(sqfs_file_t *file, uint64_t offset,
+ int (*write_at)(sqfs_file_t *file, sqfs_u64 offset,
const void *buffer, size_t size);
/**
@@ -105,7 +105,7 @@ struct sqfs_file_t {
*
* @param file A pointer to the file object.
*/
- uint64_t (*get_size)(const sqfs_file_t *file);
+ sqfs_u64 (*get_size)(const sqfs_file_t *file);
/**
* @brief Extend or shrink a file to a specified size.
@@ -117,7 +117,7 @@ struct sqfs_file_t {
* that the data structures in libsquashfs that use this return
* directly to the caller.
*/
- int (*truncate)(sqfs_file_t *file, uint64_t size);
+ int (*truncate)(sqfs_file_t *file, sqfs_u64 size);
};
#ifdef __cplusplus
diff --git a/include/sqfs/meta_reader.h b/include/sqfs/meta_reader.h
index c03c0f6..e720006 100644
--- a/include/sqfs/meta_reader.h
+++ b/include/sqfs/meta_reader.h
@@ -66,8 +66,8 @@ extern "C" {
*/
SQFS_API 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);
/**
* @brief Destroy a meta data reader and free all memory used by it.
@@ -92,7 +92,7 @@ SQFS_API void sqfs_meta_reader_destroy(sqfs_meta_reader_t *m);
*
* @return Zero on success, an @ref E_SQFS_ERROR value on failure.
*/
-SQFS_API int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, uint64_t block_start,
+SQFS_API int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, sqfs_u64 block_start,
size_t offset);
/**
@@ -105,7 +105,7 @@ SQFS_API int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, uint64_t block_start,
* @param offset A byte offset into the uncompressed block.
*/
SQFS_API void sqfs_meta_reader_get_position(const sqfs_meta_reader_t *m,
- uint64_t *block_start,
+ sqfs_u64 *block_start,
size_t *offset);
/**
@@ -181,7 +181,7 @@ SQFS_API int sqfs_meta_reader_read_dir_ent(sqfs_meta_reader_t *m,
SQFS_API
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 **out);
#ifdef __cplusplus
diff --git a/include/sqfs/meta_writer.h b/include/sqfs/meta_writer.h
index 4351f70..8425e94 100644
--- a/include/sqfs/meta_writer.h
+++ b/include/sqfs/meta_writer.h
@@ -147,8 +147,8 @@ SQFS_API int sqfs_meta_writer_append(sqfs_meta_writer_t *m, const void *data,
* starts.
*/
SQFS_API 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);
/**
* @brief Reset all internal state, including the current block start position.
diff --git a/include/sqfs/predef.h b/include/sqfs/predef.h
index ebe99e1..2e835f3 100644
--- a/include/sqfs/predef.h
+++ b/include/sqfs/predef.h
@@ -58,6 +58,16 @@
#endif
#endif
+typedef uint8_t sqfs_u8;
+typedef uint16_t sqfs_u16;
+typedef uint32_t sqfs_u32;
+typedef uint64_t sqfs_u64;
+
+typedef int8_t sqfs_s8;
+typedef int16_t sqfs_s16;
+typedef int32_t sqfs_s32;
+typedef int64_t sqfs_s64;
+
typedef struct sqfs_block_t sqfs_block_t;
typedef struct sqfs_data_writer_t sqfs_data_writer_t;
typedef struct sqfs_compressor_config_t sqfs_compressor_config_t;
diff --git a/include/sqfs/super.h b/include/sqfs/super.h
index aea2394..ea25878 100644
--- a/include/sqfs/super.h
+++ b/include/sqfs/super.h
@@ -45,12 +45,12 @@ struct sqfs_super_t {
/**
* @brief Magic number. Must be set to SQFS_MAGIC.
*/
- uint32_t magic;
+ sqfs_u32 magic;
/**
* @brief Total number of inodes.
*/
- uint32_t inode_count;
+ sqfs_u32 inode_count;
/**
* @brief Last time the filesystem was modified.
@@ -59,55 +59,55 @@ struct sqfs_super_t {
* Jan 1 1970 UTC. This field is unsigned, so it expires in the year
* 2106 (as opposed to 2038).
*/
- uint32_t modification_time;
+ sqfs_u32 modification_time;
/**
* @brief The data block size in bytes.
*
* Must be a power of 2, no less than 4k and not larger than 1M.
*/
- uint32_t block_size;
+ sqfs_u32 block_size;
/**
* @brief The number of fragment blocks in the data area.
*/
- uint32_t fragment_entry_count;
+ sqfs_u32 fragment_entry_count;
/**
* @brief Identifies the compressor that has been used.
*
* Valid identifiers are in the @ref E_SQFS_COMPRESSOR enum.
*/
- uint16_t compression_id;
+ sqfs_u16 compression_id;
/**
* @brief The log2 of the block_size field for sanity checking
*
* Must be no less than 12 and not larger than 20.
*/
- uint16_t block_log;
+ sqfs_u16 block_log;
/**
* @brief A combination of @ref E_SQFS_SUPER_FLAGS flags
*
* Most of the flags that can be set here are informative only.
*/
- uint16_t flags;
+ sqfs_u16 flags;
/**
* @brief The total number of unique user or group IDs.
*/
- uint16_t id_count;
+ sqfs_u16 id_count;
/**
* @brief Must be @ref SQFS_VERSION_MAJOR
*/
- uint16_t version_major;
+ sqfs_u16 version_major;
/**
* @brief Must be @ref SQFS_VERSION_MINOR
*/
- uint16_t version_minor;
+ sqfs_u16 version_minor;
/**
* @brief A reference to the root inode
@@ -116,12 +116,12 @@ struct sqfs_super_t {
* to get the location of the meta data block containing the inode.
* The lower 16 bits hold a byte offset into the uncompressed block.
*/
- uint64_t root_inode_ref;
+ sqfs_u64 root_inode_ref;
/**
* @brief Total size of the file system in bytes, not counting padding
*/
- uint64_t bytes_used;
+ sqfs_u64 bytes_used;
/**
* @brief On-disk location of the ID table
@@ -130,7 +130,7 @@ struct sqfs_super_t {
* (if present) after the export and fragment tables, but before the
* xattr table.
*/
- uint64_t id_table_start;
+ sqfs_u64 id_table_start;
/**
* @brief On-disk location of the extended attribute table (if present)
@@ -141,7 +141,7 @@ struct sqfs_super_t {
* This value must either point to a location after the ID table, or
* it must be set to 0xFFFFFFFF to indicate the table is not present.
*/
- uint64_t xattr_id_table_start;
+ sqfs_u64 xattr_id_table_start;
/**
* @brief On-disk location of the first meta data block containing
@@ -149,7 +149,7 @@ struct sqfs_super_t {
*
* This value must point to a location before the directory table.
*/
- uint64_t inode_table_start;
+ sqfs_u64 inode_table_start;
/**
* @brief On-disk location of the first meta data block containing
@@ -158,7 +158,7 @@ struct sqfs_super_t {
* This value must point to a location after the inode table but
* before the fragment, export, ID and xattr tables.
*/
- uint64_t directory_table_start;
+ sqfs_u64 directory_table_start;
/**
* @brief On-disk location of the fragment table (if present)
@@ -167,7 +167,7 @@ struct sqfs_super_t {
* table, but before the export, ID and xattr tables, or it must be
* set to 0xFFFFFFFF to indicate that the table is not present.
*/
- uint64_t fragment_table_start;
+ sqfs_u64 fragment_table_start;
/**
* @brief On-disk location of the export table (if present)
@@ -177,7 +177,7 @@ struct sqfs_super_t {
* or it must be set to 0xFFFFFFFF to indicate that the table is not
* present.
*/
- uint64_t export_table_start;
+ sqfs_u64 export_table_start;
};
/**
@@ -287,7 +287,7 @@ extern "C" {
* fields does not hold a valid value.
*/
SQFS_API int sqfs_super_init(sqfs_super_t *super, size_t block_size,
- uint32_t mtime,
+ sqfs_u32 mtime,
E_SQFS_COMPRESSOR compressor);
/**
diff --git a/include/sqfs/table.h b/include/sqfs/table.h
index c3c1205..1738789 100644
--- a/include/sqfs/table.h
+++ b/include/sqfs/table.h
@@ -50,7 +50,7 @@ extern "C" {
*/
SQFS_API int sqfs_write_table(sqfs_file_t *file, sqfs_compressor_t *cmp,
const void *data, size_t table_size,
- uint64_t *start);
+ sqfs_u64 *start);
/**
* @brief Read a table from a SquashFS filesystem.
@@ -78,8 +78,8 @@ SQFS_API int sqfs_write_table(sqfs_file_t *file, sqfs_compressor_t *cmp,
* @return Zero on success, an @ref E_SQFS_ERROR value on failure.
*/
SQFS_API 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,
+ size_t table_size, sqfs_u64 location,
+ sqfs_u64 lower_limit, sqfs_u64 upper_limit,
void **out);
#ifdef __cplusplus
diff --git a/include/sqfs/xattr.h b/include/sqfs/xattr.h
index 71e4ffa..e4a3efa 100644
--- a/include/sqfs/xattr.h
+++ b/include/sqfs/xattr.h
@@ -59,13 +59,13 @@ struct sqfs_xattr_entry_t {
* set, the value that follows is not actually a string but a 64 bit
* reference to the location where the value is actually stored.
*/
- uint16_t type;
+ sqfs_u16 type;
/**
* @brief The size in bytes of the suffix string that follows
*/
- uint16_t size;
- uint8_t key[];
+ sqfs_u16 size;
+ sqfs_u8 key[];
};
/**
@@ -80,8 +80,8 @@ struct sqfs_xattr_value_t {
/**
* @brief The exact size in bytes of the value that follows
*/
- uint32_t size;
- uint8_t value[];
+ sqfs_u32 size;
+ sqfs_u8 value[];
};
/**
@@ -102,18 +102,18 @@ struct sqfs_xattr_id_t {
* pair. The lower 16 bits store an offset into the uncompressed meta
* data block.
*/
- uint64_t xattr;
+ sqfs_u64 xattr;
/**
* @brief Number of consecutive key-value pairs
*/
- uint32_t count;
+ sqfs_u32 count;
/**
* @brief Total size of the uncompressed key-value pairs in bytes,
* including data structures used to encode them.
*/
- uint32_t size;
+ sqfs_u32 size;
};
/**
@@ -130,23 +130,23 @@ struct sqfs_xattr_id_table_t {
* @brief The location of the first meta data block holding the key
* value pairs.
*/
- uint64_t xattr_table_start;
+ sqfs_u64 xattr_table_start;
/**
* @brief The total number of descriptors (@ref sqfs_xattr_id_t)
*/
- uint32_t xattr_ids;
+ sqfs_u32 xattr_ids;
/**
* @brief Unused, alwayas set this to 0 when writing!
*/
- uint32_t unused;
+ sqfs_u32 unused;
/**
* @brief Holds the locations of the meta data blocks that contain the
* @ref sqfs_xattr_id_t descriptor array.
*/
- uint64_t locations[];
+ sqfs_u64 locations[];
};
/**
@@ -298,7 +298,7 @@ SQFS_API sqfs_xattr_reader_t *sqfs_xattr_reader_create(sqfs_file_t *file,
*
* @return Zero on success, a negative @ref E_SQFS_ERROR value on failure.
*/
-SQFS_API int sqfs_xattr_reader_get_desc(sqfs_xattr_reader_t *xr, uint32_t idx,
+SQFS_API int sqfs_xattr_reader_get_desc(sqfs_xattr_reader_t *xr, sqfs_u32 idx,
sqfs_xattr_id_t *desc);
/**
diff --git a/include/tar.h b/include/tar.h
index 45457da..d4e72ec 100644
--- a/include/tar.h
+++ b/include/tar.h
@@ -16,8 +16,8 @@
typedef struct sparse_map_t {
struct sparse_map_t *next;
- uint64_t offset;
- uint64_t count;
+ sqfs_u64 offset;
+ sqfs_u64 count;
} sparse_map_t;
typedef struct {
@@ -80,14 +80,14 @@ typedef struct {
char *name;
char *link_target;
sparse_map_t *sparse;
- uint64_t actual_size;
- uint64_t record_size;
+ sqfs_u64 actual_size;
+ sqfs_u64 record_size;
bool unknown_record;
tar_xattr_t *xattr;
/* broken out since struct stat could contain
32 bit values on 32 bit systems. */
- int64_t mtime;
+ sqfs_s64 mtime;
} tar_header_decoded_t;
#define TAR_TYPE_FILE '0'
@@ -122,10 +122,10 @@ int write_tar_header(int fd, const struct stat *sb, const char *name,
unsigned int counter);
/* calcuate and skip the zero padding */
-int skip_padding(int fd, uint64_t size);
+int skip_padding(int fd, sqfs_u64 size);
/* round up to block size and skip the entire entry */
-int skip_entry(int fd, uint64_t size);
+int skip_entry(int fd, sqfs_u64 size);
int read_header(int fd, tar_header_decoded_t *out);
diff --git a/include/util.h b/include/util.h
index ab57c04..61754ed 100644
--- a/include/util.h
+++ b/include/util.h
@@ -92,10 +92,10 @@ int popd(void);
Returns 0 on success. On failure, prints error message to stderr.
*/
SQFS_INTERNAL
-int padd_file(int outfd, uint64_t size, size_t blocksize);
+int padd_file(int outfd, sqfs_u64 size, size_t blocksize);
SQFS_INTERNAL
-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);
/*
Helper for allocating data structures with flexible array members.
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]);
diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c
index 0d50afd..5746c69 100644
--- a/mkfs/mkfs.c
+++ b/mkfs/mkfs.c
@@ -33,7 +33,7 @@ static int pack_files(sqfs_data_writer_t *data, fstree_t *fs,
{
sqfs_inode_generic_t *inode;
size_t max_blk_count;
- uint64_t filesize;
+ sqfs_u64 filesize;
sqfs_file_t *file;
file_info_t *fi;
int ret;
@@ -58,7 +58,7 @@ static int pack_files(sqfs_data_writer_t *data, fstree_t *fs,
if (filesize % fs->block_size)
++max_blk_count;
- inode = alloc_flex(sizeof(*inode), sizeof(uint32_t),
+ inode = alloc_flex(sizeof(*inode), sizeof(sqfs_u32),
max_blk_count);
if (inode == NULL) {
perror("creating file inode");
@@ -66,7 +66,7 @@ static int pack_files(sqfs_data_writer_t *data, fstree_t *fs,
return -1;
}
- inode->block_sizes = (uint32_t *)inode->extra;
+ inode->block_sizes = (sqfs_u32 *)inode->extra;
inode->base.type = SQFS_INODE_FILE;
sqfs_inode_set_file_size(inode, filesize);
sqfs_inode_set_frag_location(inode, 0xFFFFFFFF, 0xFFFFFFFF);
diff --git a/tar/sqfs2tar.c b/tar/sqfs2tar.c
index 1afbedf..10c4d24 100644
--- a/tar/sqfs2tar.c
+++ b/tar/sqfs2tar.c
@@ -189,7 +189,7 @@ static int get_xattrs(const sqfs_inode_generic_t *inode, tar_xattr_t **out)
sqfs_xattr_value_t *value;
sqfs_xattr_entry_t *key;
sqfs_xattr_id_t desc;
- uint32_t index;
+ sqfs_u32 index;
size_t i;
if (xr == NULL)
diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c
index 45b71bb..1175273 100644
--- a/tar/tar2sqfs.c
+++ b/tar/tar2sqfs.c
@@ -223,26 +223,26 @@ fail_arg:
}
static int write_file(tar_header_decoded_t *hdr, file_info_t *fi,
- sqfs_data_writer_t *data, uint64_t filesize)
+ sqfs_data_writer_t *data, sqfs_u64 filesize)
{
const sparse_map_t *it;
sqfs_inode_generic_t *inode;
size_t max_blk_count;
sqfs_file_t *file;
- uint64_t sum;
+ sqfs_u64 sum;
int ret;
max_blk_count = filesize / block_size;
if (filesize % block_size)
++max_blk_count;
- inode = alloc_flex(sizeof(*inode), sizeof(uint32_t), max_blk_count);
+ inode = alloc_flex(sizeof(*inode), sizeof(sqfs_u32), max_blk_count);
if (inode == NULL) {
perror("creating file inode");
return -1;
}
- inode->block_sizes = (uint32_t *)inode->extra;
+ inode->block_sizes = (sqfs_u32 *)inode->extra;
inode->base.type = SQFS_INODE_FILE;
sqfs_inode_set_file_size(inode, filesize);
sqfs_inode_set_frag_location(inode, 0xFFFFFFFF, 0xFFFFFFFF);
@@ -339,7 +339,7 @@ fail_errno:
static int process_tar_ball(fstree_t *fs, sqfs_data_writer_t *data)
{
tar_header_decoded_t hdr;
- uint64_t offset, count;
+ sqfs_u64 offset, count;
sparse_map_t *m;
bool skip;
int ret;
diff --git a/unpack/describe.c b/unpack/describe.c
index 336eb4d..4c35070 100644
--- a/unpack/describe.c
+++ b/unpack/describe.c
@@ -93,7 +93,7 @@ int describe_tree(const sqfs_tree_node_t *root, const char *unpack_root)
case S_IFCHR:
case S_IFBLK: {
char buffer[32];
- uint32_t devno;
+ sqfs_u32 devno;
if (root->inode->base.type == SQFS_INODE_EXT_BDEV ||
root->inode->base.type == SQFS_INODE_EXT_CDEV) {
diff --git a/unpack/dump_xattrs.c b/unpack/dump_xattrs.c
index 13bddfe..b7611a9 100644
--- a/unpack/dump_xattrs.c
+++ b/unpack/dump_xattrs.c
@@ -11,7 +11,7 @@ int dump_xattrs(sqfs_xattr_reader_t *xattr, const sqfs_inode_generic_t *inode)
sqfs_xattr_value_t *value;
sqfs_xattr_entry_t *key;
sqfs_xattr_id_t desc;
- uint32_t index;
+ sqfs_u32 index;
size_t i;
if (xattr == NULL)
diff --git a/unpack/fill_files.c b/unpack/fill_files.c
index 3d1e7b2..12b39fb 100644
--- a/unpack/fill_files.c
+++ b/unpack/fill_files.c
@@ -17,8 +17,8 @@ static size_t block_size = 0;
static int compare_files(const void *l, const void *r)
{
- uint32_t lhs_frag_idx, lhs_frag_off, rhs_frag_idx, rhs_frag_off;
- uint64_t lhs_size, rhs_size, lhs_start, rhs_start;
+ sqfs_u32 lhs_frag_idx, lhs_frag_off, rhs_frag_idx, rhs_frag_off;
+ sqfs_u64 lhs_size, rhs_size, lhs_start, rhs_start;
const struct file_ent *lhs = l, *rhs = r;
sqfs_inode_get_frag_location(lhs->inode, &lhs_frag_idx, &lhs_frag_off);
diff --git a/unpack/list_files.c b/unpack/list_files.c
index ae259bd..0d64010 100644
--- a/unpack/list_files.c
+++ b/unpack/list_files.c
@@ -6,7 +6,7 @@
*/
#include "rdsquashfs.h"
-static void mode_to_str(uint16_t mode, char *p)
+static void mode_to_str(sqfs_u16 mode, char *p)
{
switch (mode & S_IFMT) {
case S_IFDIR: *(p++) = 'd'; break;
@@ -64,7 +64,7 @@ static int count_int_chars(unsigned int i)
return count;
}
-static void print_size(uint64_t size, char *buffer)
+static void print_size(sqfs_u64 size, char *buffer)
{
static const char *suffices = "kMGTPEZY";
int suffix = -1;
@@ -88,7 +88,7 @@ static void print_node_size(const sqfs_tree_node_t *n, char *buffer)
print_size(strlen(n->inode->slink_target), buffer);
break;
case S_IFREG: {
- uint64_t size;
+ sqfs_u64 size;
sqfs_inode_get_file_size(n->inode, &size);
print_size(size, buffer);
break;
@@ -102,7 +102,7 @@ static void print_node_size(const sqfs_tree_node_t *n, char *buffer)
break;
case S_IFBLK:
case S_IFCHR: {
- uint32_t devno;
+ sqfs_u32 devno;
if (n->inode->base.type == SQFS_INODE_EXT_BDEV ||
n->inode->base.type == SQFS_INODE_EXT_CDEV) {
diff --git a/unpack/restore_fstree.c b/unpack/restore_fstree.c
index 5b82de4..1736c47 100644
--- a/unpack/restore_fstree.c
+++ b/unpack/restore_fstree.c
@@ -56,7 +56,7 @@ static int create_node(const sqfs_tree_node_t *n, int flags)
break;
case S_IFBLK:
case S_IFCHR: {
- uint32_t devno;
+ sqfs_u32 devno;
if (n->inode->base.type == SQFS_INODE_EXT_BDEV ||
n->inode->base.type == SQFS_INODE_EXT_CDEV) {
@@ -97,7 +97,7 @@ static int set_xattr(sqfs_xattr_reader_t *xattr, const sqfs_tree_node_t *n)
sqfs_xattr_value_t *value;
sqfs_xattr_entry_t *key;
sqfs_xattr_id_t desc;
- uint32_t index;
+ sqfs_u32 index;
size_t i;
int ret;