diff options
author | Tianjie Xu <xunchang@google.com> | 2019-03-20 19:10:04 +0100 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-03-20 19:10:04 +0100 |
commit | 9b177eb32d5156df43565831d8e80d958db36af5 (patch) | |
tree | 7d534e4a3f47b18eb13b11f4a386f98ae1cd289e /fuse_sdcard_install.cpp | |
parent | Merge "Create a FuseDataProvider base class" am: eeea86f5fd am: 4aa4bf5e19 (diff) | |
parent | Merge "Remove the provider_vtab" am: 2037c60de4 (diff) | |
download | android_bootable_recovery-9b177eb32d5156df43565831d8e80d958db36af5.tar android_bootable_recovery-9b177eb32d5156df43565831d8e80d958db36af5.tar.gz android_bootable_recovery-9b177eb32d5156df43565831d8e80d958db36af5.tar.bz2 android_bootable_recovery-9b177eb32d5156df43565831d8e80d958db36af5.tar.lz android_bootable_recovery-9b177eb32d5156df43565831d8e80d958db36af5.tar.xz android_bootable_recovery-9b177eb32d5156df43565831d8e80d958db36af5.tar.zst android_bootable_recovery-9b177eb32d5156df43565831d8e80d958db36af5.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; } |