summaryrefslogtreecommitdiffstats
path: root/applypatch/freecache.cpp (unfollow)
Commit message (Collapse)AuthorFilesLines
2018-12-17applypatch: Fix comparison of integers of different signs.Tao Bao1-4/+12
bootable/recovery/applypatch/imgpatch.cpp:57:3: error: comparison of integers of different signs: 'unsigned int' and 'int' [-Werror,-Wsign-compare] CHECK_GT(expected_target_length, 0); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bootable/recovery/applypatch/freecache.cpp:145:50: error: comparison of integers of different signs: 'long' and '__fsblkcnt64_t' (aka 'unsigned long') [-Werror,-Wsign-compare] if (sf.f_bsize == 0 || free_space / sf.f_bsize != sf.f_bavail) { ~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~ bootable/recovery/applypatch/freecache.cpp:190:16: error: comparison of integers of different signs: 'int64_t' (aka 'long') and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare] if (free_now >= bytes_needed) { ~~~~~~~~ ^ ~~~~~~~~~~~~ bootable/recovery/applypatch/freecache.cpp:233:18: error: comparison of integers of different signs: 'int64_t' (aka 'long') and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare] if (free_now >= bytes_needed) { ~~~~~~~~ ^ ~~~~~~~~~~~~ Test: `mmma -j bootable/recovery/applypatch` with -Wsign-compare Test: Run recovery_unit_test on marlin. Change-Id: I4aa1fd0f9b7205b9e4e50874fc4bccb62951e7fe
2018-07-13applypatch: Consolidate CacheSizeCheck() and MakeFreeSpaceOnCache().Tao Bao1-6/+6
They are doing exactly the same thing, except for the slightly different error return value (1 vs -1). int CacheSizeCheck(size_t bytes); int MakeFreeSpaceOnCache(size_t bytes_needed); This CL consolidates the two functions and uses bool as its return type. // Checks whether /cache partition has at least 'bytes'-byte free space. Returns true immediately // if so. Otherwise, it will try to free some space by removing older logs, checks again and // returns the checking result. bool CheckAndFreeSpaceOnCache(size_t bytes); Test: Run recovery_unit_test and recovery_component_test on marlin. Change-Id: I94a96934d2b18713f8f39ad5aa96a02c98d87963
2018-07-12applypatch: Fix the return type of FreeSpaceForFile().Tao Bao1-2/+30
Prior to this CL, FreeSpaceForFile() was returning `size_t`, which may overflow on ILP32 when called on a partition with 4GiB+ free space. Additionally, it was returning static_cast<size_t>(-1) on error, but the caller in freecache.cpp didn't check for that. This CL changes its return type to `int64_t`, and moves the function into freecache.cpp since there's no external caller. Test: Run recovery_unit_test on marlin. Test: Code search shows no external user of FreeSpaceForFile(). Change-Id: I00f501a057726e1f1ab69f367c46c77b30f2d774
2018-07-12applypatch: Switch freecache.cpp to libbase logging.Tao Bao1-21/+17
Test: mmma -j bootable/recovery Test: Run recovery_unit_test on marlin. Change-Id: Iaa326cd26211d527071cc64a928e59a96271b111
2018-04-26Rename CacheLocation to Paths.Tao Bao1-4/+4
We have a general need for overriding more paths (e.g. "/tmp"), mostly for testing purpose. Rename CacheLocation to Paths, and use that to manage TEMPORARY_{INSTALL,LOG}_FILE. Test: mmma -j bootable/recovery Test: recovery_component_test Change-Id: Ia8ce8e5695df37ca434f13ac4d3206de1e8e9396
2018-04-13Remove the old log files if cache space is insufficient for OTATianjie Xu1-51/+117
We set the limit of the max stash size to 80% of cache size. But the cache space can still be insufficient for the update if the log files occupy a large chunk of /cache. So remove the old logs for now to make room for the update. Bug: 77528881 Test: unit tests pass Change-Id: Ia8bcb0ace11f8164ad9290bfb360e08e31d282cb
2018-02-28Add a singleton CacheLocation to replace the hard coded locationsTianjie Xu1-1/+2
This class allows us to set the following locations dynamically: cache_temp_source, last_command_file, stash_directory_base. In the updater's main function, we reset the values of these variables to their default locations in /cache; while we can set them to temp files in unit tests or host simulation. Test: unit tests pass Change-Id: I528652650caa41373617ab055d41b1f1a4ec0f87
2018-02-13Skip the cache size check on hostTianjie Xu1-0/+6
When running the update simulation, we choose to skip the cache size check for now due to the lack of "/cache" on host. And in later cls we can implement a cache size estimator to make the check more constrained. Also build the host version of support libraries. Test: unit test pass Change-Id: I3ed93c857fd02f7b62f5baba9130f75c3236e717
2017-11-03Switch to bionic gtest in bootable/recoveryTianjie Xu1-4/+3
We encountered segfaults in Imgdiff host tests due to the failure to reset states of getopt. The problem can be solved by switching to use bionic's gtest where a new process is forked for each test. Also modify the recovery_component_test to make sure it runs in parallel. Changes include: 1. Merge the writes to misc partition into one single test. 2. Change the hard coded location "/cache/saved.file" into a configurable variable. Bug: 67849209 Test: recovery tests pass Change-Id: I165d313f32b83393fb7922c5078636ac40b50bc2
2016-03-03Fix the improper use of LOCAL_WHOLE_STATIC_LIBRARIES.Tao Bao1-1/+1
If two libraries both use LOCAL_WHOLE_STATIC_LIBRARIES and include a same library, there would be linking errors when generating a shared library (or executable) that depends on the two libraries both. Also clean up Android.mk files. Remove the "LOCAL_MODULE_TAGS := eng" line for the updater module. The module will then default to "optional" which won't be built until needed. Change-Id: I3ec227109b8aa744b7568e7f82f575aae3fe0e6f
2016-02-05applypatch: fix memory leaks reported by static analysis.Yabin Cui1-92/+49
Bug: 26906416 Change-Id: I163df5a8f3abda3ba5d4ed81dfc8567054eceb27
2015-11-16DO NOT MERGE recovery: Switch applypatch/ and updater/ to cpp.Tao Bao1-7/+21
Mostly trivial changes to make cpp compiler happy. Change-Id: I69bd1d96fcccf506007f6144faf37e11cfba1270 (cherry picked from commit ba9a42aa7e10686de186636fe9fecbf8c4cc7c19)
2015-07-14recovery: Switch applypatch/ and updater/ to cpp.Tao Bao1-172/+0
Mostly trivial changes to make cpp compiler happy. Change-Id: I1b0481465c67c3bbca35a839d0764190d84ff34e (cherry picked from commit ba9a42aa7e10686de186636fe9fecbf8c4cc7c19)
2015-07-14recovery: Switch applypatch/ and updater/ to cpp.Tao Bao1-172/+0
Mostly trivial changes to make cpp compiler happy. Change-Id: I69bd1d96fcccf506007f6144faf37e11cfba1270
2010-02-18relocate applypatch; add type system and new functions to edifyDoug Zongker1-0/+172
- Move applypatch to this package (from build). - Add a rudimentary type system to edify: instead of just returning a char*, functions now return a Value*, which is a struct that can carry different types of value (currently just STRING and BLOB). Convert all functions to this new scheme. - Change the one-argument form of package_extract_file to return a Value of the new BLOB type. - Add read_file() to load a local file and return a blob, and sha1_check() to test a blob (or string) against a set of possible sha1s. read_file() uses the file-loading code from applypatch so it can read MTD partitions as well. This is the start of better integration between applypatch and the rest of edify. b/2361316 - VZW Issue PP628: Continuous reset to Droid logo: framework-res.apk update failed (CR LIBtt59130) Change-Id: Ibd038074749a4d515de1f115c498c6c589ee91e5