summaryrefslogtreecommitdiffstats
path: root/bootloader_message
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2018-08-24 18:17:36 +0200
committerEthan Yonker <dees_troy@teamw.in>2018-08-24 18:17:39 +0200
commit58f2132bc3954fc704787d477500a209eedb8e29 (patch)
treeeb0f79aacd68724b0c0c091018384ef924380f47 /bootloader_message
parentRemove remaining pieces of supersu (diff)
parentSnap for 4745538 from 723056a83f8c8b15af02d9c302862dbb2304ea8c to pi-release (diff)
downloadandroid_bootable_recovery-58f2132bc3954fc704787d477500a209eedb8e29.tar
android_bootable_recovery-58f2132bc3954fc704787d477500a209eedb8e29.tar.gz
android_bootable_recovery-58f2132bc3954fc704787d477500a209eedb8e29.tar.bz2
android_bootable_recovery-58f2132bc3954fc704787d477500a209eedb8e29.tar.lz
android_bootable_recovery-58f2132bc3954fc704787d477500a209eedb8e29.tar.xz
android_bootable_recovery-58f2132bc3954fc704787d477500a209eedb8e29.tar.zst
android_bootable_recovery-58f2132bc3954fc704787d477500a209eedb8e29.zip
Diffstat (limited to '')
-rw-r--r--bootloader_message/Android.bp (renamed from bootloader_message/Android.NObp)5
-rw-r--r--bootloader_message/bootloader_message.cpp33
-rw-r--r--bootloader_message/include/bootloader_message/bootloader_message.h11
3 files changed, 31 insertions, 18 deletions
diff --git a/bootloader_message/Android.NObp b/bootloader_message/Android.bp
index f0d76e718..c81c67bdb 100644
--- a/bootloader_message/Android.NObp
+++ b/bootloader_message/Android.bp
@@ -17,7 +17,10 @@
cc_library_static {
name: "libbootloader_message",
srcs: ["bootloader_message.cpp"],
- cppflags: ["-Werror"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
static_libs: [
"libbase",
"libfs_mgr",
diff --git a/bootloader_message/bootloader_message.cpp b/bootloader_message/bootloader_message.cpp
index 6c237e620..72ec8bcc9 100644
--- a/bootloader_message/bootloader_message.cpp
+++ b/bootloader_message/bootloader_message.cpp
@@ -186,14 +186,8 @@ bool clear_bootloader_message(std::string* err) {
bool write_bootloader_message(const std::vector<std::string>& options, std::string* err) {
bootloader_message boot = {};
- strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
- strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
- for (const auto& s : options) {
- strlcat(boot.recovery, s.c_str(), sizeof(boot.recovery));
- if (s.back() != '\n') {
- strlcat(boot.recovery, "\n", sizeof(boot.recovery));
- }
- }
+ update_bootloader_message_in_struct(&boot, options);
+
return write_bootloader_message(boot, err);
}
@@ -202,20 +196,27 @@ bool update_bootloader_message(const std::vector<std::string>& options, std::str
if (!read_bootloader_message(&boot, err)) {
return false;
}
+ update_bootloader_message_in_struct(&boot, options);
- // Zero out the entire fields.
- memset(boot.command, 0, sizeof(boot.command));
- memset(boot.recovery, 0, sizeof(boot.recovery));
+ return write_bootloader_message(boot, err);
+}
+
+bool update_bootloader_message_in_struct(bootloader_message* boot,
+ const std::vector<std::string>& options) {
+ if (!boot) return false;
+ // Replace the command & recovery 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));
+ strlcpy(boot->command, "boot-recovery", sizeof(boot->command));
+ strlcpy(boot->recovery, "recovery\n", sizeof(boot->recovery));
for (const auto& s : options) {
- strlcat(boot.recovery, s.c_str(), sizeof(boot.recovery));
+ strlcat(boot->recovery, s.c_str(), sizeof(boot->recovery));
if (s.back() != '\n') {
- strlcat(boot.recovery, "\n", sizeof(boot.recovery));
+ strlcat(boot->recovery, "\n", sizeof(boot->recovery));
}
}
- return write_bootloader_message(boot, err);
+ return true;
}
bool write_reboot_bootloader(std::string* err) {
diff --git a/bootloader_message/include/bootloader_message/bootloader_message.h b/bootloader_message/include/bootloader_message/bootloader_message.h
index 4da1171cd..29f560185 100644
--- a/bootloader_message/include/bootloader_message/bootloader_message.h
+++ b/bootloader_message/include/bootloader_message/bootloader_message.h
@@ -114,13 +114,17 @@ static_assert(sizeof(struct bootloader_message) == 2048,
* implementations are free to use all 32 bytes and may store private
* data past the first NUL-byte in this field. It is encouraged, but
* not mandatory, to use 'struct bootloader_control' described below.
+ *
+ * The update_channel field is used to store the Omaha update channel
+ * if update_engine is compiled with Omaha support.
*/
struct bootloader_message_ab {
struct bootloader_message message;
char slot_suffix[32];
+ char update_channel[128];
// Round up the entire struct to 4096-byte.
- char reserved[2016];
+ char reserved[1888];
};
/**
@@ -218,6 +222,11 @@ bool write_bootloader_message(const std::vector<std::string>& options, std::stri
// only update the command and recovery fields.
bool update_bootloader_message(const std::vector<std::string>& options, std::string* err);
+// Update bootloader message (boots into recovery with the |options|) in |boot|. Will only update
+// the command and recovery fields.
+bool update_bootloader_message_in_struct(bootloader_message* boot,
+ const std::vector<std::string>& options);
+
// Clear BCB.
bool clear_bootloader_message(std::string* err);