summaryrefslogtreecommitdiffstats
path: root/fuse_sideload/include
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2019-04-15 21:45:50 +0200
committerTao Bao <tbao@google.com>2019-04-26 21:21:38 +0200
commit178cdd4f5c6ae59d5aaae2614f22cd783eba60d8 (patch)
treebc196683e4994ca538ae0317719f264a828dcfb0 /fuse_sideload/include
parentAllow entering rescue mode via recovery UI. (diff)
downloadandroid_bootable_recovery-178cdd4f5c6ae59d5aaae2614f22cd783eba60d8.tar
android_bootable_recovery-178cdd4f5c6ae59d5aaae2614f22cd783eba60d8.tar.gz
android_bootable_recovery-178cdd4f5c6ae59d5aaae2614f22cd783eba60d8.tar.bz2
android_bootable_recovery-178cdd4f5c6ae59d5aaae2614f22cd783eba60d8.tar.lz
android_bootable_recovery-178cdd4f5c6ae59d5aaae2614f22cd783eba60d8.tar.xz
android_bootable_recovery-178cdd4f5c6ae59d5aaae2614f22cd783eba60d8.tar.zst
android_bootable_recovery-178cdd4f5c6ae59d5aaae2614f22cd783eba60d8.zip
Diffstat (limited to 'fuse_sideload/include')
-rw-r--r--fuse_sideload/include/fuse_provider.h23
1 files changed, 11 insertions, 12 deletions
diff --git a/fuse_sideload/include/fuse_provider.h b/fuse_sideload/include/fuse_provider.h
index 499d57aa0..59059cf9b 100644
--- a/fuse_sideload/include/fuse_provider.h
+++ b/fuse_sideload/include/fuse_provider.h
@@ -25,8 +25,8 @@
// This is the base class to read data from source and provide the data to FUSE.
class FuseDataProvider {
public:
- FuseDataProvider(android::base::unique_fd&& fd, uint64_t file_size, uint32_t block_size)
- : fd_(std::move(fd)), file_size_(file_size), fuse_block_size_(block_size) {}
+ FuseDataProvider(uint64_t file_size, uint32_t block_size)
+ : file_size_(file_size), fuse_block_size_(block_size) {}
virtual ~FuseDataProvider() = default;
@@ -37,21 +37,15 @@ class FuseDataProvider {
return fuse_block_size_;
}
- bool Valid() const {
- return fd_ != -1;
- }
-
// Reads |fetch_size| bytes data starting from |start_block|. Puts the result in |buffer|.
virtual bool ReadBlockAlignedData(uint8_t* buffer, uint32_t fetch_size,
uint32_t start_block) const = 0;
- virtual void Close() = 0;
+ virtual void Close() {}
protected:
FuseDataProvider() = default;
- // The underlying source to read data from.
- android::base::unique_fd fd_;
// Size in bytes of the file to read.
uint64_t file_size_ = 0;
// Block size passed to the fuse, this is different from the block size of the block device.
@@ -61,13 +55,18 @@ class FuseDataProvider {
// This class reads data from a file.
class FuseFileDataProvider : public FuseDataProvider {
public:
- FuseFileDataProvider(android::base::unique_fd&& fd, uint64_t file_size, uint32_t block_size)
- : FuseDataProvider(std::move(fd), file_size, block_size) {}
-
FuseFileDataProvider(const std::string& path, uint32_t block_size);
bool ReadBlockAlignedData(uint8_t* buffer, uint32_t fetch_size,
uint32_t start_block) const override;
+ bool Valid() const {
+ return fd_ != -1;
+ }
+
void Close() override;
+
+ private:
+ // The underlying source to read data from.
+ android::base::unique_fd fd_;
};