summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-03-19 08:02:03 +0100
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-03-19 08:02:03 +0100
commit72407e176514b6b3e0b35bf985d9f97cbca9e27f (patch)
tree00ee997b3bfb0ea0243b38de336eec8593ac3f2c
parentSnap for 6306509 from 9af0acd1c4022b7188131e3b4c8ea17895262b7d to mainline-release (diff)
parentConsolidate the wait in recovery's reboot am: e8ca1b8634 am: 32d28f90f0 am: 457bb8ce31 (diff)
downloadandroid_bootable_recovery-72407e176514b6b3e0b35bf985d9f97cbca9e27f.tar
android_bootable_recovery-72407e176514b6b3e0b35bf985d9f97cbca9e27f.tar.gz
android_bootable_recovery-72407e176514b6b3e0b35bf985d9f97cbca9e27f.tar.bz2
android_bootable_recovery-72407e176514b6b3e0b35bf985d9f97cbca9e27f.tar.lz
android_bootable_recovery-72407e176514b6b3e0b35bf985d9f97cbca9e27f.tar.xz
android_bootable_recovery-72407e176514b6b3e0b35bf985d9f97cbca9e27f.tar.zst
android_bootable_recovery-72407e176514b6b3e0b35bf985d9f97cbca9e27f.zip
-rw-r--r--otautil/include/otautil/sysutil.h2
-rw-r--r--otautil/sysutil.cpp8
-rw-r--r--recovery.cpp8
-rw-r--r--recovery_ui/ui.cpp3
-rw-r--r--updater/install.cpp1
-rw-r--r--updater/updater_runtime.cpp60
6 files changed, 66 insertions, 16 deletions
diff --git a/otautil/include/otautil/sysutil.h b/otautil/include/otautil/sysutil.h
index 326db8644..d0d2e67d7 100644
--- a/otautil/include/otautil/sysutil.h
+++ b/otautil/include/otautil/sysutil.h
@@ -103,7 +103,7 @@ class MemMapping {
// Reboots the device into the specified target, by additionally handling quiescent reboot mode.
// All unknown targets reboot into Android.
-bool Reboot(std::string_view target);
+[[noreturn]] void Reboot(std::string_view target);
// Triggers a shutdown.
bool Shutdown(std::string_view target);
diff --git a/otautil/sysutil.cpp b/otautil/sysutil.cpp
index 6cd46c6a9..b3ead9736 100644
--- a/otautil/sysutil.cpp
+++ b/otautil/sysutil.cpp
@@ -219,14 +219,18 @@ MemMapping::~MemMapping() {
ranges_.clear();
}
-bool Reboot(std::string_view target) {
+void Reboot(std::string_view target) {
std::string cmd = "reboot," + std::string(target);
// Honor the quiescent mode if applicable.
if (target != "bootloader" && target != "fastboot" &&
android::base::GetBoolProperty("ro.boot.quiescent", false)) {
cmd += ",quiescent";
}
- return android::base::SetProperty(ANDROID_RB_PROPERTY, cmd);
+ if (!android::base::SetProperty(ANDROID_RB_PROPERTY, cmd)) {
+ LOG(FATAL) << "Reboot failed";
+ }
+
+ while (true) pause();
}
bool Shutdown(std::string_view target) {
diff --git a/recovery.cpp b/recovery.cpp
index 0382697ab..7675121d4 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -781,13 +781,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
ui->Print("Retry attempt %d\n", retry_count);
// Reboot back into recovery to retry the update.
- if (!Reboot("recovery")) {
- ui->Print("Reboot failed\n");
- } else {
- while (true) {
- pause();
- }
- }
+ Reboot("recovery");
}
// If this is an eng or userdebug build, then automatically
// turn the text display on if the script fails so the error
diff --git a/recovery_ui/ui.cpp b/recovery_ui/ui.cpp
index 6f5cbbca6..330721773 100644
--- a/recovery_ui/ui.cpp
+++ b/recovery_ui/ui.cpp
@@ -375,9 +375,6 @@ void RecoveryUI::ProcessKey(int key_code, int updown) {
case RecoveryUI::REBOOT:
if (reboot_enabled) {
Reboot("userrequested,recovery,ui");
- while (true) {
- pause();
- }
}
break;
diff --git a/updater/install.cpp b/updater/install.cpp
index 62ff87e76..7608dc3cd 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -733,7 +733,6 @@ Value* RebootNowFn(const char* name, State* state, const std::vector<std::unique
Reboot(property);
- sleep(5);
return ErrorAbort(state, kRebootFailure, "%s() failed to reboot", name);
}
diff --git a/updater/updater_runtime.cpp b/updater/updater_runtime.cpp
index c4222a56e..b1b8863fd 100644
--- a/updater/updater_runtime.cpp
+++ b/updater/updater_runtime.cpp
@@ -43,10 +43,62 @@ std::string UpdaterRuntime::FindBlockDeviceName(const std::string_view name) con
return std::string(name);
}
+static struct {
+ const char* name;
+ unsigned flag;
+} mount_flags_list[] = {
+ { "noatime", MS_NOATIME },
+ { "noexec", MS_NOEXEC },
+ { "nosuid", MS_NOSUID },
+ { "nodev", MS_NODEV },
+ { "nodiratime", MS_NODIRATIME },
+ { "ro", MS_RDONLY },
+ { "rw", 0 },
+ { "remount", MS_REMOUNT },
+ { "bind", MS_BIND },
+ { "rec", MS_REC },
+ { "unbindable", MS_UNBINDABLE },
+ { "private", MS_PRIVATE },
+ { "slave", MS_SLAVE },
+ { "shared", MS_SHARED },
+ { "defaults", 0 },
+ { 0, 0 },
+};
+
+static bool setMountFlag(const std::string& flag, unsigned* mount_flags) {
+ for (const auto& [name, value] : mount_flags_list) {
+ if (flag == name) {
+ *mount_flags |= value;
+ return true;
+ }
+ }
+ return false;
+}
+
+static bool parseMountFlags(const std::string& flags, unsigned* mount_flags,
+ std::string* fs_options) {
+ bool is_flag_set = false;
+ std::vector<std::string> flag_list;
+ for (const auto& flag : android::base::Split(flags, ",")) {
+ if (!setMountFlag(flag, mount_flags)) {
+ // Unknown flag, so it must be a filesystem specific option.
+ flag_list.push_back(flag);
+ } else {
+ is_flag_set = true;
+ }
+ }
+ *fs_options = android::base::Join(flag_list, ',');
+ return is_flag_set;
+}
+
int UpdaterRuntime::Mount(const std::string_view location, const std::string_view mount_point,
const std::string_view fs_type, const std::string_view mount_options) {
std::string mount_point_string(mount_point);
+ std::string mount_options_string(mount_options);
char* secontext = nullptr;
+ unsigned mount_flags = 0;
+ std::string fs_options;
+
if (sehandle_) {
selabel_lookup(sehandle_, &secontext, mount_point_string.c_str(), 0755);
setfscreatecon(secontext);
@@ -59,9 +111,13 @@ int UpdaterRuntime::Mount(const std::string_view location, const std::string_vie
setfscreatecon(nullptr);
}
+ if (!parseMountFlags(mount_options_string, &mount_flags, &fs_options)) {
+ // Fall back to default
+ mount_flags = MS_NOATIME | MS_NODEV | MS_NODIRATIME;
+ }
+
return mount(std::string(location).c_str(), mount_point_string.c_str(),
- std::string(fs_type).c_str(), MS_NOATIME | MS_NODEV | MS_NODIRATIME,
- std::string(mount_options).c_str());
+ std::string(fs_type).c_str(), mount_flags, fs_options.c_str());
}
bool UpdaterRuntime::IsMounted(const std::string_view mount_point) const {