summaryrefslogtreecommitdiff
path: root/extents.h
AgeCommit message (Collapse)Author
2017-05-03Update Makefile to build shared libraries.Alex Deymo
The Makefile didn't build libbspatch and libbsdiff. This patch includes those libraries in the Makefile and moves the header files exposed by those to an include/bsdiff subdirectory following the Android convention so calling program can include "bsdiff/bspatch.h" avoiding any collision with other libraries. The Android.mk is updated to export the new include path while keeping the old style until calling programs are updated. The new Makefile allows Chromium OS to build the new libraries. Bug: None Test: FEATURES=test emerge-link bsdiff; sudo emerge bsdiff Test: mmma external/bsdiff Change-Id: I2ea9251eb224e9418fe236e4c4c9c5621853f590
2015-10-23bspatch: Re-enable extents support.Alex Deymo
With the implementation of the ExtentsFile, we can now use the FileInterface from bspatch to read and write files. This patch re-enables the extent argument support and adds unittests for the argument parsing. Bug: 24478450 Test: make all test && ./unittest Change-Id: If6837f250df10c24d3ff96f7ad8f0e0d98126788
2015-10-23bspatch: Use a C++ interface for file access.Alex Deymo
This patch moves the exfile.cc implementation to a C++ class with an abstract interface of a file. The implementation of exfile.cc, renamed to extents_file.cc, now uses C++ STL classes and has unittests to test its core functionality. Bug: 24478450 Test: Unittests added. make all test -j5 && ./unittests Change-Id: I8d8f07150ad2ea465c55b5178ca9fbab49185eea
2015-10-12Ran clang-format on all the Chromium OS sources.Alex Deymo
The source code has mixed style guides. The new introduced extents and exfile modules had 4-spaces indents but one tab instead of two indents probably due to bad editor cofiguration. These modules were first introduced as local patches to the .ebuild file but later merged in the git repository. This patch fixes the style guide on all the files added by Chromium OS (all the source files execpt bsdiff.c and bspatch.c). The remaining file should be converted over to the Chromium style guide when parts of it are modified. A .clang-format file is included in this patch to help with that process. Bug: None Test: `make all test && ./unittests`; mm Change-Id: Ief3c557cb35aae67871a5ccde8486af651b84a35
2015-09-23Add gtest unittest framework.Alex Deymo
bsdiff and bspatch are in C and had no unittest. This patch keeps those programs as C code, but adds the C++ gtest unittest framework to allow testing them. Two simple unittests added to validate that the unittests work. BUG=None TEST=make test; ./unittests Change-Id: I8bca6b0c6bc5d5880464183d50a602c9886d20d0
2015-09-23bsdiff: support for lazy reading from extent files in bspatchGilad Arnold
Previously, bspatch used to read the whole content of a file to be patched into a memory buffer, only to copy this data while generating the new file content, which is written to a second buffer. The said read buffer entails an unnecessary memory allocation requirement, especially since it's being indexed almost linearly. This behavior was further extended to support extents (i.e. a list of <offset, length> pairs), which are used extensively during Chrome OS updates. This change introduces extent files, which let users open files through a layer of extents as ordinary glibc file handles. This in turn allows us to easily convert reads from a memory buffer into direct reads from an extent file. Extent files are buffered on the outer level (done for us by glibc), but otherwise use a system file descriptor for the underlying I/O; this proved to be the most efficient combination when applying actual update payloads. Since we are reading a single byte at a time using fread(2), and since the program is decidedly single-threaded, we shift to using _unlocked variants, which appear to reduce the total update time significantly without otherwise affecting memory/CPU footprint. We expect this to cut bspatch's memory usage by nearly one half. Note that in general it is possible to use the same abstraction for implementing direct writing to the target file; however, due to the way we implement delta updates, there is risk that such writes might clobber the read data, and so further support is needed to mark safe operations (i.e. no read/write dependencies) as such. This CL obsoletes the previous ebuild patch for handling extent arguments, which is therefore removed. It also (i) gets rid of logic for special handling of /dev/fd filenames, which is deemed redundant; (ii) fixes the Makefile (via a separate patch) and changes the ebuild to use it, for uniformity; (iii) updates the ebuild to EAPI version 4; (iv) sets -Wall -Werror and fixes eliminates a warning due to bsdiff.c; (v) enhances man pages for both bsdiff/bspatch. BUG=chromium:229705 TEST=Passes update engine unittests with new bspatch TEST=delta payload with BSDIFF operations updates correctly on x86-alex Change-Id: I4bb4afa42e43279048093e7a7f0ef96406b0c9e0 Reviewed-on: https://gerrit.chromium.org/gerrit/49595 Reviewed-by: Gilad Arnold <garnold@chromium.org> Tested-by: Gilad Arnold <garnold@chromium.org> Commit-Queue: Gilad Arnold <garnold@chromium.org>