diff options
author | Colin Cross <ccross@android.com> | 2012-04-25 18:31:39 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2012-07-09 22:09:37 -0700 |
commit | 9e1f17e926fa20255c5f4b4d2f68aa98a964253a (patch) | |
tree | 142907cdec91851c3e162bdfc23638df9a0d675b /libsparse/sparse.c | |
parent | b55dceea986ab24f8b836b5116b389ed619c816e (diff) |
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/sparse.c')
-rw-r--r-- | libsparse/sparse.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libsparse/sparse.c b/libsparse/sparse.c index fce9dbbb6..4ebcf0f8d 100644 --- a/libsparse/sparse.c +++ b/libsparse/sparse.c @@ -70,6 +70,12 @@ int sparse_file_add_file(struct sparse_file *s, len, block); } +int sparse_file_add_fd(struct sparse_file *s, + int fd, int64_t file_offset, unsigned int len, unsigned int block) +{ + return backed_block_add_fd(s->backed_block_list, fd, file_offset, + len, block); +} unsigned int sparse_count_chunks(struct sparse_file *s) { struct backed_block *bb; @@ -122,6 +128,10 @@ int sparse_file_write(struct sparse_file *s, int fd, bool gz, bool sparse, write_file_chunk(out, backed_block_len(bb), backed_block_filename(bb), backed_block_file_offset(bb)); break; + case BACKED_BLOCK_FD: + write_fd_chunk(out, backed_block_len(bb), + backed_block_fd(bb), backed_block_file_offset(bb)); + break; case BACKED_BLOCK_FILL: write_fill_chunk(out, backed_block_len(bb), backed_block_fill_val(bb)); |