diff options
author | katao <ustckato@gmail.com> | 2016-12-19 11:22:30 +0800 |
---|---|---|
committer | tao ka <ustckato@gmail.com> | 2016-12-19 08:51:07 +0000 |
commit | 9a6f5204190cda6bb6aecb59dff0293cc90ab0b7 (patch) | |
tree | 567c1e301e3e40486e427a0ce6bd9d02cd21f957 /applypatch/applypatch.cpp | |
parent | 26d972c9d2d75a2a96d63123f0313e5c9e70a73f (diff) |
Bugfix:updater always retry apply patch failed,when memcpy failed.
https://code.google.com/p/android/issues/detail?id=230602
On the second attempt, open the file with O_RDONLY,
which causing a write failure。
Change-Id: If89165b8c7619fe25722073a46b3cc7c61530a71
Signed-off-by: katao <ustckato@gmail.com>
Diffstat (limited to 'applypatch/applypatch.cpp')
-rw-r--r-- | applypatch/applypatch.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp index 95389da6..8682e128 100644 --- a/applypatch/applypatch.cpp +++ b/applypatch/applypatch.cpp @@ -332,6 +332,17 @@ int WriteToPartition(const unsigned char* data, size_t len, const std::string& t success = true; break; } + + if (ota_close(fd) != 0) { + printf("failed to close %s: %s\n", partition, strerror(errno)); + return -1; + } + + fd.reset(ota_open(partition, O_RDWR)); + if (fd == -1) { + printf("failed to reopen %s for retry write && verify: %s\n", partition, strerror(errno)); + return -1; + } } if (!success) { |