Merge "Fix device mapper name clashes on non-A/B devices."
am: 97d1fccd5b
Change-Id: Id47e289674eee3c17f0a267544e75cc48213fcb1
This commit is contained in:
commit
d7874a2fa9
4 changed files with 21 additions and 12 deletions
|
|
@ -1602,14 +1602,6 @@ bool fs_mgr_load_verity_state(int* mode) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string fs_mgr_get_verity_device_name(const FstabEntry& entry) {
|
|
||||||
if (entry.mount_point == "/") {
|
|
||||||
// In AVB, the dm device name is vroot instead of system.
|
|
||||||
return entry.fs_mgr_flags.avb ? "vroot" : "system";
|
|
||||||
}
|
|
||||||
return Basename(entry.mount_point);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool fs_mgr_is_verity_enabled(const FstabEntry& entry) {
|
bool fs_mgr_is_verity_enabled(const FstabEntry& entry) {
|
||||||
if (!entry.fs_mgr_flags.verify && !entry.fs_mgr_flags.avb) {
|
if (!entry.fs_mgr_flags.verify && !entry.fs_mgr_flags.avb) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1617,7 +1609,7 @@ bool fs_mgr_is_verity_enabled(const FstabEntry& entry) {
|
||||||
|
|
||||||
DeviceMapper& dm = DeviceMapper::Instance();
|
DeviceMapper& dm = DeviceMapper::Instance();
|
||||||
|
|
||||||
std::string mount_point = fs_mgr_get_verity_device_name(entry);
|
std::string mount_point = GetVerityDeviceName(entry);
|
||||||
if (dm.GetState(mount_point) == DmDeviceState::INVALID) {
|
if (dm.GetState(mount_point) == DmDeviceState::INVALID) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1646,7 +1638,7 @@ bool fs_mgr_verity_is_check_at_most_once(const android::fs_mgr::FstabEntry& entr
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceMapper& dm = DeviceMapper::Instance();
|
DeviceMapper& dm = DeviceMapper::Instance();
|
||||||
std::string device = fs_mgr_get_verity_device_name(entry);
|
std::string device = GetVerityDeviceName(entry);
|
||||||
|
|
||||||
std::vector<DeviceMapper::TargetInfo> table;
|
std::vector<DeviceMapper::TargetInfo> table;
|
||||||
if (dm.GetState(device) == DmDeviceState::INVALID || !dm.GetTableInfo(device, &table)) {
|
if (dm.GetState(device) == DmDeviceState::INVALID || !dm.GetTableInfo(device, &table)) {
|
||||||
|
|
|
||||||
|
|
@ -768,6 +768,17 @@ FstabEntry BuildGsiSystemFstabEntry() {
|
||||||
return system;
|
return system;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GetVerityDeviceName(const FstabEntry& entry) {
|
||||||
|
std::string base_device;
|
||||||
|
if (entry.mount_point == "/") {
|
||||||
|
// In AVB, the dm device name is vroot instead of system.
|
||||||
|
base_device = entry.fs_mgr_flags.avb ? "vroot" : "system";
|
||||||
|
} else {
|
||||||
|
base_device = android::base::Basename(entry.mount_point);
|
||||||
|
}
|
||||||
|
return base_device + "-verity";
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace fs_mgr
|
} // namespace fs_mgr
|
||||||
} // namespace android
|
} // namespace android
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,5 +107,10 @@ FstabEntry BuildGsiSystemFstabEntry();
|
||||||
|
|
||||||
std::set<std::string> GetBootDevices();
|
std::set<std::string> GetBootDevices();
|
||||||
|
|
||||||
|
// Return the name of the dm-verity device for the given fstab entry. This does
|
||||||
|
// not check whether the device is valid or exists; it merely returns the
|
||||||
|
// expected name.
|
||||||
|
std::string GetVerityDeviceName(const FstabEntry& entry);
|
||||||
|
|
||||||
} // namespace fs_mgr
|
} // namespace fs_mgr
|
||||||
} // namespace android
|
} // namespace android
|
||||||
|
|
|
||||||
|
|
@ -105,14 +105,15 @@ bool HashtreeDmVeritySetup(FstabEntry* fstab_entry, const FsAvbHashtreeDescripto
|
||||||
table.set_readonly(true);
|
table.set_readonly(true);
|
||||||
|
|
||||||
const std::string mount_point(Basename(fstab_entry->mount_point));
|
const std::string mount_point(Basename(fstab_entry->mount_point));
|
||||||
|
const std::string device_name(GetVerityDeviceName(*fstab_entry));
|
||||||
android::dm::DeviceMapper& dm = android::dm::DeviceMapper::Instance();
|
android::dm::DeviceMapper& dm = android::dm::DeviceMapper::Instance();
|
||||||
if (!dm.CreateDevice(mount_point, table)) {
|
if (!dm.CreateDevice(device_name, table)) {
|
||||||
LERROR << "Couldn't create verity device!";
|
LERROR << "Couldn't create verity device!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string dev_path;
|
std::string dev_path;
|
||||||
if (!dm.GetDmDevicePathByName(mount_point, &dev_path)) {
|
if (!dm.GetDmDevicePathByName(device_name, &dev_path)) {
|
||||||
LERROR << "Couldn't get verity device path!";
|
LERROR << "Couldn't get verity device path!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue