summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bootloader_message/bootloader_message.cpp8
-rw-r--r--bootloader_message/include/bootloader_message/bootloader_message.h3
-rw-r--r--recovery.cpp29
3 files changed, 15 insertions, 25 deletions
diff --git a/bootloader_message/bootloader_message.cpp b/bootloader_message/bootloader_message.cpp
index 9a5671843..294b1725d 100644
--- a/bootloader_message/bootloader_message.cpp
+++ b/bootloader_message/bootloader_message.cpp
@@ -164,7 +164,13 @@ bool clear_bootloader_message(std::string* err) {
}
bool write_bootloader_message(const std::vector<std::string>& options, std::string* err) {
- bootloader_message boot = {};
+ bootloader_message boot;
+ if (!read_bootloader_message(&boot, err)) {
+ return false;
+ }
+ // Zero out the entire fields.
+ memset(boot.command, 0, sizeof(boot.command));
+ memset(boot.recovery, 0, sizeof(boot.recovery));
strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
for (const auto& s : options) {
diff --git a/bootloader_message/include/bootloader_message/bootloader_message.h b/bootloader_message/include/bootloader_message/bootloader_message.h
index b3d2182df..437189e32 100644
--- a/bootloader_message/include/bootloader_message/bootloader_message.h
+++ b/bootloader_message/include/bootloader_message/bootloader_message.h
@@ -193,7 +193,8 @@ bool write_bootloader_message(const bootloader_message& boot, std::string* err);
bool write_bootloader_message_to(const bootloader_message& boot,
const std::string& misc_blk_device, std::string* err);
-// Write bootloader message (boots into recovery with the options) to BCB.
+// Write bootloader message (boots into recovery with the options) to BCB. Will
+// set command and recovery fields only.
bool write_bootloader_message(const std::vector<std::string>& options, std::string* err);
// Clear BCB.
diff --git a/recovery.cpp b/recovery.cpp
index 5f1607553..e777c46cd 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -350,9 +350,12 @@ static std::vector<std::string> get_args(const int argc, char** const argv) {
// --- if that doesn't work, try the command file (if we have /cache).
if (argc == 1 && has_cache) {
std::string content;
- if (android::base::ReadFileToString(COMMAND_FILE, &content)) {
+ if (ensure_path_mounted(COMMAND_FILE) == 0 &&
+ android::base::ReadFileToString(COMMAND_FILE, &content)) {
std::vector<std::string> tokens = android::base::Split(content, "\n");
- for (auto it = tokens.begin() + 1; it != tokens.end(); it++) {
+ // All the arguments in COMMAND_FILE are needed (unlike the BCB message,
+ // COMMAND_FILE doesn't use filename as the first argument).
+ for (auto it = tokens.begin(); it != tokens.end(); it++) {
// Skip empty and '\0'-filled tokens.
if (!it->empty() && (*it)[0] != '\0') args.push_back(std::move(*it));
}
@@ -1522,27 +1525,7 @@ int main(int argc, char **argv) {
for (const auto& arg : args) {
printf(" \"%s\"", arg.c_str());
}
- printf("\n");
-
- if (update_package) {
- // For backwards compatibility on the cache partition only, if
- // we're given an old 'root' path "CACHE:foo", change it to
- // "/cache/foo".
- if (strncmp(update_package, "CACHE:", 6) == 0) {
- int len = strlen(update_package) + 10;
- char* modified_path = (char*)malloc(len);
- if (modified_path) {
- strlcpy(modified_path, "/cache/", len);
- strlcat(modified_path, update_package+6, len);
- printf("(replacing path \"%s\" with \"%s\")\n",
- update_package, modified_path);
- update_package = modified_path;
- }
- else
- printf("modified_path allocation failed\n");
- }
- }
- printf("\n");
+ printf("\n\n");
property_list(print_property, NULL);
printf("\n");