diff options
author | Tianjie Xu <xunchang@google.com> | 2019-03-20 18:43:30 +0100 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-03-20 18:43:30 +0100 |
commit | 2037c60de48b560be698f3a74588084b1de5e726 (patch) | |
tree | 9f5ad0d458a7ae8cb128e0c48caf1def481105dd /fuse_sdcard_install.cpp | |
parent | Merge "Create a FuseDataProvider base class" (diff) | |
parent | Remove the provider_vtab (diff) | |
download | android_bootable_recovery-2037c60de48b560be698f3a74588084b1de5e726.tar android_bootable_recovery-2037c60de48b560be698f3a74588084b1de5e726.tar.gz android_bootable_recovery-2037c60de48b560be698f3a74588084b1de5e726.tar.bz2 android_bootable_recovery-2037c60de48b560be698f3a74588084b1de5e726.tar.lz android_bootable_recovery-2037c60de48b560be698f3a74588084b1de5e726.tar.xz android_bootable_recovery-2037c60de48b560be698f3a74588084b1de5e726.tar.zst android_bootable_recovery-2037c60de48b560be698f3a74588084b1de5e726.zip |
Diffstat (limited to 'fuse_sdcard_install.cpp')
-rw-r--r-- | fuse_sdcard_install.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/fuse_sdcard_install.cpp b/fuse_sdcard_install.cpp index 79ef16bbc..2feb4d242 100644 --- a/fuse_sdcard_install.cpp +++ b/fuse_sdcard_install.cpp @@ -20,26 +20,21 @@ #include <unistd.h> #include <functional> +#include <memory> #include "fuse_provider.h" #include "fuse_sideload.h" bool start_sdcard_fuse(const char* path) { - FuseFileDataProvider file_data_reader(path, 65536); + auto file_data_reader = std::make_unique<FuseFileDataProvider>(path, 65536); - if (!file_data_reader) { + if (!file_data_reader->Valid()) { return false; } - provider_vtab vtab; - vtab.read_block = std::bind(&FuseFileDataProvider::ReadBlockAlignedData, &file_data_reader, - std::placeholders::_2, std::placeholders::_3, std::placeholders::_1); - vtab.close = [&file_data_reader]() { file_data_reader.Close(); }; - // The installation process expects to find the sdcard unmounted. Unmount it with MNT_DETACH so // that our open file continues to work but new references see it as unmounted. umount2("/sdcard", MNT_DETACH); - return run_fuse_sideload(vtab, file_data_reader.file_size(), - file_data_reader.fuse_block_size()) == 0; + return run_fuse_sideload(std::move(file_data_reader)) == 0; } |