From 40232f4bd4d7e8e001f7d1e8f120606f59b2c147 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 27 Sep 2019 18:15:40 +0200 Subject: Cleanup: replace fixed with data types with typedefs This is a fully automated search and replace, i.e. I ran this: git grep -l uint8_t | xargs sed -i 's/uint8_t/sqfs_u8/g' git grep -l uint16_t | xargs sed -i 's/uint16_t/sqfs_u16/g' git grep -l uint32_t | xargs sed -i 's/uint32_t/sqfs_u32/g' git grep -l uint64_t | xargs sed -i 's/uint64_t/sqfs_u64/g' git grep -l int8_t | xargs sed -i 's/int8_t/sqfs_s8/g' git grep -l int16_t | xargs sed -i 's/int16_t/sqfs_s16/g' git grep -l int32_t | xargs sed -i 's/int32_t/sqfs_s32/g' git grep -l int64_t | xargs sed -i 's/int64_t/sqfs_s64/g' and than added the appropriate definitions to sqfs/predef.h The whole point being better compatibillity with platforms that may not have an stdint.h with the propper definitions. Signed-off-by: David Oberhollenzer --- include/sqfs/block.h | 18 ++++---- include/sqfs/compress.h | 24 +++++----- include/sqfs/data_reader.h | 2 +- include/sqfs/data_writer.h | 4 +- include/sqfs/dir.h | 24 +++++----- include/sqfs/dir_reader.h | 6 +-- include/sqfs/dir_writer.h | 6 +-- include/sqfs/id_table.h | 6 +-- include/sqfs/inode.h | 110 ++++++++++++++++++++++----------------------- include/sqfs/io.h | 8 ++-- include/sqfs/meta_reader.h | 10 ++--- include/sqfs/meta_writer.h | 4 +- include/sqfs/predef.h | 10 +++++ include/sqfs/super.h | 40 ++++++++--------- include/sqfs/table.h | 6 +-- include/sqfs/xattr.h | 26 +++++------ 16 files changed, 157 insertions(+), 147 deletions(-) (limited to 'include/sqfs') 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); /** -- cgit v1.2.3