Commit graph

16 commits

Author SHA1 Message Date
Adrien Schildknecht
a26a6bd6f3 libsparse: add a function to retrieve the data blocks
Test: m libsparse

Change-Id: I04bd3912bb4364e591b064ec2aab782cf02f6bd7
2016-11-30 19:16:28 -08:00
Jeremy Compostella
cfd3a03d3d libsparse: move_chunks_up_to_len() does not account skip chunks
I caught the fastboot host command sending more data than the fastboot
device can accept.  Fastboot host command was sending 36 surplus bytes
because of 3 skip chunks that were not taken into account in
move_chunks_up_to_len() algorithm.

Change-Id: I39a4a033c9b15893bd70e553f17116735ee4a48e
2015-04-08 10:10:17 +02:00
Jeremy Compostella
9f0d6bdd66 fastboot/sparse: propagate error code
sparse_file_write_block calls functions that might failed.  This patch
makes sparse_file_write_block catch the error code and propagate it.

Without this patch, fastboot crashes on a segmentation fault if
usb_write() fail during a sparse file image flashing.

Change-Id: If9c0e8dfac8fa380628a2504e13abe8cf7d62726
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
2015-03-01 11:54:02 +01:00
Mark Salyzyn
8116c8c37a libsparse: turn on -Werror
- Deal with some -Wunused issues

Change-Id: I9667d74c0dfbe55c625e65b9d44d7c6f861c455d
2014-05-07 16:56:22 -07:00
Mark Salyzyn
031a748b2a libsparse: deal with build warning messages
- mostly unused parameters, added defs.h to hold __unused macro
- read_all prototype not included, added output_file.h to acquire

Change-Id: Ib7ee00614acab53a6bd6a64f7e26a8c13dbe6297
2014-02-28 08:08:01 -08:00
Colin Cross
f1ec8ac84a libsparse: fix 32 bit overflow when calculating last chunk
last_block * s->block_size can overflow when writing large filesystems,
cast to 64 bits before multiplying.

Change-Id: I3e54097852ce7d0fd271eab53d65e666284898e4
2012-07-23 17:11:29 -07:00
Colin Cross
b43828b247 libsparse: rename symbols that conflict with libext4_utils
Until ext4_utils switches to using libsparse, libext4_utils defines some
of the same symbols as libsparse.  Fastboot links statically against
both of them, and there is no easy way to make the symbols hidden, so
just rename them in libsparse.

Change-Id: Idc2cfe20efe3c3a7fb8233f453a89bbbeb0dcc8b
2012-07-09 22:09:37 -07:00
Colin Cross
317a09e2d4 libsparse: add sparse_file_len
Add sparse_file_len, which will compute the size of data that would
be produced if sparse_file_write was called.  Useful combined with
sparse_file_callback.

Change-Id: I1a156d1071760f5559483954a5c62ffc20298703
2012-07-09 22:09:37 -07:00
Colin Cross
bdc6d39ed6 libsparse: add function to resparse a file and a utility to use it
Add sparse_file_repsarse, which splits chunks in an existing sparse
file such that the maximum size of a chunk, plus a header and footer,
is smaller than the given size.  This will allow multiple smaller
sparse files to result in the same data as a large sparse file.

Change-Id: I177abdb958a23d5afd394ff265c5b0c6a3ff22fa
2012-07-09 22:09:37 -07:00
Colin Cross
1e17b313a6 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
2012-07-09 22:09:37 -07:00
Colin Cross
be8ddcb35a libsparse: merge adjacent blocks of the same type
When a block is added that is adjacent to another block and of the same
type, merge it.  This will be useful for converting regular images to
sparse images, allowing the reader to add a single block at a time and
letting libsparse optimize into larger blocks as it goes.

Does not support merge two blocks that are backed by a data pointer,
only blocks that are backed by a file for now.

Change-Id: I95aa231714cbe01ac194e868c21385806c0bdb97
2012-07-09 22:09:37 -07:00
Colin Cross
a21930b6b0 libsparse: add error reporting functions
Change-Id: I2f21355b6c5339d1d724b4c121ea30d575b2d366
2012-07-09 22:09:37 -07:00
Colin Cross
9e1f17e926 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
2012-07-09 22:09:37 -07:00
Colin Cross
b55dceea98 libsparse: cleanups
Move block loops into sparse.c with iterator helpers in backed_block.c.
Simplify chunk writing by moving skip chunk calls from output_file.c to
sparse.c.
Rename variables to be consistent with new naming.
Remove use of u8, u32, u64.

Change-Id: Ic138ad58bef9f96239266ccee12ee83ea285e7eb
2012-07-09 22:09:37 -07:00
Colin Cross
411619e921 libsparse: remove static variables
Removes static variables in backed_block.c to allow multiple
sparse files to be open at the same time.

Change-Id: I012d8a424c6e21a7352408416adb7c72ee8add21
2012-07-09 22:09:36 -07:00
Colin Cross
28fa5bc347 system/core: move libsparse into system/core
This moves an exact copy of libsparse from
system/extras/ext4_utils/libsparse to system/core/libsparse in
preparation for linking tools in system/core against it.

Change-Id: If664e4fcfd6612844ac745589beb1517e7f9fe58
2012-07-09 22:09:36 -07:00