fastbootd: Add support for flashing logical partitions.
When flashing logical partitions, we read the "super" partition metadata
corresponding to the current slot. We then temporarily create a
device-mapper device for that partition, and immediately destroy the
device after all operations are complete. We do not mount partitions
ahead of time, or keep them mounted, because a fastboot operation may
change the layout of the logical partition table (or change which slot
is current).
Bug: 78793464
Test: fastboot flash a logical partition under "super"
Change-Id: Id2a61d3592decabeebfd283c4fd6e6cbe576a18c
diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp
index 8f66fea..b51b985 100644
--- a/fastboot/device/variables.cpp
+++ b/fastboot/device/variables.cpp
@@ -133,6 +133,14 @@
if (args.size() < 1) {
return device->WriteFail("Missing argument");
}
+ // Zero-length partitions cannot be created through device-mapper, so we
+ // special case them here.
+ bool is_zero_length;
+ if (LogicalPartitionExists(args[0], device->GetCurrentSlot(), &is_zero_length) &&
+ is_zero_length) {
+ return device->WriteOkay("0");
+ }
+ // Otherwise, open the partition as normal.
PartitionHandle handle;
if (!OpenPartition(device, args[0], &handle)) {
return device->WriteFail("Could not open partition");