diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-07-23 09:31:42 +0200 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-07-23 09:31:42 +0200 |
commit | a187538c374b645b9a44204d911ea93fb0c1fcf7 (patch) | |
tree | 1f01f28cb4c545d376a46f19473b38f039f688af | |
parent | release-request-d8901a87-7dd0-4cc8-a44e-d04982e429da-for-git_oc-mr1-release-4198291 snap-temp-L50900000084068812 (diff) | |
parent | Avoid crashing recovery with unwritable /cache. (diff) | |
download | android_bootable_recovery-a187538c374b645b9a44204d911ea93fb0c1fcf7.tar android_bootable_recovery-a187538c374b645b9a44204d911ea93fb0c1fcf7.tar.gz android_bootable_recovery-a187538c374b645b9a44204d911ea93fb0c1fcf7.tar.bz2 android_bootable_recovery-a187538c374b645b9a44204d911ea93fb0c1fcf7.tar.lz android_bootable_recovery-a187538c374b645b9a44204d911ea93fb0c1fcf7.tar.xz android_bootable_recovery-a187538c374b645b9a44204d911ea93fb0c1fcf7.tar.zst android_bootable_recovery-a187538c374b645b9a44204d911ea93fb0c1fcf7.zip |
-rw-r--r-- | minui/Android.mk | 2 | ||||
-rw-r--r-- | recovery.cpp | 48 |
2 files changed, 24 insertions, 26 deletions
diff --git a/minui/Android.mk b/minui/Android.mk index 4dfc65f8a..6522fcfd2 100644 --- a/minui/Android.mk +++ b/minui/Android.mk @@ -25,7 +25,7 @@ LOCAL_SRC_FILES := \ LOCAL_WHOLE_STATIC_LIBRARIES := \ libadf \ - libdrm \ + libdrm_platform \ libsync_recovery LOCAL_STATIC_LIBRARIES := \ diff --git a/recovery.cpp b/recovery.cpp index 50115885f..11c12f6f1 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -478,40 +478,38 @@ static void copy_logs() { sync(); } -// clear the recovery command and prepare to boot a (hopefully working) system, +// Clear the recovery command and prepare to boot a (hopefully working) system, // copy our log file to cache as well (for the system to read). This function is // idempotent: call it as many times as you like. static void finish_recovery() { - // Save the locale to cache, so if recovery is next started up - // without a --locale argument (eg, directly from the bootloader) - // it will use the last-known locale. - if (!locale.empty() && has_cache) { - LOG(INFO) << "Saving locale \"" << locale << "\""; - - FILE* fp = fopen_path(LOCALE_FILE, "we"); - if (!android::base::WriteStringToFd(locale, fileno(fp))) { - PLOG(ERROR) << "Failed to save locale to " << LOCALE_FILE; - } - check_and_fclose(fp, LOCALE_FILE); + // Save the locale to cache, so if recovery is next started up without a '--locale' argument + // (e.g., directly from the bootloader) it will use the last-known locale. + if (!locale.empty() && has_cache) { + LOG(INFO) << "Saving locale \"" << locale << "\""; + if (ensure_path_mounted(LOCALE_FILE) != 0) { + LOG(ERROR) << "Failed to mount " << LOCALE_FILE; + } else if (!android::base::WriteStringToFile(locale, LOCALE_FILE)) { + PLOG(ERROR) << "Failed to save locale to " << LOCALE_FILE; } + } - copy_logs(); + copy_logs(); - // Reset to normal system boot so recovery won't cycle indefinitely. - std::string err; - if (!clear_bootloader_message(&err)) { - LOG(ERROR) << "Failed to clear BCB message: " << err; - } + // Reset to normal system boot so recovery won't cycle indefinitely. + std::string err; + if (!clear_bootloader_message(&err)) { + LOG(ERROR) << "Failed to clear BCB message: " << err; + } - // Remove the command file, so recovery won't repeat indefinitely. - if (has_cache) { - if (ensure_path_mounted(COMMAND_FILE) != 0 || (unlink(COMMAND_FILE) && errno != ENOENT)) { - LOG(WARNING) << "Can't unlink " << COMMAND_FILE; - } - ensure_path_unmounted(CACHE_ROOT); + // Remove the command file, so recovery won't repeat indefinitely. + if (has_cache) { + if (ensure_path_mounted(COMMAND_FILE) != 0 || (unlink(COMMAND_FILE) && errno != ENOENT)) { + LOG(WARNING) << "Can't unlink " << COMMAND_FILE; } + ensure_path_unmounted(CACHE_ROOT); + } - sync(); // For good measure. + sync(); // For good measure. } struct saved_log_file { |