summaryrefslogtreecommitdiffstats
path: root/fastboot/fastboot_driver.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2018-10-19 16:09:39 -0700
committerElliott Hughes <enh@google.com>2018-10-23 13:20:49 -0700
commite8f4b14301e697e0cc54754b1837ce106f08e304 (patch)
tree9bdb3a9d843e532a3b1a4882859c6d51ec55ebd9 /fastboot/fastboot_driver.cpp
parent7a08c896dda54b1814a2c7f06e45fff3de98ecdc (diff)
downloadsystem_core-e8f4b14301e697e0cc54754b1837ce106f08e304.tar.gz
system_core-e8f4b14301e697e0cc54754b1837ce106f08e304.tar.bz2
system_core-e8f4b14301e697e0cc54754b1837ce106f08e304.zip
Add a simple MappedFile to libbase and switch fastboot and libziparchive over.
This allows us to remove libziparchive's dependency on libutils. Bug: http://b/79112958 Test: ran libbase and libziparchive tests, ran fastboot manually Change-Id: I95c651976dad222863e5b8c37d4514b778f5dce7
Diffstat (limited to 'fastboot/fastboot_driver.cpp')
-rw-r--r--fastboot/fastboot_driver.cpp9
1 files changed, 4 insertions, 5 deletions
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;
}