Adding error for when overlayfs is enabled in OTA
when running adb remount, overlayfs is enabled on the device interfering
with OTA being able to run. Currently we don't have a good debug message
and users aren't able to realize why the OTA fails. Adding this log will
make it clear this behavior is intended, and we need verity-enabled for
OTA to work
Test: adb remount, update_device.py
Bug: 286889613
Change-Id: Ibcd27911afe6f02ddf0c38ad40904a7e17735b31
diff --git a/aosp/dynamic_partition_control_android.cc b/aosp/dynamic_partition_control_android.cc
index a309b6e..d8df520 100644
--- a/aosp/dynamic_partition_control_android.cc
+++ b/aosp/dynamic_partition_control_android.cc
@@ -48,6 +48,7 @@
#include "update_engine/aosp/dynamic_partition_utils.h"
#include "update_engine/common/boot_control_interface.h"
#include "update_engine/common/dynamic_partition_control_interface.h"
+#include "update_engine/common/error_code.h"
#include "update_engine/common/platform_constants.h"
#include "update_engine/common/utils.h"
#include "update_engine/payload_consumer/cow_writer_file_descriptor.h"
@@ -449,7 +450,8 @@
uint32_t target_slot,
const DeltaArchiveManifest& manifest,
bool update,
- uint64_t* required_size) {
+ uint64_t* required_size,
+ ErrorCode* error) {
source_slot_ = source_slot;
target_slot_ = target_slot;
if (required_size != nullptr) {
@@ -458,10 +460,14 @@
if (fs_mgr_overlayfs_is_setup()) {
// Non DAP devices can use overlayfs as well.
- LOG(WARNING)
+ LOG(ERROR)
<< "overlayfs overrides are active and can interfere with our "
"resources.\n"
<< "run adb enable-verity to deactivate if required and try again.";
+ if (error) {
+ *error = ErrorCode::kOverlayfsenabledError;
+ return false;
+ }
}
// If metadata is erased but not formatted, it is possible to not mount
@@ -852,6 +858,7 @@
auto target_device =
device_dir.Append(GetSuperPartitionName(target_slot)).value();
+
return StoreMetadata(target_device, builder.get(), target_slot);
}
diff --git a/aosp/dynamic_partition_control_android.h b/aosp/dynamic_partition_control_android.h
index 830901b..35a79fd 100644
--- a/aosp/dynamic_partition_control_android.h
+++ b/aosp/dynamic_partition_control_android.h
@@ -55,7 +55,8 @@
uint32_t target_slot,
const DeltaArchiveManifest& manifest,
bool update,
- uint64_t* required_size) override;
+ uint64_t* required_size,
+ ErrorCode* error = nullptr) override;
bool FinishUpdate(bool powerwash_required) override;
std::unique_ptr<AbstractAction> GetCleanupPreviousUpdateAction(
BootControlInterface* boot_control,
diff --git a/aosp/dynamic_partition_control_android_unittest.cc b/aosp/dynamic_partition_control_android_unittest.cc
index 6f1d4ef..30780f0 100644
--- a/aosp/dynamic_partition_control_android_unittest.cc
+++ b/aosp/dynamic_partition_control_android_unittest.cc
@@ -164,6 +164,7 @@
target(),
PartitionSizesToManifest(partition_sizes),
true,
+ nullptr,
nullptr);
}
void SetSlots(const TestParam& slots) { slots_ = slots; }
@@ -363,7 +364,7 @@
// DynamicPartitionControlAndroidTest::PreparePartitionsForUpdate(), since we
// don't want any default group in the PartitionMetadata.
EXPECT_TRUE(dynamicControl().PreparePartitionsForUpdate(
- source(), target(), {}, true, nullptr));
+ source(), target(), {}, true, nullptr, nullptr));
// Should use dynamic source partitions.
EXPECT_CALL(dynamicControl(), GetState(S("system")))
@@ -504,6 +505,7 @@
target(),
PartitionSizesToManifest({{"system", 2_GiB}, {"vendor", 1_GiB}}),
false,
+ nullptr,
nullptr));
// Dynamic partition "system".
@@ -759,6 +761,7 @@
target(),
PartitionSizesToManifest({{"foo", 4_MiB}}),
false,
+ nullptr,
nullptr));
dynamicControl().set_fake_mapped_devices({T("foo")});
@@ -1041,8 +1044,12 @@
}));
}
bool PreparePartitionsForUpdate(uint64_t* required_size) {
- return dynamicControl().PreparePartitionsForUpdate(
- source(), target(), manifest_, true /* update */, required_size);
+ return dynamicControl().PreparePartitionsForUpdate(source(),
+ target(),
+ manifest_,
+ true /* update */,
+ required_size,
+ nullptr);
}
MockSnapshotManager* snapshot_ = nullptr;
DeltaArchiveManifest manifest_;
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index 0c834ad..fcb142e 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -1218,12 +1218,23 @@
string payload_id = GetPayloadId(headers);
uint64_t required_size = 0;
+ ErrorCode error_code{};
+
if (!DeltaPerformer::PreparePartitionsForUpdate(prefs_,
boot_control_,
GetTargetSlot(),
manifest,
payload_id,
- &required_size)) {
+ &required_size,
+ &error_code)) {
+ if (error_code == ErrorCode::kOverlayfsenabledError) {
+ LogAndSetError(error,
+ __LINE__,
+ __FILE__,
+ "OverlayFS Shouldn't be enabled for OTA.",
+ error_code);
+ return 0;
+ }
if (required_size == 0) {
LogAndSetGenericError(
error, __LINE__, __FILE__, "Failed to allocate space for payload.");
@@ -1300,6 +1311,7 @@
std::make_unique<PostinstallRunnerAction>(boot_control_, hardware_);
SetStatusAndNotify(UpdateStatus::VERIFYING);
postinstall_runner_action->set_delegate(this);
+ ErrorCode error_code{};
// If last error code is kUpdatedButNotActive, we know that we reached this
// state by calling applyPayload() with switch_slot=false. That applyPayload()
@@ -1314,11 +1326,11 @@
GetTargetSlot(),
manifest,
false /* should update */,
- nullptr)) {
+ nullptr,
+ &error_code)) {
return LogAndSetGenericError(
error, __LINE__, __FILE__, "Failed to PreparePartitionsForUpdate");
}
- ErrorCode error_code{};
if (!install_plan_.ParsePartitions(manifest.partitions(),
boot_control_,
manifest.block_size(),