From a9665ced57ebd3f00f11cd8d9d99b33269687286 Mon Sep 17 00:00:00 2001 From: Alessio Balsini Date: Mon, 9 Dec 2019 09:26:05 +0000 Subject: Mount snapshotted /system in Virtual A/B devices Mounting /system in Virtual A/B devices may require the creation of the associated snapshot devices. This patch performs all the required initializations prior to attempting the mount of /system. Bug: 139157327 Test: manual /system partition mount on VAB device during OTA Depends-on: I7337bdd38d7016d12d3ee42be1c7893b10e9116d Change-Id: I71a9dfc57e1a1354f1f1edc5d287aca93c0c8924 Signed-off-by: Alessio Balsini --- install/snapshot_utils.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'install/snapshot_utils.cpp') diff --git a/install/snapshot_utils.cpp b/install/snapshot_utils.cpp index 69da5eea0..7235e67c8 100644 --- a/install/snapshot_utils.cpp +++ b/install/snapshot_utils.cpp @@ -15,6 +15,7 @@ * limitations under the License. */ +#include #include #include @@ -22,6 +23,7 @@ #include "recovery_ui/ui.h" #include "recovery_utils/roots.h" +using android::snapshot::CreateResult; using android::snapshot::SnapshotManager; bool FinishPendingSnapshotMerges(Device* device) { @@ -47,3 +49,26 @@ bool FinishPendingSnapshotMerges(Device* device) { } return true; } + +bool CreateSnapshotPartitions() { + if (!android::base::GetBoolProperty("ro.virtual_ab.enabled", false)) { + // If the device does not support Virtual A/B, there's no need to create + // snapshot devices. + return true; + } + + auto sm = SnapshotManager::NewForFirstStageMount(); + if (!sm) { + // SnapshotManager could not be created. The device is still in a + // consistent state and can continue with the mounting of the existing + // devices, but cannot initialize snapshot devices. + LOG(WARNING) << "Could not create SnapshotManager"; + return true; + } + + auto ret = sm->RecoveryCreateSnapshotDevices(); + if (ret == CreateResult::ERROR) { + return false; + } + return true; +} -- cgit v1.2.3