diff options
author | Jed Estep <jestep@google.com> | 2016-01-09 00:28:32 +0100 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-01-09 00:28:32 +0100 |
commit | b1cc5d8434c0216a1d7174d18c53054e46a51f76 (patch) | |
tree | b979d15382f002d7df1dd5be49999d3462564838 /updater/blockimg.cpp | |
parent | Merge "updater: Add a function to check first block" am: 6f8b9b60db (diff) | |
parent | IO fault injection for OTA packages (diff) | |
download | android_bootable_recovery-b1cc5d8434c0216a1d7174d18c53054e46a51f76.tar android_bootable_recovery-b1cc5d8434c0216a1d7174d18c53054e46a51f76.tar.gz android_bootable_recovery-b1cc5d8434c0216a1d7174d18c53054e46a51f76.tar.bz2 android_bootable_recovery-b1cc5d8434c0216a1d7174d18c53054e46a51f76.tar.lz android_bootable_recovery-b1cc5d8434c0216a1d7174d18c53054e46a51f76.tar.xz android_bootable_recovery-b1cc5d8434c0216a1d7174d18c53054e46a51f76.tar.zst android_bootable_recovery-b1cc5d8434c0216a1d7174d18c53054e46a51f76.zip |
Diffstat (limited to 'updater/blockimg.cpp')
-rw-r--r-- | updater/blockimg.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp index c6daf7db5..c898ac6f6 100644 --- a/updater/blockimg.cpp +++ b/updater/blockimg.cpp @@ -45,6 +45,7 @@ #include "install.h" #include "mincrypt/sha.h" #include "minzip/Hash.h" +#include "otafault/ota_io.h" #include "print_sha1.h" #include "unique_fd.h" #include "updater.h" @@ -139,7 +140,7 @@ static bool range_overlaps(const RangeSet& r1, const RangeSet& r2) { static int read_all(int fd, uint8_t* data, size_t size) { size_t so_far = 0; while (so_far < size) { - ssize_t r = TEMP_FAILURE_RETRY(read(fd, data+so_far, size-so_far)); + ssize_t r = TEMP_FAILURE_RETRY(ota_read(fd, data+so_far, size-so_far)); if (r == -1) { fprintf(stderr, "read failed: %s\n", strerror(errno)); return -1; @@ -156,7 +157,7 @@ static int read_all(int fd, std::vector<uint8_t>& buffer, size_t size) { static int write_all(int fd, const uint8_t* data, size_t size) { size_t written = 0; while (written < size) { - ssize_t w = TEMP_FAILURE_RETRY(write(fd, data+written, size-written)); + ssize_t w = TEMP_FAILURE_RETRY(ota_write(fd, data+written, size-written)); if (w == -1) { fprintf(stderr, "write failed: %s\n", strerror(errno)); return -1; @@ -622,7 +623,7 @@ static int WriteStash(const std::string& base, const std::string& id, int blocks return -1; } - if (fsync(fd) == -1) { + if (ota_fsync(fd) == -1) { fprintf(stderr, "fsync \"%s\" failed: %s\n", fn.c_str(), strerror(errno)); return -1; } @@ -642,7 +643,7 @@ static int WriteStash(const std::string& base, const std::string& id, int blocks return -1; } - if (fsync(dfd) == -1) { + if (ota_fsync(dfd) == -1) { fprintf(stderr, "fsync \"%s\" failed: %s\n", dname.c_str(), strerror(errno)); return -1; } @@ -1467,7 +1468,7 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, int /* arg } if (params.canwrite) { - if (fsync(params.fd) == -1) { + if (ota_fsync(params.fd) == -1) { fprintf(stderr, "fsync failed: %s\n", strerror(errno)); goto pbiudone; } @@ -1492,7 +1493,7 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, int /* arg rc = 0; pbiudone: - if (fsync(params.fd) == -1) { + if (ota_fsync(params.fd) == -1) { fprintf(stderr, "fsync failed: %s\n", strerror(errno)); } // params.fd will be automatically closed because of the fd_holder above. |