summaryrefslogtreecommitdiff
path: root/libsparse/include/sparse/sparse.h
diff options
context:
space:
mode:
authorAdrien Schildknecht <adriens@google.com>2016-11-30 11:49:47 -0800
committerAdrien Schildknecht <adriens@google.com>2016-11-30 19:16:28 -0800
commita26a6bd6f36d29cdc959f746b495f79f74c7fad7 (patch)
treec7fc492b1924ca83bb3839cd5cc92404f0ca2282 /libsparse/include/sparse/sparse.h
parent59826ddee5462d1be93176e2dee660c46e413e52 (diff)
libsparse: add a function to retrieve the data blocks
Test: m libsparse Change-Id: I04bd3912bb4364e591b064ec2aab782cf02f6bd7
Diffstat (limited to 'libsparse/include/sparse/sparse.h')
-rw-r--r--libsparse/include/sparse/sparse.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/libsparse/include/sparse/sparse.h b/libsparse/include/sparse/sparse.h
index 42d4adb87..356f65fd0 100644
--- a/libsparse/include/sparse/sparse.h
+++ b/libsparse/include/sparse/sparse.h
@@ -176,6 +176,13 @@ int sparse_file_write(struct sparse_file *s, int fd, bool gz, bool sparse,
int64_t sparse_file_len(struct sparse_file *s, bool sparse, bool crc);
/**
+ * sparse_file_block_size
+ *
+ * @s - sparse file cookie
+ */
+unsigned int sparse_file_block_size(struct sparse_file *s);
+
+/**
* sparse_file_callback - call a callback for blocks in sparse file
*
* @s - sparse file cookie
@@ -197,6 +204,24 @@ int sparse_file_callback(struct sparse_file *s, bool sparse, bool crc,
int (*write)(void *priv, const void *data, int len), void *priv);
/**
+ * sparse_file_foreach_chunk - call a callback for data blocks in sparse file
+ *
+ * @s - sparse file cookie
+ * @sparse - write in the Android sparse file format
+ * @crc - append a crc chunk
+ * @write - function to call for each block
+ * @priv - value that will be passed as the first argument to write
+ *
+ * The function has the same behavior as 'sparse_file_callback', except it only
+ * iterates on blocks that contain data.
+ *
+ * Returns 0 on success, negative errno on error.
+ */
+int sparse_file_foreach_chunk(struct sparse_file *s, bool sparse, bool crc,
+ int (*write)(void *priv, const void *data, int len, unsigned int block,
+ unsigned int nr_blocks),
+ void *priv);
+/**
* sparse_file_read - read a file into a sparse file cookie
*
* @s - sparse file cookie