summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYifan Hong <elsk@google.com>2019-05-01 22:12:57 +0200
committerYifan Hong <elsk@google.com>2019-05-03 00:51:56 +0200
commitd83070ddb902a5319cf9cdfcc71127b2ef6e8d1e (patch)
treeec7483a877499bac6b12b8fb743517ff2211de47
parentlibbootloader_message: write recovery to any device (diff)
downloadandroid_bootable_recovery-d83070ddb902a5319cf9cdfcc71127b2ef6e8d1e.tar
android_bootable_recovery-d83070ddb902a5319cf9cdfcc71127b2ef6e8d1e.tar.gz
android_bootable_recovery-d83070ddb902a5319cf9cdfcc71127b2ef6e8d1e.tar.bz2
android_bootable_recovery-d83070ddb902a5319cf9cdfcc71127b2ef6e8d1e.tar.lz
android_bootable_recovery-d83070ddb902a5319cf9cdfcc71127b2ef6e8d1e.tar.xz
android_bootable_recovery-d83070ddb902a5319cf9cdfcc71127b2ef6e8d1e.tar.zst
android_bootable_recovery-d83070ddb902a5319cf9cdfcc71127b2ef6e8d1e.zip
-rw-r--r--bootloader_message/Android.bp18
-rw-r--r--bootloader_message/bootloader_message.cpp12
2 files changed, 26 insertions, 4 deletions
diff --git a/bootloader_message/Android.bp b/bootloader_message/Android.bp
index 5cd21323c..4ea7c8680 100644
--- a/bootloader_message/Android.bp
+++ b/bootloader_message/Android.bp
@@ -17,6 +17,7 @@
cc_library {
name: "libbootloader_message",
recovery_available: true,
+ host_supported: true,
srcs: ["bootloader_message.cpp"],
cflags: [
"-Wall",
@@ -24,7 +25,22 @@ cc_library {
],
shared_libs: [
"libbase",
- "libfs_mgr",
],
export_include_dirs: ["include"],
+
+ target: {
+ android: {
+ shared_libs: [
+ "libfs_mgr",
+ ],
+ },
+ host: {
+ shared_libs: [
+ "libcutils", // for strlcpy
+ ],
+ static_libs: [
+ "libfstab",
+ ],
+ }
+ }
}
diff --git a/bootloader_message/bootloader_message.cpp b/bootloader_message/bootloader_message.cpp
index 0ebc04a30..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;
@@ -194,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;
}