diff options
Diffstat (limited to 'fastboot')
-rw-r--r-- | fastboot/fastboot.cpp | 4 | ||||
-rw-r--r-- | fastboot/fastboot_driver.cpp | 9 |
2 files changed, 6 insertions, 7 deletions
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index 6b6e659c6..925cac430 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -79,8 +79,8 @@ using android::base::Split; using android::base::Trim; using android::base::unique_fd; -#ifndef O_BINARY -#define O_BINARY 0 +#if defined(_WIN32) +#define O_CLOEXEC O_NOINHERIT #endif static const char* serial = nullptr; diff --git a/fastboot/fastboot_driver.cpp b/fastboot/fastboot_driver.cpp index b1f3bc91b..65a52475d 100644 --- a/fastboot/fastboot_driver.cpp +++ b/fastboot/fastboot_driver.cpp @@ -41,10 +41,10 @@ #include <vector> #include <android-base/file.h> +#include <android-base/mapped_file.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> -#include <utils/FileMap.h> #include "constants.h" #include "transport.h" @@ -467,15 +467,14 @@ RetCode FastBootDriver::SendBuffer(int fd, size_t size) { while (remaining) { // Memory map the file - android::FileMap filemap; size_t len = std::min(remaining, MAX_MAP_SIZE); - - if (!filemap.create(NULL, fd, offset, len, true)) { + auto mapping{android::base::MappedFile::FromFd(fd, offset, len, PROT_READ)}; + if (!mapping) { error_ = "Creating filemap failed"; return IO_ERROR; } - if ((ret = SendBuffer(filemap.getDataPtr(), len))) { + if ((ret = SendBuffer(mapping->data(), mapping->size()))) { return ret; } |