diff options
author | David Anderson <dvander@google.com> | 2018-06-25 17:55:01 -0700 |
---|---|---|
committer | David Anderson <dvander@google.com> | 2018-06-27 12:48:28 -0700 |
commit | 40b594827fb895dd603f449eaea27dca0ee05874 (patch) | |
tree | 4fb8b8eeaed609aa8f8739c225ce770a17ec053c /fs_mgr/libdm/dm_test.cpp | |
parent | 6effd4d6a36c5188d05cd43410e8903156431106 (diff) | |
download | system_core-40b594827fb895dd603f449eaea27dca0ee05874.tar.gz system_core-40b594827fb895dd603f449eaea27dca0ee05874.tar.bz2 system_core-40b594827fb895dd603f449eaea27dca0ee05874.zip |
fs_mgr: replace DM_TABLE_STATUS use with libdm.
This change introduces a new GetTableStatus method on DeviceMapper,
which returns a vector of information about each target in a device's
table. Some target types (such as verity) can also return additional
information as a string.
Support for this call has also been added to the "dmctl" tool via a
"table" command. Examples:
$ dmctl create blah zero 0 8000 linear 8000 1000 /dev/block/sdd1 0
$ dmctl table blah
Targets in the device-mapper table for blah:
0-8000: zero
8000-9000: linear
For verity:
sailfish:/ # dmctl table system
Targets in the device-mapper table for system:
0-4128792: android-verity, V
Bug: 110035986
Test: libdm_test gtest; AVB1 device still boots
Change-Id: Iaf13450d3b32e2264c7c399a8af8d6bade260592
Diffstat (limited to 'fs_mgr/libdm/dm_test.cpp')
-rw-r--r-- | fs_mgr/libdm/dm_test.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fs_mgr/libdm/dm_test.cpp b/fs_mgr/libdm/dm_test.cpp index 85f8e4a4e..cc6191753 100644 --- a/fs_mgr/libdm/dm_test.cpp +++ b/fs_mgr/libdm/dm_test.cpp @@ -160,6 +160,20 @@ TEST(libdm, DmLinear) { ASSERT_EQ(strncmp(sector, message2, sizeof(message2)), 0); } + // Test GetTableStatus. + DeviceMapper& dm = DeviceMapper::Instance(); + vector<DeviceMapper::TargetInfo> targets; + ASSERT_TRUE(dm.GetTableStatus(dev.name(), &targets)); + ASSERT_EQ(targets.size(), 2); + EXPECT_EQ(strcmp(targets[0].spec.target_type, "linear"), 0); + EXPECT_TRUE(targets[0].data.empty()); + EXPECT_EQ(targets[0].spec.sector_start, 0); + EXPECT_EQ(targets[0].spec.length, 1); + EXPECT_EQ(strcmp(targets[1].spec.target_type, "linear"), 0); + EXPECT_TRUE(targets[1].data.empty()); + EXPECT_EQ(targets[1].spec.sector_start, 1); + EXPECT_EQ(targets[1].spec.length, 1); + // Normally the TestDevice destructor would delete this, but at least one // test should ensure that device deletion works. ASSERT_TRUE(dev.Destroy()); |