summaryrefslogtreecommitdiff
path: root/fastboot/device/variables.cpp
diff options
context:
space:
mode:
authorDavid Anderson <dvander@google.com>2018-11-09 20:41:33 -0800
committerDavid Anderson <dvander@google.com>2018-11-20 13:47:01 -0800
commitd25f1c377540ef4be3545b0e50e49be5df2ad09a (patch)
treee2b559e7d58382d2d2ee9e50fd7c4657371d508a /fastboot/device/variables.cpp
parenteb1213f1707bb6911fd4116d51e17f331abfaa90 (diff)
fastbootd: Support two super partitions for retrofit devices.
Retrofit devices will have two super partitions, spanning the A and B slots separately. By design an OTA will never cause "A" or "B" partitions to be assigned to the wrong super. However, the same is not true of fastbootd, where it is possible to flash the inactive slot. We do not want, for example, logical "system_a" flashing to super_b. When interacting with partitions, fastbootd now extracts the slot suffix from a GetSuperSlotSuffix() helper. On retrofit devices, if the partition name has a slot, that slot will override FastbootDevice::GetCurrentSlot. This forces partitions in the inactive slot to be assigned to the correct super. There are two consequences of this. First, partitions with no slot suffix will default to the current slot. That means it is possible to wind up with two "scratch" partitions, if "adb remount" is used on both the "A" and "B" slots. However, only the active slot's "scratch" will be visible to the user (either through adb or fastboot). Second, if one slot does not have dynamic partitions, flashing will default to fixed partitions. For example, if the A slot is logical and B is not, flashing "system_a" will be logical and "system_b" will be fixed. This works no matter which slot is active. We do not try to upgrade the inactive slot to dynamic partitions. Bug: 116802789 Test: fastboot set_active a fastboot flashall # dynamic partitions fastboot getvar is-logical:system_a # true fastboot getvar is-logical:system_b # false fastboot set_active b fastboot flashall --skip-secondary fastboot getvar is-logical:system_a # true fastboot getvar is-logical:system_b # true Booting both slots works. Change-Id: Ib3c91944aaee1a96b2f5ad69c90e215bd6c5a2e8
Diffstat (limited to 'fastboot/device/variables.cpp')
-rw-r--r--fastboot/device/variables.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp
index 601af3446..130a3cf34 100644
--- a/fastboot/device/variables.cpp
+++ b/fastboot/device/variables.cpp
@@ -271,8 +271,7 @@ bool GetHasSlot(FastbootDevice* device, const std::vector<std::string>& args,
return true;
}
std::string partition_name = args[0] + slot_suffix;
- if (FindPhysicalPartition(partition_name) ||
- LogicalPartitionExists(partition_name, slot_suffix)) {
+ if (FindPhysicalPartition(partition_name) || LogicalPartitionExists(device, partition_name)) {
*message = "yes";
} else {
*message = "no";
@@ -289,8 +288,7 @@ bool GetPartitionSize(FastbootDevice* device, const std::vector<std::string>& ar
// 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) {
+ if (LogicalPartitionExists(device, args[0], &is_zero_length) && is_zero_length) {
*message = "0x0";
return true;
}
@@ -313,8 +311,7 @@ bool GetPartitionType(FastbootDevice* device, const std::vector<std::string>& ar
}
std::string partition_name = args[0];
- if (!FindPhysicalPartition(partition_name) &&
- !LogicalPartitionExists(partition_name, device->GetCurrentSlot())) {
+ if (!FindPhysicalPartition(partition_name) && !LogicalPartitionExists(device, partition_name)) {
*message = "Invalid partition";
return false;
}
@@ -363,7 +360,7 @@ bool GetPartitionIsLogical(FastbootDevice* device, const std::vector<std::string
// return "true", to be consistent with prefering to flash logical partitions
// over physical ones.
std::string partition_name = args[0];
- if (LogicalPartitionExists(partition_name, device->GetCurrentSlot())) {
+ if (LogicalPartitionExists(device, partition_name)) {
*message = "yes";
return true;
}