system/core
Révision | 7f724ad4e9f946a38ac737fc4794b212e5e4f6dc (tree) |
---|---|
l'heure | 2019-04-03 06:08:25 |
Auteur | David Anderson <dvander@goog...> |
Commiter | android-build-merger |
Merge "Fix device mapper name clashes on non-A/B devices." am: 97d1fccd5b
am: d7874a2fa9
Change-Id: I5ea972dd4e28dc476a49ac623fd03004c4a21ee1
@@ -1602,14 +1602,6 @@ bool fs_mgr_load_verity_state(int* mode) { | ||
1602 | 1602 | return true; |
1603 | 1603 | } |
1604 | 1604 | |
1605 | -std::string fs_mgr_get_verity_device_name(const FstabEntry& entry) { | |
1606 | - if (entry.mount_point == "/") { | |
1607 | - // In AVB, the dm device name is vroot instead of system. | |
1608 | - return entry.fs_mgr_flags.avb ? "vroot" : "system"; | |
1609 | - } | |
1610 | - return Basename(entry.mount_point); | |
1611 | -} | |
1612 | - | |
1613 | 1605 | bool fs_mgr_is_verity_enabled(const FstabEntry& entry) { |
1614 | 1606 | if (!entry.fs_mgr_flags.verify && !entry.fs_mgr_flags.avb) { |
1615 | 1607 | return false; |
@@ -1617,7 +1609,7 @@ bool fs_mgr_is_verity_enabled(const FstabEntry& entry) { | ||
1617 | 1609 | |
1618 | 1610 | DeviceMapper& dm = DeviceMapper::Instance(); |
1619 | 1611 | |
1620 | - std::string mount_point = fs_mgr_get_verity_device_name(entry); | |
1612 | + std::string mount_point = GetVerityDeviceName(entry); | |
1621 | 1613 | if (dm.GetState(mount_point) == DmDeviceState::INVALID) { |
1622 | 1614 | return false; |
1623 | 1615 | } |
@@ -1646,7 +1638,7 @@ bool fs_mgr_verity_is_check_at_most_once(const android::fs_mgr::FstabEntry& entr | ||
1646 | 1638 | } |
1647 | 1639 | |
1648 | 1640 | DeviceMapper& dm = DeviceMapper::Instance(); |
1649 | - std::string device = fs_mgr_get_verity_device_name(entry); | |
1641 | + std::string device = GetVerityDeviceName(entry); | |
1650 | 1642 | |
1651 | 1643 | std::vector<DeviceMapper::TargetInfo> table; |
1652 | 1644 | if (dm.GetState(device) == DmDeviceState::INVALID || !dm.GetTableInfo(device, &table)) { |
@@ -768,6 +768,17 @@ FstabEntry BuildGsiSystemFstabEntry() { | ||
768 | 768 | return system; |
769 | 769 | } |
770 | 770 | |
771 | +std::string GetVerityDeviceName(const FstabEntry& entry) { | |
772 | + std::string base_device; | |
773 | + if (entry.mount_point == "/") { | |
774 | + // In AVB, the dm device name is vroot instead of system. | |
775 | + base_device = entry.fs_mgr_flags.avb ? "vroot" : "system"; | |
776 | + } else { | |
777 | + base_device = android::base::Basename(entry.mount_point); | |
778 | + } | |
779 | + return base_device + "-verity"; | |
780 | +} | |
781 | + | |
771 | 782 | } // namespace fs_mgr |
772 | 783 | } // namespace android |
773 | 784 |
@@ -107,5 +107,10 @@ FstabEntry BuildGsiSystemFstabEntry(); | ||
107 | 107 | |
108 | 108 | std::set<std::string> GetBootDevices(); |
109 | 109 | |
110 | +// Return the name of the dm-verity device for the given fstab entry. This does | |
111 | +// not check whether the device is valid or exists; it merely returns the | |
112 | +// expected name. | |
113 | +std::string GetVerityDeviceName(const FstabEntry& entry); | |
114 | + | |
110 | 115 | } // namespace fs_mgr |
111 | 116 | } // namespace android |
@@ -105,14 +105,15 @@ bool HashtreeDmVeritySetup(FstabEntry* fstab_entry, const FsAvbHashtreeDescripto | ||
105 | 105 | table.set_readonly(true); |
106 | 106 | |
107 | 107 | const std::string mount_point(Basename(fstab_entry->mount_point)); |
108 | + const std::string device_name(GetVerityDeviceName(*fstab_entry)); | |
108 | 109 | android::dm::DeviceMapper& dm = android::dm::DeviceMapper::Instance(); |
109 | - if (!dm.CreateDevice(mount_point, table)) { | |
110 | + if (!dm.CreateDevice(device_name, table)) { | |
110 | 111 | LERROR << "Couldn't create verity device!"; |
111 | 112 | return false; |
112 | 113 | } |
113 | 114 | |
114 | 115 | std::string dev_path; |
115 | - if (!dm.GetDmDevicePathByName(mount_point, &dev_path)) { | |
116 | + if (!dm.GetDmDevicePathByName(device_name, &dev_path)) { | |
116 | 117 | LERROR << "Couldn't get verity device path!"; |
117 | 118 | return false; |
118 | 119 | } |