fs_mgr: support 'check_at_most_once' for dm-verity
Parse the hashtree descriptor of the AVB-protected partitions
and add 'check_at_most_once' option to dm-verity table.
Test: build & check dm-verity table
Test: atest --host libfs_avb_test
Test: atest --host libfs_avb_internal_test -- --test-arg \
com.android.tradefed.testtype.HostGTest:native-test-timeout:5m
Signed-off-by: JeongHyeon Lee <jhs2.lee@samsung.com>
Change-Id: I226a545aa95e07ebd7096dde18c357ac1ed1241c
diff --git a/fs_mgr/libdm/dm_target.cpp b/fs_mgr/libdm/dm_target.cpp
index b0639e6..90d91a0 100644
--- a/fs_mgr/libdm/dm_target.cpp
+++ b/fs_mgr/libdm/dm_target.cpp
@@ -109,6 +109,10 @@
optional_args_.emplace_back("ignore_zero_blocks");
}
+void DmTargetVerity::CheckAtMostOnce() {
+ optional_args_.emplace_back("check_at_most_once");
+}
+
std::string DmTargetVerity::GetParameterString() const {
std::string base = android::base::Join(base_args_, " ");
if (optional_args_.empty()) {
diff --git a/fs_mgr/libdm/include/libdm/dm_target.h b/fs_mgr/libdm/include/libdm/dm_target.h
index 478a3c6..9543058 100644
--- a/fs_mgr/libdm/include/libdm/dm_target.h
+++ b/fs_mgr/libdm/include/libdm/dm_target.h
@@ -127,6 +127,7 @@
void UseFec(const std::string& device, uint32_t num_roots, uint32_t num_blocks, uint32_t start);
void SetVerityMode(const std::string& mode);
void IgnoreZeroBlocks();
+ void CheckAtMostOnce();
std::string name() const override { return "verity"; }
std::string GetParameterString() const override;
diff --git a/fs_mgr/libfs_avb/avb_util.cpp b/fs_mgr/libfs_avb/avb_util.cpp
index 31494c1..e913d50 100644
--- a/fs_mgr/libfs_avb/avb_util.cpp
+++ b/fs_mgr/libfs_avb/avb_util.cpp
@@ -92,6 +92,10 @@
// Always use ignore_zero_blocks.
target.IgnoreZeroBlocks();
+ if (hashtree_desc.flags & AVB_HASHTREE_DESCRIPTOR_FLAGS_CHECK_AT_MOST_ONCE) {
+ target.CheckAtMostOnce();
+ }
+
LINFO << "Built verity table: '" << target.GetParameterString() << "'";
return table->AddTarget(std::make_unique<android::dm::DmTargetVerity>(target));