From 7b0ad9c638176dc364dabb65b363536055a0ea9c Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Fri, 5 Aug 2016 18:00:04 -0700 Subject: Switch recovery to libbase logging Clean up the recovery image and switch to libbase logging. Bug: 28191554 Change-Id: Icd999c3cc832f0639f204b5c36cea8afe303ad35 Merged-In: Icd999c3cc832f0639f204b5c36cea8afe303ad35 --- bootloader.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'bootloader.cpp') diff --git a/bootloader.cpp b/bootloader.cpp index 783f56ea8..dad0bab30 100644 --- a/bootloader.cpp +++ b/bootloader.cpp @@ -25,10 +25,11 @@ #include +#include +#include + #include "bootloader.h" -#include "common.h" #include "roots.h" -#include static int get_bootloader_message_block(bootloader_message* out, const Volume* v); static int set_bootloader_message_block(const bootloader_message* in, const Volume* v); @@ -36,26 +37,26 @@ static int set_bootloader_message_block(const bootloader_message* in, const Volu int get_bootloader_message(bootloader_message* out) { Volume* v = volume_for_path("/misc"); if (v == nullptr) { - LOGE("Cannot load volume /misc!\n"); + LOG(ERROR) << "Cannot load volume /misc!"; return -1; } if (strcmp(v->fs_type, "emmc") == 0) { return get_bootloader_message_block(out, v); } - LOGE("unknown misc partition fs_type \"%s\"\n", v->fs_type); + LOG(ERROR) << "unknown misc partition fs_type \"" << v->fs_type << "\""; return -1; } int set_bootloader_message(const bootloader_message* in) { Volume* v = volume_for_path("/misc"); if (v == nullptr) { - LOGE("Cannot load volume /misc!\n"); + LOG(ERROR) << "Cannot load volume /misc!"; return -1; } if (strcmp(v->fs_type, "emmc") == 0) { return set_bootloader_message_block(in, v); } - LOGE("unknown misc partition fs_type \"%s\"\n", v->fs_type); + LOG(ERROR) << "unknown misc partition fs_type \"" << v->fs_type << "\""; return -1; } @@ -86,17 +87,17 @@ static int get_bootloader_message_block(bootloader_message* out, wait_for_device(v->blk_device); FILE* f = fopen(v->blk_device, "rb"); if (f == nullptr) { - LOGE("failed to open \"%s\": %s\n", v->blk_device, strerror(errno)); + PLOG(ERROR) << "failed to open \"" << v->blk_device << "\""; return -1; } bootloader_message temp; int count = fread(&temp, sizeof(temp), 1, f); if (count != 1) { - LOGE("failed to read \"%s\": %s\n", v->blk_device, strerror(errno)); + PLOG(ERROR) << "failed to read \"" << v->blk_device << "\""; return -1; } if (fclose(f) != 0) { - LOGE("failed to close \"%s\": %s\n", v->blk_device, strerror(errno)); + PLOG(ERROR) << "failed to close \"" << v->blk_device << "\""; return -1; } memcpy(out, &temp, sizeof(temp)); @@ -108,7 +109,7 @@ static int set_bootloader_message_block(const bootloader_message* in, wait_for_device(v->blk_device); android::base::unique_fd fd(open(v->blk_device, O_WRONLY | O_SYNC)); if (fd == -1) { - LOGE("failed to open \"%s\": %s\n", v->blk_device, strerror(errno)); + PLOG(ERROR) << "failed to open \"" << v->blk_device << "\""; return -1; } @@ -118,15 +119,15 @@ static int set_bootloader_message_block(const bootloader_message* in, while (written < total) { ssize_t wrote = TEMP_FAILURE_RETRY(write(fd, start + written, total - written)); if (wrote == -1) { - LOGE("failed to write %" PRId64 " bytes: %s\n", - static_cast(written), strerror(errno)); + PLOG(ERROR) << "failed to write " << total << " bytes, " << written + << " bytes written"; return -1; } written += wrote; } if (fsync(fd) == -1) { - LOGE("failed to fsync \"%s\": %s\n", v->blk_device, strerror(errno)); + PLOG(ERROR) << "failed to fsync \"" << v->blk_device << "\""; return -1; } return 0; -- cgit v1.2.3