From 9a6f5204190cda6bb6aecb59dff0293cc90ab0b7 Mon Sep 17 00:00:00 2001 From: katao Date: Mon, 19 Dec 2016 11:22:30 +0800 Subject: Bugfix:updater always retry apply patch failed,when memcpy failed. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- applypatch/applypatch.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp index 95389da6e..8682e128b 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) { -- cgit v1.2.3