summaryrefslogtreecommitdiffstats
path: root/recovery.cpp
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2013-05-16 20:23:48 +0200
committerDoug Zongker <dougz@android.com>2013-05-16 20:25:28 +0200
commit46bee63afcd1e2817cdc75a6a8cefdcfdc3e8429 (patch)
treebaec950e22bbb298c4ee9b40e9c44729d3c6a53f /recovery.cpp
parentrecovery: turn on text display for install errors in debug builds (diff)
downloadandroid_bootable_recovery-46bee63afcd1e2817cdc75a6a8cefdcfdc3e8429.tar
android_bootable_recovery-46bee63afcd1e2817cdc75a6a8cefdcfdc3e8429.tar.gz
android_bootable_recovery-46bee63afcd1e2817cdc75a6a8cefdcfdc3e8429.tar.bz2
android_bootable_recovery-46bee63afcd1e2817cdc75a6a8cefdcfdc3e8429.tar.lz
android_bootable_recovery-46bee63afcd1e2817cdc75a6a8cefdcfdc3e8429.tar.xz
android_bootable_recovery-46bee63afcd1e2817cdc75a6a8cefdcfdc3e8429.tar.zst
android_bootable_recovery-46bee63afcd1e2817cdc75a6a8cefdcfdc3e8429.zip
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/recovery.cpp b/recovery.cpp
index a84d8333a..840e63c42 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -59,10 +59,11 @@ static const struct option OPTIONS[] = {
{ NULL, 0, NULL, 0 },
};
+#define LAST_LOG_FILE "/cache/recovery/last_log"
+
static const char *COMMAND_FILE = "/cache/recovery/command";
static const char *INTENT_FILE = "/cache/recovery/intent";
static const char *LOG_FILE = "/cache/recovery/log";
-static const char *LAST_LOG_FILE = "/cache/recovery/last_log";
static const char *LAST_INSTALL_FILE = "/cache/recovery/last_install";
static const char *LOCALE_FILE = "/cache/recovery/last_locale";
static const char *CACHE_ROOT = "/cache";
@@ -260,6 +261,21 @@ copy_log_file(const char* source, const char* destination, int append) {
}
}
+// Rename last_log -> last_log.1 -> last_log.2 -> ... -> last_log.$max
+// Overwrites any existing last_log.$max.
+static void
+rotate_last_logs(int max) {
+ char oldfn[256];
+ char newfn[256];
+
+ int i;
+ for (i = max-1; i >= 0; --i) {
+ snprintf(oldfn, sizeof(oldfn), (i==0) ? LAST_LOG_FILE : (LAST_LOG_FILE ".%d"), i);
+ snprintf(newfn, sizeof(newfn), LAST_LOG_FILE ".%d", i+1);
+ // ignore errors
+ rename(oldfn, newfn);
+ }
+}
// 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), and
@@ -843,6 +859,8 @@ main(int argc, char **argv) {
printf("Starting recovery on %s", ctime(&start));
load_volume_table();
+ ensure_path_mounted(LAST_LOG_FILE);
+ rotate_last_logs(5);
get_args(&argc, &argv);
int previous_runs = 0;