From f117962eb25bde75e981c3bff91ba708a55df65e Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Thu, 25 Aug 2016 15:32:21 -0500 Subject: Make it backwards compatible with 4.4 Change-Id: I668604cddc8e8afbf78709f3f872bea4e9f4aa06 --- bootloader.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'bootloader.cpp') diff --git a/bootloader.cpp b/bootloader.cpp index 13bc39167..90b8998b0 100644 --- a/bootloader.cpp +++ b/bootloader.cpp @@ -32,7 +32,7 @@ extern "C" { #include "common.h" #include "mtdutils/mtdutils.h" //#include "roots.h" -#include "unique_fd.h" +//#include "unique_fd.h" // fake Volume struct that allows us to use the AOSP code easily struct Volume @@ -232,33 +232,36 @@ static int get_bootloader_message_block(bootloader_message* out, static int set_bootloader_message_block(const bootloader_message* in, const Volume* v) { wait_for_device(v->blk_device); - unique_fd fd(open(v->blk_device, O_WRONLY | O_SYNC)); - if (fd.get() == -1) { + int fd = open(v->blk_device, O_WRONLY | O_SYNC); + if (fd == -1) { LOGE("failed to open \"%s\": %s\n", v->blk_device, strerror(errno)); return -1; } #ifdef BOARD_RECOVERY_BLDRMSG_OFFSET - lseek(fd.get(), BOARD_RECOVERY_BLDRMSG_OFFSET, SEEK_SET); + lseek(fd, BOARD_RECOVERY_BLDRMSG_OFFSET, SEEK_SET); #endif size_t written = 0; const uint8_t* start = reinterpret_cast(in); size_t total = sizeof(*in); while (written < total) { - ssize_t wrote = TEMP_FAILURE_RETRY(write(fd.get(), start + written, total - written)); + 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)); + LOGE("failed to write some bytes: %s\n", + strerror(errno)); + close(fd); return -1; } written += wrote; } - if (fsync(fd.get()) == -1) { + if (fsync(fd) == -1) { LOGE("failed to fsync \"%s\": %s\n", v->blk_device, strerror(errno)); + close(fd); return -1; } + close(fd); return 0; } -- cgit v1.2.3