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
diff --git a/libsparse/backed_block.h b/libsparse/backed_block.h
index 3166505..ca2ad1d 100644
--- a/libsparse/backed_block.h
+++ b/libsparse/backed_block.h
@@ -25,6 +25,7 @@
 enum backed_block_type {
 	BACKED_BLOCK_DATA,
 	BACKED_BLOCK_FILE,
+	BACKED_BLOCK_FD,
 	BACKED_BLOCK_FILL,
 };
 
@@ -34,6 +35,8 @@
 		unsigned int len, unsigned int block);
 int backed_block_add_file(struct backed_block_list *bbl, const char *filename,
 		int64_t offset, unsigned int len, unsigned int block);
+int backed_block_add_fd(struct backed_block_list *bbl, int fd,
+		int64_t offset, unsigned int len, unsigned int block);
 
 struct backed_block *backed_block_iter_new(struct backed_block_list *bbl);
 struct backed_block *backed_block_iter_next(struct backed_block *bb);
@@ -41,6 +44,7 @@
 unsigned int backed_block_block(struct backed_block *bb);
 void *backed_block_data(struct backed_block *bb);
 const char *backed_block_filename(struct backed_block *bb);
+int backed_block_fd(struct backed_block *bb);
 int64_t backed_block_file_offset(struct backed_block *bb);
 uint32_t backed_block_fill_val(struct backed_block *bb);
 enum backed_block_type backed_block_type(struct backed_block *bb);