aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Zongker2013-07-02 13:43:25 -0500
committerDoug Zongker2013-07-02 13:43:25 -0500
commitf24fd7e8479d54eaa2b73db5a3a3ad076a13f72d (patch)
tree2dfafc6f3181e6e016381db5d757022259d63712 /recovery.cpp
parent7839f64bafff349bff630df29cae11dfee05a1e5 (diff)
downloadplatform-bootable-recovery-f24fd7e8479d54eaa2b73db5a3a3ad076a13f72d.tar.gz
platform-bootable-recovery-f24fd7e8479d54eaa2b73db5a3a3ad076a13f72d.tar.xz
platform-bootable-recovery-f24fd7e8479d54eaa2b73db5a3a3ad076a13f72d.zip
recovery: copy logs to cache more aggressively
Copy logs to /cache immediately upon a package installation failure; don't wait for recovery to finish. (If the user reboots without exiting recovery the "right" way, the logs never get copied at all.) Change-Id: Iee342944e7ded63da5a4af33d11ebc876f6c0835
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/recovery.cpp b/recovery.cpp
index c82844d2..b7fb616c 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -283,6 +283,19 @@ rotate_last_logs(int max) {
283 } 283 }
284} 284}
285 285
286static void
287copy_logs() {
288 // Copy logs to cache so the system can find out what happened.
289 copy_log_file(TEMPORARY_LOG_FILE, LOG_FILE, true);
290 copy_log_file(TEMPORARY_LOG_FILE, LAST_LOG_FILE, false);
291 copy_log_file(TEMPORARY_INSTALL_FILE, LAST_INSTALL_FILE, false);
292 chmod(LOG_FILE, 0600);
293 chown(LOG_FILE, 1000, 1000); // system user
294 chmod(LAST_LOG_FILE, 0640);
295 chmod(LAST_INSTALL_FILE, 0644);
296 sync();
297}
298
286// clear the recovery command and prepare to boot a (hopefully working) system, 299// clear the recovery command and prepare to boot a (hopefully working) system,
287// copy our log file to cache as well (for the system to read), and 300// copy our log file to cache as well (for the system to read), and
288// record any intent we were asked to communicate back to the system. 301// record any intent we were asked to communicate back to the system.
@@ -312,14 +325,7 @@ finish_recovery(const char *send_intent) {
312 check_and_fclose(fp, LOCALE_FILE); 325 check_and_fclose(fp, LOCALE_FILE);
313 } 326 }
314 327
315 // Copy logs to cache so the system can find out what happened. 328 copy_logs();
316 copy_log_file(TEMPORARY_LOG_FILE, LOG_FILE, true);
317 copy_log_file(TEMPORARY_LOG_FILE, LAST_LOG_FILE, false);
318 copy_log_file(TEMPORARY_INSTALL_FILE, LAST_INSTALL_FILE, false);
319 chmod(LOG_FILE, 0600);
320 chown(LOG_FILE, 1000, 1000); // system user
321 chmod(LAST_LOG_FILE, 0640);
322 chmod(LAST_INSTALL_FILE, 0644);
323 329
324 // Reset to normal system boot so recovery won't cycle indefinitely. 330 // Reset to normal system boot so recovery won't cycle indefinitely.
325 struct bootloader_message boot; 331 struct bootloader_message boot;
@@ -789,6 +795,7 @@ prompt_and_wait(Device* device, int status) {
789 if (status != INSTALL_SUCCESS) { 795 if (status != INSTALL_SUCCESS) {
790 ui->SetBackground(RecoveryUI::ERROR); 796 ui->SetBackground(RecoveryUI::ERROR);
791 ui->Print("Installation aborted.\n"); 797 ui->Print("Installation aborted.\n");
798 copy_logs();
792 } else if (!ui->IsTextVisible()) { 799 } else if (!ui->IsTextVisible()) {
793 return; // reboot if logs aren't visible 800 return; // reboot if logs aren't visible
794 } else { 801 } else {
@@ -866,7 +873,7 @@ main(int argc, char **argv) {
866 873
867 load_volume_table(); 874 load_volume_table();
868 ensure_path_mounted(LAST_LOG_FILE); 875 ensure_path_mounted(LAST_LOG_FILE);
869 rotate_last_logs(5); 876 rotate_last_logs(10);
870 get_args(&argc, &argv); 877 get_args(&argc, &argv);
871 878
872 int previous_runs = 0; 879 int previous_runs = 0;
@@ -979,6 +986,7 @@ main(int argc, char **argv) {
979 } 986 }
980 987
981 if (status == INSTALL_ERROR || status == INSTALL_CORRUPT) { 988 if (status == INSTALL_ERROR || status == INSTALL_CORRUPT) {
989 copy_logs();
982 ui->SetBackground(RecoveryUI::ERROR); 990 ui->SetBackground(RecoveryUI::ERROR);
983 } 991 }
984 if (status != INSTALL_SUCCESS || ui->IsTextVisible()) { 992 if (status != INSTALL_SUCCESS || ui->IsTextVisible()) {