From ec799183c8be97835a62339ef25e10c5c63f6f62 Mon Sep 17 00:00:00 2001 From: Akilesh Kailash Date: Thu, 28 Mar 2024 09:51:52 -0700 Subject: [PATCH] init: Remove legacy virtual-ab support Bug: 304829384 Test: OTA on Pixel Change-Id: I8463a1cc102379daa41fdade6820222a5e3bdd86 Signed-off-by: Akilesh Kailash --- init/first_stage_mount.cpp | 5 +++-- init/snapuserd_transition.cpp | 23 +++++++---------------- init/snapuserd_transition.h | 7 +------ 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/init/first_stage_mount.cpp b/init/first_stage_mount.cpp index 836d536c9..ae216c664 100644 --- a/init/first_stage_mount.cpp +++ b/init/first_stage_mount.cpp @@ -396,9 +396,10 @@ bool FirstStageMountVBootV2::CreateSnapshotPartitions(SnapshotManager* sm) { use_snapuserd_ = sm->IsSnapuserdRequired(); if (use_snapuserd_) { if (sm->UpdateUsesUserSnapshots()) { - LaunchFirstStageSnapuserd(SnapshotDriver::DM_USER); + LaunchFirstStageSnapuserd(); } else { - LaunchFirstStageSnapuserd(SnapshotDriver::DM_SNAPSHOT); + LOG(FATAL) << "legacy virtual-ab is no longer supported"; + return false; } } diff --git a/init/snapuserd_transition.cpp b/init/snapuserd_transition.cpp index dea7af97b..9e3ff4175 100644 --- a/init/snapuserd_transition.cpp +++ b/init/snapuserd_transition.cpp @@ -62,7 +62,7 @@ static constexpr char kSnapuserdFirstStageInfoVar[] = "FIRST_STAGE_SNAPUSERD_INF static constexpr char kSnapuserdLabel[] = "u:object_r:snapuserd_exec:s0"; static constexpr char kSnapuserdSocketLabel[] = "u:object_r:snapuserd_socket:s0"; -void LaunchFirstStageSnapuserd(SnapshotDriver driver) { +void LaunchFirstStageSnapuserd() { SocketDescriptor socket_desc; socket_desc.name = android::snapshot::kSnapuserdSocket; socket_desc.type = SOCK_STREAM; @@ -85,22 +85,13 @@ void LaunchFirstStageSnapuserd(SnapshotDriver driver) { if (pid == 0) { socket->Publish(); - if (driver == SnapshotDriver::DM_USER) { - char arg0[] = "/system/bin/snapuserd"; - char arg1[] = "-user_snapshot"; - char* const argv[] = {arg0, arg1, nullptr}; - if (execv(arg0, argv) < 0) { - PLOG(FATAL) << "Cannot launch snapuserd; execv failed"; - } - _exit(127); - } else { - char arg0[] = "/system/bin/snapuserd"; - char* const argv[] = {arg0, nullptr}; - if (execv(arg0, argv) < 0) { - PLOG(FATAL) << "Cannot launch snapuserd; execv failed"; - } - _exit(127); + char arg0[] = "/system/bin/snapuserd"; + char arg1[] = "-user_snapshot"; + char* const argv[] = {arg0, arg1, nullptr}; + if (execv(arg0, argv) < 0) { + PLOG(FATAL) << "Cannot launch snapuserd; execv failed"; } + _exit(127); } auto client = SnapuserdClient::Connect(android::snapshot::kSnapuserdSocket, 10s); diff --git a/init/snapuserd_transition.h b/init/snapuserd_transition.h index 557d10587..e86e8daa1 100644 --- a/init/snapuserd_transition.h +++ b/init/snapuserd_transition.h @@ -29,13 +29,8 @@ namespace android { namespace init { -enum class SnapshotDriver { - DM_SNAPSHOT, - DM_USER, -}; - // Fork and exec a new copy of snapuserd. -void LaunchFirstStageSnapuserd(SnapshotDriver driver); +void LaunchFirstStageSnapuserd(); class SnapuserdSelinuxHelper final { using SnapshotManager = android::snapshot::SnapshotManager;