summaryrefslogtreecommitdiff
path: root/libsparse/sparse_read.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge changes from topic "sparse-file-read-enum"Treehugger Robot2022-01-281-13/+83
|\ | | | | | | | | | | * changes: libsparse: Add "hole" mode to sparse_file_read libsparse: Split off most of sparse_file_read_normal into a helper function
| * libsparse: Add "hole" mode to sparse_file_readSean Anderson2022-01-271-7/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds support for filesystem-level sparse files. These files have holes which are not stored in the filesystem and when read are full of zeros. While these zeros may be significant in some types of files, other types of files may not care about the contents of holes. For example, most filesystem creation tools write to all the blocks they care about. Those blocks not written to will remain holes, and can be safely represented by "don't care" chunks. Using "don't care" chunks instead of fill chunks can result in a substantial reduction of the time it takes to program a sparse image. To accomplish this, we extend the existing "sparse" boolean parameter to be an enum of mode types. This enum represents the strategy we take when reading in a file. For the most part the implementation is straightforward. We use lseek to determine where the holes in the file are, and then use do_sparse_file_read_normal to create chunks for the data section. Note that every file has an implicit hole at its end. Change-Id: I0cfbf08886fca9a91cb753ec8734c84fcbe52c9f
| * libsparse: Split off most of sparse_file_read_normal into a helper functionSean Anderson2021-12-301-7/+15
| | | | | | | | | | | | | | This carves out the core of sparse_file_read_normal and splits it off so it can be reused in the next patch. No functional change intended. Change-Id: Id00491fd7e5bb6fa28c517a0bb32b8b506539d4d
* | Add checking for sparse file formatKeith Mok2022-01-141-26/+76
|/ | | | | | | | | | | | | | | Sparse file can come from an untrusted source. Need more checking to ensure that it is not a malformed file and would not cause any OOB read access. Update fuzz test for decoding also. Test: adb reboot fastboot fuzzy_fastboot --gtest_filter=Fuzz.Sparse* fuzzy_fastboot --gtest_filter=Conformance.Sparse* sparse_fuzzer Bug: 212705418 Change-Id: I7622df307bb00e59faaba8bb2c67cb474cffed8e
* [libsparse] Modernize codebase by replacing NULL with nullptrYi Kong2018-07-231-14/+14
| | | | | | | | Fixes -Wzero-as-null-pointer-constant warning. Test: m Bug: 68236239 Change-Id: I43dae734817cae7a260ffc7afcd85fbd4451eddf
* libsparse: Add .clang-format and reformat to google3 styleJerry Zhang2018-06-131-500/+478
| | | | | | Bug: 78793464 Test: compiles Change-Id: I8e44ba77195a12fc2bac7d4276bbc4aa95149b31
* libsparse: Add method to create sparse file from bufferJerry Zhang2018-06-071-38/+154
| | | | | | | | | | | | Refactor elements of sparse file parsing that depend on an fd into SparseFileSource class, then create implementations using both fd and buffer. Add sparse_file_read_buf which reads the given buffer into a sparse file cookie without copying. Test: flash system with sparse images Bug: 78793464 Change-Id: Ice6c8e1ff075d6867e070f80fcf5aa4f530a1b95
* Merge "<stdbool.h> not necessary in C++."Treehugger Robot2017-10-171-1/+0
|\
| * <stdbool.h> not necessary in C++.Elliott Hughes2017-10-171-1/+0
| | | | | | | | | | | | | | Bug: N/A Test: builds Change-Id: I1f32b202e353414e74ace87a7d5b495b5deb5f99 Merged-In: I1f32b202e353414e74ace87a7d5b495b5deb5f99
* | libsparse: fix building on linux host.Xiaolei Yu2017-10-111-0/+1
|/ | | | | | | | memset is declared in <string.h> Test: builds and works on host Change-Id: I224a01c78ee1d0c2f8d5e86eef10c84c8960cbc0
* libsparse: Fix verbose_error string usageChris Fries2017-04-181-0/+483
Switch vnsprintf to StringPrintf to avoid off-by-one, and switch sparse_read.c to cpp. Test: fastboot flash normal image with smaller sparse limit Change-Id: Ia399b167625deb271bfd0ee3273071306d71c4d4