summaryrefslogtreecommitdiffstats
path: root/otautil/include
diff options
context:
space:
mode:
authorxunchang <xunchang@google.com>2019-03-22 17:33:49 +0100
committerxunchang <xunchang@google.com>2019-03-26 19:47:27 +0100
commit625c588c0f1a77bf632f56aa1cf92bb746f6f02a (patch)
tree303b8ebc0cdc324d4f8ecdd49249b2c2171c1f7b /otautil/include
parentMerge "Move librecovery_ui to a sub-directory" (diff)
downloadandroid_bootable_recovery-625c588c0f1a77bf632f56aa1cf92bb746f6f02a.tar
android_bootable_recovery-625c588c0f1a77bf632f56aa1cf92bb746f6f02a.tar.gz
android_bootable_recovery-625c588c0f1a77bf632f56aa1cf92bb746f6f02a.tar.bz2
android_bootable_recovery-625c588c0f1a77bf632f56aa1cf92bb746f6f02a.tar.lz
android_bootable_recovery-625c588c0f1a77bf632f56aa1cf92bb746f6f02a.tar.xz
android_bootable_recovery-625c588c0f1a77bf632f56aa1cf92bb746f6f02a.tar.zst
android_bootable_recovery-625c588c0f1a77bf632f56aa1cf92bb746f6f02a.zip
Diffstat (limited to 'otautil/include')
-rw-r--r--otautil/include/otautil/sysutil.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/otautil/include/otautil/sysutil.h b/otautil/include/otautil/sysutil.h
index 2eeb7c302..692a99e9d 100644
--- a/otautil/include/otautil/sysutil.h
+++ b/otautil/include/otautil/sysutil.h
@@ -22,6 +22,57 @@
#include <string>
#include <vector>
+#include "rangeset.h"
+
+// This class holds the content of a block map file.
+class BlockMapData {
+ public:
+ // A "block map" which looks like this (from uncrypt/uncrypt.cpp):
+ //
+ // /dev/block/platform/msm_sdcc.1/by-name/userdata # block device
+ // 49652 4096 # file size in bytes, block size
+ // 3 # count of block ranges
+ // 1000 1008 # block range 0
+ // 2100 2102 # ... block range 1
+ // 30 33 # ... block range 2
+ //
+ // Each block range represents a half-open interval; the line "30 33" reprents the blocks
+ // [30, 31, 32].
+ static BlockMapData ParseBlockMapFile(const std::string& block_map_path);
+
+ explicit operator bool() const {
+ return !path_.empty();
+ }
+
+ std::string path() const {
+ return path_;
+ }
+ uint64_t file_size() const {
+ return file_size_;
+ }
+ uint32_t block_size() const {
+ return block_size_;
+ }
+ RangeSet block_ranges() const {
+ return block_ranges_;
+ }
+
+ private:
+ BlockMapData() = default;
+
+ BlockMapData(const std::string& path, uint64_t file_size, uint32_t block_size,
+ RangeSet block_ranges)
+ : path_(path),
+ file_size_(file_size),
+ block_size_(block_size),
+ block_ranges_(std::move(block_ranges)) {}
+
+ std::string path_;
+ uint64_t file_size_ = 0;
+ uint32_t block_size_ = 0;
+ RangeSet block_ranges_;
+};
+
/*
* Use this to keep track of mapped segments.
*/