summaryrefslogtreecommitdiffstats
path: root/fuse_sideload/include/fuse_provider.h
diff options
context:
space:
mode:
authorxunchang <xunchang@google.com>2019-03-22 16:54:35 +0100
committerTianjie Xu <xunchang@google.com>2019-05-01 21:09:38 +0200
commit311e6ca7b609e578c0ec132440a4ad981db70a9e (patch)
tree206a8c1268e4664cb06890f9835d86e83014ae8a /fuse_sideload/include/fuse_provider.h
parentMerge changes I2d42f55a,Ic1b5dbf7 (diff)
downloadandroid_bootable_recovery-311e6ca7b609e578c0ec132440a4ad981db70a9e.tar
android_bootable_recovery-311e6ca7b609e578c0ec132440a4ad981db70a9e.tar.gz
android_bootable_recovery-311e6ca7b609e578c0ec132440a4ad981db70a9e.tar.bz2
android_bootable_recovery-311e6ca7b609e578c0ec132440a4ad981db70a9e.tar.lz
android_bootable_recovery-311e6ca7b609e578c0ec132440a4ad981db70a9e.tar.xz
android_bootable_recovery-311e6ca7b609e578c0ec132440a4ad981db70a9e.tar.zst
android_bootable_recovery-311e6ca7b609e578c0ec132440a4ad981db70a9e.zip
Diffstat (limited to '')
-rw-r--r--fuse_sideload/include/fuse_provider.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/fuse_sideload/include/fuse_provider.h b/fuse_sideload/include/fuse_provider.h
index 59059cf9b..8d4ea4073 100644
--- a/fuse_sideload/include/fuse_provider.h
+++ b/fuse_sideload/include/fuse_provider.h
@@ -18,10 +18,13 @@
#include <stdint.h>
+#include <memory>
#include <string>
#include <android-base/unique_fd.h>
+#include "otautil/rangeset.h"
+
// This is the base class to read data from source and provide the data to FUSE.
class FuseDataProvider {
public:
@@ -70,3 +73,28 @@ class FuseFileDataProvider : public FuseDataProvider {
// The underlying source to read data from.
android::base::unique_fd fd_;
};
+
+// This class parses a block map and reads data from the underlying block device.
+class FuseBlockDataProvider : public FuseDataProvider {
+ public:
+ // Constructs the fuse provider from the block map.
+ static std::unique_ptr<FuseBlockDataProvider> CreateFromBlockMap(
+ const std::string& block_map_path, uint32_t fuse_block_size);
+
+ RangeSet ranges() const {
+ return ranges_;
+ }
+ bool ReadBlockAlignedData(uint8_t* buffer, uint32_t fetch_size,
+ uint32_t start_block) const override;
+ void Close() override;
+
+ private:
+ FuseBlockDataProvider(uint64_t file_size, uint32_t fuse_block_size, android::base::unique_fd&& fd,
+ uint32_t source_block_size, RangeSet ranges);
+ // The underlying block device to read data from.
+ android::base::unique_fd fd_;
+ // The block size of the source block device.
+ uint32_t source_block_size_;
+ // The block ranges from the source block device that consist of the file
+ RangeSet ranges_;
+};