Merge changes I819eb60a,I48a52aa0,Iab04742c into main
* changes: init: Reorder GetBlockDeviceSymlinks() so FindDmDevice() is first init: Add partition_uuid to Uevent fs_mgr: Add getter for androidboot.boot_part_uuid
This commit is contained in:
commit
5d5906fb02
5 changed files with 38 additions and 8 deletions
|
|
@ -950,6 +950,22 @@ std::set<std::string> GetBootDevices() {
|
|||
return ExtraBootDevices(fstab);
|
||||
}
|
||||
|
||||
std::string GetBootPartUuid() {
|
||||
std::string boot_part_uuid;
|
||||
|
||||
if (GetBootconfig("androidboot.boot_part_uuid", &boot_part_uuid)) {
|
||||
return boot_part_uuid;
|
||||
}
|
||||
|
||||
ImportKernelCmdline([&](std::string key, std::string value) {
|
||||
if (key == "androidboot.boot_part_uuid") {
|
||||
boot_part_uuid = value;
|
||||
}
|
||||
});
|
||||
|
||||
return boot_part_uuid;
|
||||
}
|
||||
|
||||
std::string GetVerityDeviceName(const FstabEntry& entry) {
|
||||
std::string base_device;
|
||||
if (entry.mount_point == "/") {
|
||||
|
|
|
|||
|
|
@ -126,6 +126,16 @@ void TransformFstabForDsu(Fstab* fstab, const std::string& dsu_slot,
|
|||
|
||||
std::set<std::string> GetBootDevices();
|
||||
|
||||
// Get the Partition UUID the kernel loaded from if the bootloader passed it.
|
||||
//
|
||||
// If the kernel's Partition UUID is provided then we can use this to help
|
||||
// identify which block device contains the filesystems we care about.
|
||||
//
|
||||
// NOTE: Nothing secures a UUID other than the convention that two disks
|
||||
// aren't supposed to both have the same UUID. We still need other mechanisms
|
||||
// to ensure we've got the right disk.
|
||||
std::string GetBootPartUuid();
|
||||
|
||||
// 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.
|
||||
|
|
|
|||
|
|
@ -376,7 +376,13 @@ std::vector<std::string> DeviceHandler::GetBlockDeviceSymlinks(const Uevent& uev
|
|||
std::string partition;
|
||||
std::string uuid;
|
||||
|
||||
if (FindPlatformDevice(uevent.path, &device)) {
|
||||
if (FindDmDevice(uevent, &partition, &uuid)) {
|
||||
std::vector<std::string> symlinks = {"/dev/block/mapper/" + partition};
|
||||
if (!uuid.empty()) {
|
||||
symlinks.emplace_back("/dev/block/mapper/by-uuid/" + uuid);
|
||||
}
|
||||
return symlinks;
|
||||
} else if (FindPlatformDevice(uevent.path, &device)) {
|
||||
// Skip /devices/platform or /devices/ if present
|
||||
static constexpr std::string_view devices_platform_prefix = "/devices/platform/";
|
||||
static constexpr std::string_view devices_prefix = "/devices/";
|
||||
|
|
@ -392,12 +398,6 @@ std::vector<std::string> DeviceHandler::GetBlockDeviceSymlinks(const Uevent& uev
|
|||
type = "pci";
|
||||
} else if (FindVbdDevicePrefix(uevent.path, &device)) {
|
||||
type = "vbd";
|
||||
} else if (FindDmDevice(uevent, &partition, &uuid)) {
|
||||
std::vector<std::string> symlinks = {"/dev/block/mapper/" + partition};
|
||||
if (!uuid.empty()) {
|
||||
symlinks.emplace_back("/dev/block/mapper/by-uuid/" + uuid);
|
||||
}
|
||||
return symlinks;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ struct Uevent {
|
|||
std::string subsystem;
|
||||
std::string firmware;
|
||||
std::string partition_name;
|
||||
std::string partition_uuid;
|
||||
std::string device_name;
|
||||
std::string modalias;
|
||||
int partition_num;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ static void ParseEvent(const char* msg, Uevent* uevent) {
|
|||
} else if (!strncmp(msg, "PARTNAME=", 9)) {
|
||||
msg += 9;
|
||||
uevent->partition_name = msg;
|
||||
} else if (!strncmp(msg, "PARTUUID=", 9)) {
|
||||
msg += 9;
|
||||
uevent->partition_uuid = msg;
|
||||
} else if (!strncmp(msg, "DEVNAME=", 8)) {
|
||||
msg += 8;
|
||||
uevent->device_name = msg;
|
||||
|
|
@ -82,7 +85,7 @@ static void ParseEvent(const char* msg, Uevent* uevent) {
|
|||
if (LOG_UEVENTS) {
|
||||
LOG(INFO) << "event { '" << uevent->action << "', '" << uevent->path << "', '"
|
||||
<< uevent->subsystem << "', '" << uevent->firmware << "', " << uevent->major
|
||||
<< ", " << uevent->minor << " }";
|
||||
<< ", " << uevent->minor << ", " << uevent->partition_uuid << " }";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue