summaryrefslogtreecommitdiffstats
path: root/libsparse/include
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2012-05-21 16:35:45 -0700
committerColin Cross <ccross@android.com>2012-07-09 22:09:37 -0700
commit1e17b313a6257b7b5081e178e81435c09d60378e (patch)
treeaea5379ca96c99ec14f1c5c8dc202b7b5b36ca47 /libsparse/include
parentb4cd267db30c152245e6308598e0066d87c5c55d (diff)
downloadsystem_core-1e17b313a6257b7b5081e178e81435c09d60378e.zip
system_core-1e17b313a6257b7b5081e178e81435c09d60378e.tar.gz
system_core-1e17b313a6257b7b5081e178e81435c09d60378e.tar.bz2
libsparse: add callback output file type
Add a new output file subclass that will call a callback for each block as it is written. Will be used to measure the space used by each sparse block to allow resparsing files. Also add sparse_file_callback, which will write out a sparse file by calling the provided write function. Change-Id: I18707bd9c357b68da319cc07982e93d1c2b2bee2
Diffstat (limited to 'libsparse/include')
-rw-r--r--libsparse/include/sparse/sparse.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/libsparse/include/sparse/sparse.h b/libsparse/include/sparse/sparse.h
index ae54955..b215227 100644
--- a/libsparse/include/sparse/sparse.h
+++ b/libsparse/include/sparse/sparse.h
@@ -158,6 +158,27 @@ int sparse_file_write(struct sparse_file *s, int fd, bool gz, bool sparse,
bool crc);
/**
+ * sparse_file_callback - call a callback for 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
+ *
+ * Writes a sparse file by calling a callback function. If sparse is true, the
+ * file will be written in the Android sparse file format. If crc is true, the
+ * crc of the expanded data will be calculated and appended in a crc chunk.
+ * The callback 'write' will be called with data and length for each data,
+ * and with data==NULL to skip over a region (only used for non-sparse format).
+ * The callback should return negative on error, 0 on success.
+ *
+ * Returns 0 on success, negative errno on error.
+ */
+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_read - read a file into a sparse file cookie
*
* @s - sparse file cookie