summaryrefslogtreecommitdiffstats
path: root/fuse_sideload/include/fuse_provider.h
diff options
context:
space:
mode:
Diffstat (limited to 'fuse_sideload/include/fuse_provider.h')
-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_;
+};