summaryrefslogtreecommitdiffstats
path: root/otautil/sysutil.cpp (unfollow)
Commit message (Collapse)AuthorFilesLines
2018-07-17Fix the arguments passed to getopt_long(3).Tao Bao1-0/+9
The getopt_long(3) implementation in Android (upstream freebsd) expects a null-terminated array while parsing long options with required args. if (long_options[match].has_arg == required_argument) { optarg = nargv[optind++]; } ... if (long_options[match].has_arg == required_argument && optarg == NULL) { return (BADARG); } This seems to make sense in practice, as getopt(3) takes the first two arguments of argc and argv that are "as passed to the main() function on program invocation", and both of C and C++ spec say "the value of argv[argc] shall be 0". Prior to the CL, we may run into undefined behavior on malformed input command line (e.g. missing arg for an option that requires one). This CL fixes the issue by always appending a nullptr to the argument list (but without counting that into argc). Test: Build and boot into recovery with commands. Change-Id: Ic6c37548f4db2f30aeabd40f387ca916eeca5392
2018-05-04Move reboot() from common.h into otautil/sysutil.h.Tao Bao1-0/+10
This breaks the dependency on common.h (which belongs to recovery/librecovery) from librecovery_ui. reboot() is now owned by libotautil, which is expected to be a leaf node to be depended on. With the change, recovery and updater also share the same reboot() code now. Test: mmma -j bootable/recovery Change-Id: I1cc5d702cfe49302048db33d31c9c87ddc97ac71
2018-05-04otautil: Rename dir/sys/thermal utils.Tao Bao1-1/+1
Test: mmma -j bootable/recovery Change-Id: I32ab98549e91f993364306e4a88dc654221b3869
2017-10-11otautil: #include <errno.h> for TEMP_FAILURE_RETRY.Tao Bao1-0/+1
Test: mmma bootable/recovery Change-Id: I5959303528c6f704f10ce153f6fcb2054ce35b1e
2017-10-10otautil: Fix mac build.Tao Bao1-3/+3
bootable/recovery/otautil/SysUtil.cpp:103:19: error: use of undeclared identifier 'mmap64'; did you mean 'mmap'? void* reserve = mmap64(nullptr, blocks * blksize, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); ^~~~~~ Test: mmma bootable/recovery Change-Id: I22d7dc4d994069201e5a633cec21421e2c4182fa
2017-10-03otautil: Export headers.Tao Bao1-1/+1
Test: mmma bootable/recovery Change-Id: Ic01b68e2a394d578fc9fc09da2dabe9061b98122
2017-05-02Move sysMapFile and sysReleaseMap into MemMapping class.Tao Bao1-68/+58
Test: recovery_component_test Test: recovery_unit_test Test: Apply an OTA on angler. Change-Id: I7170f03e4ce1fe06184ca1d7bcce0a695f33ac4d
2016-11-08otautil: Clean up obsolete includes.Tao Bao1-6/+0
external/zlib and external/safe-iop/include were used by Zip.c, which became obsolete after [1]. Removing - <assert.h>: we no longer call assert(3); - <limits.h>: we no longer use PATH_MAX; - <stdio.h>: we don't need FILE anymore; - <stdlib.h>: no more malloc(3)/calloc(3); - <unistd.h>: was once needed for lseek(2); - <string.h>: no more memset(3). Adding - <stdint.h> for SIZE_MAX. [1] commit 8cf5c8f60f51049278b08ae4cbc31df397b651fd: "Replace minzip with libziparchive". Test: `mmma bootable/recovery` Change-Id: I349e909ba83d0f6ade5f92856ce3934f29fdca6c (cherry picked from commit 14b61e7b961bb49787ec9ec8f8f7a95c8d12b71c)
2016-11-08otautil: Clean up obsolete includes.Tao Bao1-6/+1
external/zlib and external/safe-iop/include were used by Zip.c, which became obsolete after [1]. Removing - <assert.h>: we no longer call assert(3); - <limits.h>: we no longer use PATH_MAX; - <stdio.h>: we don't need FILE anymore; - <stdlib.h>: no more malloc(3)/calloc(3); - <unistd.h>: was once needed for lseek(2); - <string.h>: no more memset(3). Adding - <stdint.h> for SIZE_MAX. [1] commit 8cf5c8f60f51049278b08ae4cbc31df397b651fd: "Replace minzip with libziparchive". Test: `mmma bootable/recovery` Change-Id: I349e909ba83d0f6ade5f92856ce3934f29fdca6c
2016-11-08otautil: Clean up SysUtil.cpp.Tao Bao1-173/+178
Add unit testcases for sysMapFile(). Test: recovery_unit_test passes. Test: Build and use the new recovery image to sideload a package. Test: Build and use the new recovery image to install an update. Change-Id: I77d8f1ea151ab513865d992c256ba93a1fcb51a4 (cherry picked from commit c3292f3fcbb3cd608cc19b7459751fa5bb64ab84)
2016-11-07otautil: Clean up SysUtil.cpp.Tao Bao1-167/+172
Add unit testcases for sysMapFile(). Test: recovery_unit_test passes. Test: Build and use the new recovery image to sideload a package. Test: Build and use the new recovery image to install an update. Change-Id: I77d8f1ea151ab513865d992c256ba93a1fcb51a4
2016-10-18Replace minzip with libziparchiveTianjie Xu1-0/+0
Clean up the duplicated codes that handle the zip files in bootable/recovery; and rename the library of the remaining utility functions to libotautil. Test: Update package installed successfully on angler. Bug: 19472796 Change-Id: Iea8962fcf3004473cb0322b6bb3a9ea3ca7f679e
2016-09-01Switch recovery to libbase loggingTianjie Xu1-32/+32
Clean up the recovery image and switch to libbase logging. Bug: 28191554 Change-Id: Icd999c3cc832f0639f204b5c36cea8afe303ad35 (cherry picked from commit 747781433fb01f745529c7e9dd97c5599070ad0d)
2016-09-01Switch recovery to libbase loggingTianjie Xu1-212/+0
Clean up the recovery image and switch to libbase logging. Bug: 28191554 Change-Id: Icd999c3cc832f0639f204b5c36cea8afe303ad35 Merged-In: Icd999c3cc832f0639f204b5c36cea8afe303ad35
2016-09-01Switch recovery to libbase loggingTianjie Xu1-213/+0
Clean up the recovery image and switch to libbase logging. Bug: 28191554 Change-Id: Icd999c3cc832f0639f204b5c36cea8afe303ad35
2016-02-23Fix integer overflows in recovery procedure.Yabin Cui1-15/+54
Bug: 26960931 Change-Id: Ieae45caccfb4728fcf514f0d920976585d8e6caf (cherry picked from commit 4f2df162c6ab4a71ca86e4b38735b681729c353b)
2016-02-22Fix integer overflows in recovery procedure.Yabin Cui1-15/+54
Bug: 26960931 Change-Id: Ieae45caccfb4728fcf514f0d920976585d8e6caf (cherry picked from commit a029c9a45888141a2fa382e0b1868e55db1f36d2)
2016-02-20Check each value read from block map file.Yabin Cui1-15/+31
Bug: 26960931 Change-Id: I50b266ecb899db043831f528c2518bea76168c88
2016-02-18Fix integer overflows in recovery procedure.Yabin Cui1-5/+27
Bug: 26960931 Change-Id: Ieae45caccfb4728fcf514f0d920976585d8e6caf
2015-07-17Clean up LOG functions.Tao Bao1-11/+11
For fatal errors, use LOGE to show messages. Bug: 22236461 Change-Id: I2b7d761576894ac37fcbadcba690ae14affe8f07 (cherry picked from commit d7d0f7503456c3d275a49f90be35e03f02c51bbd)
2015-07-16Clean up LOG functions.Tao Bao1-11/+11
For fatal errors, use LOGE to show messages. Bug: 22236461 Change-Id: Ie2ce7ec769f4502d732fbb53fb7b303c0cf9ed68
2015-06-23Just use fstat in sysMapFile.Elliott Hughes1-63/+23
Also turn on -Werror and remove a dead function. Change-Id: I436f0a91c40e36db985190b3b98b0a4527cf0eeb
2015-04-30Check all lseek calls succeed.Elliott Hughes1-4/+6
Also add missing TEMP_FAILURE_RETRYs on read, write, and lseek. Bug: http://b/20625546 Change-Id: I03b198e11c1921b35518ee2dd005a7cfcf4fd94b (cherry picked from commit 7bad7c4646ee8fd8d6e6ed0ffd3ddbb0c1b41a2f)
2015-04-30Check all lseek calls succeed.Elliott Hughes1-4/+6
Also add missing TEMP_FAILURE_RETRYs on read, write, and lseek. Bug: http://b/20625546 Change-Id: I03b198e11c1921b35518ee2dd005a7cfcf4fd94b
2014-03-18minzip: 64 bit build issueMark Salyzyn1-1/+1
Regression - verification and extraction on memory, not files Bug: 12188746 Change-Id: Ib6facc4aff6be3a31a7d184ef1c493fdd4012c21
2014-01-21log extra info for debuggingDoug Zongker1-0/+2
Make recovery log its PID, and when we use a block map file, log how many ranges it contains. Change-Id: I1b4299f8163af68a770b48c029ae25e6cb45d26b
2014-01-16do verification and extraction on memory, not filesDoug Zongker1-18/+134
Changes minzip and recovery's file signature verification to work on memory regions, rather than files. For packages which are regular files, install.cpp now mmap()s them into memory and then passes the mapped memory to the verifier and to the minzip library. Support for files which are raw block maps (which will be used when we have packages written to encrypted data partitions) is present but largely untested so far. Bug: 12188746 Change-Id: I12cc3e809834745a489dd9d4ceb558cbccdc3f71
2014-01-13remove dead code from minzipDoug Zongker1-117/+0
minzip had some features that were used when reading APKs, but APK handling now uses libziparchive instead of minzip. Remove these unused functions. Change-Id: Iead89209a716bfe9e3d339bf85b3e97e33a41f35
2012-12-17Pass the correct pointer to munmap on failure.Elliott Hughes1-4/+4
This won't ever happen, and you're probably screwed anyway if it does, but that's no excuse... Change-Id: I2c56f607e351e84308a72b41b834d13aaa98fc62
2009-03-04auto import from //depot/cupcake/@135843The Android Open Source Project1-0/+212
2009-03-04auto import from //depot/cupcake/@135843The Android Open Source Project1-212/+0