summaryrefslogtreecommitdiff
path: root/include/sqfs/inode.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-23 03:44:33 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-23 04:02:49 +0100
commitc924d87a4cbbeb93825f34f997add1ca4573a368 (patch)
treea2497b2954e0f6538cfa669062ab409f16518fc7 /include/sqfs/inode.h
parent7350bebc4ceee0bf065e73f392edb725f8d0cd14 (diff)
Unify the payload counters in the sqfs_inode_generic_t
Instead of having seperate counters for blocks, dir index bytes and having to fiddle out the link target size, simply use a single value that stores the number of payload bytes used. A seperate "payload bytes available" is used for dynamically growing inodes during processing. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/sqfs/inode.h')
-rw-r--r--include/sqfs/inode.h29
1 files changed, 24 insertions, 5 deletions
diff --git a/include/sqfs/inode.h b/include/sqfs/inode.h
index 17df022..0323bef 100644
--- a/include/sqfs/inode.h
+++ b/include/sqfs/inode.h
@@ -483,15 +483,21 @@ struct sqfs_inode_generic_t {
sqfs_inode_t base;
/**
- * @brief For file inodes, stores the number of blocks used.
+ * @brief Maximum number of available data bytes in the payload.
+ *
+ * This is used for dynamically growing an inode. The actual number
+ * of used payload bytes is stored in @ref payload_bytes_used.
*/
- size_t num_file_blocks;
+ sqfs_u32 payload_bytes_available;
/**
- * @brief For extended directory inodes, stores the number of payload
- * bytes following for the directory index.
+ * @brief Number of used data bytes in the payload.
+ *
+ * For file inodes, stores the number of blocks used. For extended
+ * directory inodes, stores the number of payload bytes following
+ * for the directory index.
*/
- size_t num_dir_idx_bytes;
+ sqfs_u32 payload_bytes_used;
/**
* @brief Type specific inode data.
@@ -525,6 +531,19 @@ extern "C" {
#endif
/**
+ * @brief Get the number of file blocks in a regular file inode.
+ *
+ * @param inode A pointer to an inode.
+ *
+ * @return The number of blocks.
+ */
+static SQFS_INLINE
+size_t sqfs_inode_get_file_block_count(const sqfs_inode_generic_t *inode)
+{
+ return inode->payload_bytes_used / sizeof(sqfs_u32);
+}
+
+/**
* @brief Create a deep copy of a generic inode.
*
* The @ref sqfs_inode_generic_t structure contains inlined fields that have a