Merge "Avoid crashing recovery with unwritable /cache."
This commit is contained in:
commit
9187f1cc51
1 changed files with 24 additions and 26 deletions
14
recovery.cpp
14
recovery.cpp
|
@ -477,21 +477,19 @@ static void copy_logs() {
|
||||||
sync();
|
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
|
// 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.
|
// idempotent: call it as many times as you like.
|
||||||
static void finish_recovery() {
|
static void finish_recovery() {
|
||||||
// Save the locale to cache, so if recovery is next started up
|
// Save the locale to cache, so if recovery is next started up without a '--locale' argument
|
||||||
// without a --locale argument (eg, directly from the bootloader)
|
// (e.g., directly from the bootloader) it will use the last-known locale.
|
||||||
// it will use the last-known locale.
|
|
||||||
if (!locale.empty() && has_cache) {
|
if (!locale.empty() && has_cache) {
|
||||||
LOG(INFO) << "Saving locale \"" << locale << "\"";
|
LOG(INFO) << "Saving locale \"" << locale << "\"";
|
||||||
|
if (ensure_path_mounted(LOCALE_FILE) != 0) {
|
||||||
FILE* fp = fopen_path(LOCALE_FILE, "we");
|
LOG(ERROR) << "Failed to mount " << LOCALE_FILE;
|
||||||
if (!android::base::WriteStringToFd(locale, fileno(fp))) {
|
} else if (!android::base::WriteStringToFile(locale, LOCALE_FILE)) {
|
||||||
PLOG(ERROR) << "Failed to save locale to " << LOCALE_FILE;
|
PLOG(ERROR) << "Failed to save locale to " << LOCALE_FILE;
|
||||||
}
|
}
|
||||||
check_and_fclose(fp, LOCALE_FILE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_logs();
|
copy_logs();
|
||||||
|
|
Loading…
Reference in a new issue