summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/sqfs/block_processor.h65
-rw-r--r--include/sqfs/block_writer.h43
-rw-r--r--include/sqfs/predef.h2
3 files changed, 110 insertions, 0 deletions
diff --git a/include/sqfs/block_processor.h b/include/sqfs/block_processor.h
index 68d1c23..fb62678 100644
--- a/include/sqfs/block_processor.h
+++ b/include/sqfs/block_processor.h
@@ -43,6 +43,59 @@
* and finally writing it to disk.
*/
+/**
+ * @struct sqfs_block_processor_stats_t
+ *
+ * @brief Used to store runtime statistics about the @ref sqf_block_processor_t.
+ */
+struct sqfs_block_processor_stats_t {
+ /**
+ * @brief Holds the size of the structure.
+ *
+ * If a later version of libsquashfs expands this structure, the value
+ * of this field can be used to check at runtime whether the newer
+ * fields are avaialable or not.
+ */
+ size_t size;
+
+ /**
+ * @brief Total number of bytes fed into the front end API.
+ */
+ sqfs_u64 input_bytes_read;
+
+ /**
+ * @brief Total number of data blocks produced.
+ */
+ sqfs_u64 data_block_count;
+
+ /**
+ * @brief Total number of fragment blocks produced.
+ */
+ sqfs_u64 frag_block_count;
+
+ /**
+ * @brief Total number of sparse blocks encountered.
+ */
+ sqfs_u64 sparse_block_count;
+
+ /**
+ * @brief Total number of tail-end fragments produced.
+ *
+ * This number also includes the fragments that have later been
+ * eliminated by deduplication.
+ */
+ sqfs_u64 total_frag_count;
+
+ /**
+ * @brief Total number of tail-end fragments actually stored in
+ * fragment blocks.
+ *
+ * This number does not include the fragments that have been
+ * eliminated by deduplication.
+ */
+ sqfs_u64 actual_frag_count;
+};
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -181,6 +234,18 @@ SQFS_API
int sqfs_block_processor_set_hooks(sqfs_block_processor_t *proc, void *user_ptr,
const sqfs_block_hooks_t *hooks);
+/**
+ * @brief Get accumulated runtime statistics from a block processor
+ *
+ * @memberof sqfs_block_processor_t
+ *
+ * @param proc A pointer to a data writer object.
+ *
+ * @return A pointer to a @ref sqfs_block_processor_stats_t structure.
+ */
+SQFS_API const sqfs_block_processor_stats_t
+*sqfs_block_processor_get_stats(const sqfs_block_processor_t *proc);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/sqfs/block_writer.h b/include/sqfs/block_writer.h
index b4d804c..421f8bd 100644
--- a/include/sqfs/block_writer.h
+++ b/include/sqfs/block_writer.h
@@ -140,6 +140,46 @@ struct sqfs_block_hooks_t {
void (*prepare_padding)(void *user, sqfs_u8 *block, size_t count);
};
+/**
+ * @struct sqfs_block_writer_stats_t
+ *
+ * @brief Collects run time statistics of the @ref sqfs_block_writer_t
+ */
+struct sqfs_block_writer_stats_t {
+ /**
+ * @brief Holds the size of the structure.
+ *
+ * If a later version of libsquashfs expands this structure, the value
+ * of this field can be used to check at runtime whether the newer
+ * fields are avaialable or not.
+ */
+ size_t size;
+
+ /**
+ * @brief Total number of bytes submitted, including blocks that were
+ * removed by deduplication and not counting any padding.
+ */
+ sqfs_u64 bytes_submitted;
+
+ /**
+ * @brief Actual number of bytes written to disk, excluding deduplicated
+ * blocks and including padding.
+ */
+ sqfs_u64 bytes_written;
+
+ /**
+ * @brief Total number of submitted blocks, including ones later
+ * removed by deduplication.
+ */
+ sqfs_u64 blocks_submitted;
+
+ /**
+ * @brief Total number of blocks actually written, excluding
+ * deduplicated blocks.
+ */
+ sqfs_u64 blocks_written;
+};
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -158,6 +198,9 @@ SQFS_API int sqfs_block_writer_write(sqfs_block_writer_t *wr,
sqfs_block_t *block,
sqfs_u64 *location);
+SQFS_API const sqfs_block_writer_stats_t
+*sqfs_block_writer_get_stats(const sqfs_block_writer_t *wr);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/sqfs/predef.h b/include/sqfs/predef.h
index 40d0e5d..87d7788 100644
--- a/include/sqfs/predef.h
+++ b/include/sqfs/predef.h
@@ -84,6 +84,8 @@ typedef struct sqfs_block_hooks_t sqfs_block_hooks_t;
typedef struct sqfs_xattr_writer_t sqfs_xattr_writer_t;
typedef struct sqfs_frag_table_t sqfs_frag_table_t;
typedef struct sqfs_block_writer_t sqfs_block_writer_t;
+typedef struct sqfs_block_writer_stats_t sqfs_block_writer_stats_t;
+typedef struct sqfs_block_processor_stats_t sqfs_block_processor_stats_t;
typedef struct sqfs_fragment_t sqfs_fragment_t;
typedef struct sqfs_dir_header_t sqfs_dir_header_t;