summaryrefslogtreecommitdiffstats
path: root/libsparse/include
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2012-04-25 18:31:39 -0700
committerColin Cross <ccross@android.com>2012-07-09 22:09:37 -0700
commit9e1f17e926fa20255c5f4b4d2f68aa98a964253a (patch)
tree142907cdec91851c3e162bdfc23638df9a0d675b /libsparse/include
parentb55dceea986ab24f8b836b5116b389ed619c816e (diff)
downloadsystem_core-9e1f17e926fa20255c5f4b4d2f68aa98a964253a.zip
system_core-9e1f17e926fa20255c5f4b4d2f68aa98a964253a.tar.gz
system_core-9e1f17e926fa20255c5f4b4d2f68aa98a964253a.tar.bz2
libsparse: add support for including fds
Add sparse_file_add_fd to include all or part of the contents of an fd in the output file. Will be useful for re-sparsing files where fd will point to the input sparse file. Change-Id: I5d4ab07fb37231e8e9c1912f62a2968c8b0a00ef
Diffstat (limited to 'libsparse/include')
-rw-r--r--libsparse/include/sparse/sparse.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/libsparse/include/sparse/sparse.h b/libsparse/include/sparse/sparse.h
index db06884..6484333 100644
--- a/libsparse/include/sparse/sparse.h
+++ b/libsparse/include/sparse/sparse.h
@@ -111,6 +111,32 @@ int sparse_file_add_file(struct sparse_file *s,
unsigned int block);
/**
+ * sparse_file_add_file - associate a chunk of a file with a sparse file
+ *
+ * @s - sparse file cookie
+ * @filename - filename of the file to be copied
+ * @file_offset - offset into the copied file
+ * @len - length of the copied block
+ * @block - offset in blocks into the sparse file to place the file chunk
+ *
+ * Associates a chunk of an existing fd with a sparse file cookie.
+ * The region [block * block_size : block * block_size + len) must not already
+ * be used in the sparse file. If len is not a multiple of the block size the
+ * data will be padded with zeros.
+ *
+ * Allows adding large amounts of data to a sparse file without needing to keep
+ * it all mapped. File size is limited by available virtual address space,
+ * exceptionally large files may need to be added in multiple chunks.
+ *
+ * The fd must remain open until the sparse file is closed or the fd block is
+ * removed from the sparse file.
+ *
+ * Returns 0 on success, negative errno on error.
+ */
+int sparse_file_add_fd(struct sparse_file *s,
+ int fd, int64_t file_offset, unsigned int len, unsigned int block);
+
+/**
* sparse_file_write - write a sparse file to a file
*
* @s - sparse file cookie