diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2019-05-03 18:09:27 +0200 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-05-03 18:09:27 +0200 |
commit | be25cd21e4b1783a836cdfd3e3f504e41b2b9a93 (patch) | |
tree | 2cf1523403a2aa4b999ec09bd89ef8ab4c927993 /bootloader_message/bootloader_message.cpp | |
parent | Merge "Implement FuseBlockDataProvider" (diff) | |
parent | libbootloader_message: host_supported. (diff) | |
download | android_bootable_recovery-be25cd21e4b1783a836cdfd3e3f504e41b2b9a93.tar android_bootable_recovery-be25cd21e4b1783a836cdfd3e3f504e41b2b9a93.tar.gz android_bootable_recovery-be25cd21e4b1783a836cdfd3e3f504e41b2b9a93.tar.bz2 android_bootable_recovery-be25cd21e4b1783a836cdfd3e3f504e41b2b9a93.tar.lz android_bootable_recovery-be25cd21e4b1783a836cdfd3e3f504e41b2b9a93.tar.xz android_bootable_recovery-be25cd21e4b1783a836cdfd3e3f504e41b2b9a93.tar.zst android_bootable_recovery-be25cd21e4b1783a836cdfd3e3f504e41b2b9a93.zip |
Diffstat (limited to 'bootloader_message/bootloader_message.cpp')
-rw-r--r-- | bootloader_message/bootloader_message.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/bootloader_message/bootloader_message.cpp b/bootloader_message/bootloader_message.cpp index 8c1d63bdd..331a42b2a 100644 --- a/bootloader_message/bootloader_message.cpp +++ b/bootloader_message/bootloader_message.cpp @@ -29,6 +29,10 @@ #include <android-base/unique_fd.h> #include <fstab/fstab.h> +#ifndef __ANDROID__ +#include <cutils/memory.h> // for strlcpy +#endif + using android::fs_mgr::Fstab; using android::fs_mgr::ReadDefaultFstab; @@ -168,6 +172,14 @@ bool write_bootloader_message(const std::vector<std::string>& options, std::stri return write_bootloader_message(boot, err); } +bool write_bootloader_message_to(const std::vector<std::string>& options, + const std::string& misc_blk_device, std::string* err) { + bootloader_message boot = {}; + update_bootloader_message_in_struct(&boot, options); + + return write_bootloader_message_to(boot, misc_blk_device, err); +} + bool update_bootloader_message(const std::vector<std::string>& options, std::string* err) { bootloader_message boot; if (!read_bootloader_message(&boot, err)) { @@ -186,13 +198,15 @@ bool update_bootloader_message_in_struct(bootloader_message* boot, memset(boot->recovery, 0, sizeof(boot->recovery)); strlcpy(boot->command, "boot-recovery", sizeof(boot->command)); - strlcpy(boot->recovery, "recovery\n", sizeof(boot->recovery)); + + std::string recovery = "recovery\n"; for (const auto& s : options) { - strlcat(boot->recovery, s.c_str(), sizeof(boot->recovery)); + recovery += s; if (s.back() != '\n') { - strlcat(boot->recovery, "\n", sizeof(boot->recovery)); + recovery += '\n'; } } + strlcpy(boot->recovery, recovery.c_str(), sizeof(boot->recovery)); return true; } |