Merge "init: write bootloader message directly." into nyc-dev
This commit is contained in:
commit
a3a7a886f5
2 changed files with 6 additions and 8 deletions
|
|
@ -83,6 +83,7 @@ LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
|
||||||
|
|
||||||
LOCAL_STATIC_LIBRARIES := \
|
LOCAL_STATIC_LIBRARIES := \
|
||||||
libinit \
|
libinit \
|
||||||
|
libbootloader_message_writer \
|
||||||
libfs_mgr \
|
libfs_mgr \
|
||||||
libfec \
|
libfec \
|
||||||
libfec_rs \
|
libfec_rs \
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <android-base/parseint.h>
|
#include <android-base/parseint.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
|
#include <bootloader_message_writer.h>
|
||||||
#include <cutils/partition_utils.h>
|
#include <cutils/partition_utils.h>
|
||||||
#include <cutils/android_reboot.h>
|
#include <cutils/android_reboot.h>
|
||||||
#include <logwrap/logwrap.h>
|
#include <logwrap/logwrap.h>
|
||||||
|
|
@ -450,14 +451,10 @@ exit_success:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wipe_data_via_recovery() {
|
static int wipe_data_via_recovery() {
|
||||||
mkdir("/cache/recovery", 0700);
|
const std::vector<std::string> options = {"--wipe_data", "--reason=wipe_data_via_recovery"};
|
||||||
int fd = open("/cache/recovery/command", O_RDWR|O_CREAT|O_TRUNC|O_CLOEXEC, 0600);
|
std::string err;
|
||||||
if (fd >= 0) {
|
if (!write_bootloader_message(options, &err)) {
|
||||||
write(fd, "--wipe_data\n", strlen("--wipe_data\n") + 1);
|
ERROR("failed to set bootloader message: %s", err.c_str());
|
||||||
write(fd, "--reason=wipe_data_via_recovery\n", strlen("--reason=wipe_data_via_recovery\n") + 1);
|
|
||||||
close(fd);
|
|
||||||
} else {
|
|
||||||
ERROR("could not open /cache/recovery/command\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
android_reboot(ANDROID_RB_RESTART2, 0, "recovery");
|
android_reboot(ANDROID_RB_RESTART2, 0, "recovery");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue