summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2011-04-12 18:28:10 +0200
committerDoug Zongker <dougz@android.com>2011-04-12 18:28:10 +0200
commit469243e53689b6f312d20813444dc00d83528758 (patch)
treee59d3978874c4637efdd7fb86201b1c360f4e56d
parentam 4762633c: log which key a package verified against in recovery (diff)
downloadandroid_bootable_recovery-469243e53689b6f312d20813444dc00d83528758.tar
android_bootable_recovery-469243e53689b6f312d20813444dc00d83528758.tar.gz
android_bootable_recovery-469243e53689b6f312d20813444dc00d83528758.tar.bz2
android_bootable_recovery-469243e53689b6f312d20813444dc00d83528758.tar.lz
android_bootable_recovery-469243e53689b6f312d20813444dc00d83528758.tar.xz
android_bootable_recovery-469243e53689b6f312d20813444dc00d83528758.tar.zst
android_bootable_recovery-469243e53689b6f312d20813444dc00d83528758.zip
Diffstat (limited to '')
-rw-r--r--common.h3
-rw-r--r--install.c26
-rw-r--r--recovery.c2
-rw-r--r--roots.c5
4 files changed, 30 insertions, 6 deletions
diff --git a/common.h b/common.h
index cba4c861d..ef2fe9f62 100644
--- a/common.h
+++ b/common.h
@@ -126,4 +126,7 @@ typedef struct {
} UIParameters;
+// fopen a file, mounting volumes and making parent dirs as necessary.
+FILE* fopen_path(const char *path, const char *mode);
+
#endif // RECOVERY_COMMON_H
diff --git a/install.c b/install.c
index 5bb3a78fa..707cda438 100644
--- a/install.c
+++ b/install.c
@@ -36,6 +36,8 @@
#define ASSUMED_UPDATE_BINARY_NAME "META-INF/com/google/android/update-binary"
#define PUBLIC_KEYS_FILE "/res/keys"
+static const char *LAST_INSTALL_FILE = "/cache/recovery/last_install";
+
// If the package contains an update binary, extract it and run it.
static int
try_update_binary(const char *path, ZipArchive *zip) {
@@ -233,8 +235,8 @@ exit:
return NULL;
}
-int
-install_package(const char *path)
+static int
+really_install_package(const char *path)
{
ui_set_background(BACKGROUND_ICON_INSTALLING);
ui_print("Finding update package...\n");
@@ -285,3 +287,23 @@ install_package(const char *path)
ui_print("Installing update...\n");
return try_update_binary(path, &zip);
}
+
+int
+install_package(const char* path)
+{
+ FILE* install_log = fopen_path(LAST_INSTALL_FILE, "w");
+ if (install_log) {
+ fputs(path, install_log);
+ fputc('\n', install_log);
+ } else {
+ LOGE("failed to open last_install: %s\n", strerror(errno));
+ }
+ int result = really_install_package(path);
+ if (install_log) {
+ fputc(result == INSTALL_SUCCESS ? '1' : '0', install_log);
+ fputc('\n', install_log);
+ fclose(install_log);
+ chmod(LAST_INSTALL_FILE, 0644);
+ }
+ return result;
+}
diff --git a/recovery.c b/recovery.c
index fd7ce42f1..3a412d5c5 100644
--- a/recovery.c
+++ b/recovery.c
@@ -120,7 +120,7 @@ static const int MAX_ARG_LENGTH = 4096;
static const int MAX_ARGS = 100;
// open a given path, mounting partitions as necessary
-static FILE*
+FILE*
fopen_path(const char *path, const char *mode) {
if (ensure_path_mounted(path) != 0) {
LOGE("Can't mount %s\n", path);
diff --git a/roots.c b/roots.c
index 1143b76bc..cb7e067a1 100644
--- a/roots.c
+++ b/roots.c
@@ -177,15 +177,14 @@ int ensure_path_mounted(const char* path) {
} else if (strcmp(v->fs_type, "ext4") == 0 ||
strcmp(v->fs_type, "vfat") == 0) {
result = mount(v->device, v->mount_point, v->fs_type,
- MS_NOATIME | MS_NODEV | MS_NODIRATIME | MS_RDONLY, "");
+ MS_NOATIME | MS_NODEV | MS_NODIRATIME, "");
if (result == 0) return 0;
if (v->device2) {
LOGW("failed to mount %s (%s); trying %s\n",
v->device, strerror(errno), v->device2);
result = mount(v->device2, v->mount_point, v->fs_type,
- MS_NOATIME | MS_NODEV |
- MS_NODIRATIME | MS_RDONLY, "");
+ MS_NOATIME | MS_NODEV | MS_NODIRATIME, "");
if (result == 0) return 0;
}