From 519d3f8b368ae87d12814480066a8eb3c8f63216 Mon Sep 17 00:00:00 2001 From: Douglas Anderson Date: Wed, 16 Oct 2024 09:23:06 -0700 Subject: [PATCH] fs_mgr: Add getter for androidboot.boot_part_uuid In order to make booting from some media types (like USB) more robust, the bootloader will be extended to support passing the partition UUID that it loaded the kernel from. It can pass this via kernel commandline or via bootconfig. Add a way to get this. Bug: 316324155 Test: Use the getter in a future change Change-Id: Iab04742c0f2666db18dc48bcaaa2869eba405748 --- fs_mgr/libfstab/fstab.cpp | 16 ++++++++++++++++ fs_mgr/libfstab/include/fstab/fstab.h | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/fs_mgr/libfstab/fstab.cpp b/fs_mgr/libfstab/fstab.cpp index 6e4cae18f..43547eaf4 100644 --- a/fs_mgr/libfstab/fstab.cpp +++ b/fs_mgr/libfstab/fstab.cpp @@ -950,6 +950,22 @@ std::set 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 == "/") { diff --git a/fs_mgr/libfstab/include/fstab/fstab.h b/fs_mgr/libfstab/include/fstab/fstab.h index 070dd9178..0ff3188d4 100644 --- a/fs_mgr/libfstab/include/fstab/fstab.h +++ b/fs_mgr/libfstab/include/fstab/fstab.h @@ -126,6 +126,16 @@ void TransformFstabForDsu(Fstab* fstab, const std::string& dsu_slot, std::set 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.