From 38a11ccdd183248b07c86b51791dc2dafba36738 Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Fri, 20 Jul 2018 15:18:04 -0700 Subject: [PATCH] init: rename init_first_stage In preparation for splitting first stage init from the rest of the init executable, rename these files which are specifically involved in first stage mount operations to a more appropriate name. Test: builds Change-Id: I8a2d4e8c7e1deea1bab45cc8e738727bc2ceb3e5 --- init/Android.bp | 2 +- ..._first_stage.cpp => first_stage_mount.cpp} | 27 ++++++++++--------- ...init_first_stage.h => first_stage_mount.h} | 5 +--- init/init.cpp | 2 +- 4 files changed, 17 insertions(+), 19 deletions(-) rename init/{init_first_stage.cpp => first_stage_mount.cpp} (95%) rename init/{init_first_stage.h => first_stage_mount.h} (92%) diff --git a/init/Android.bp b/init/Android.bp index 5bbb7a09c..d3305b903 100644 --- a/init/Android.bp +++ b/init/Android.bp @@ -104,9 +104,9 @@ cc_library_static { "devices.cpp", "epoll.cpp", "firmware_handler.cpp", + "first_stage_mount.cpp", "import_parser.cpp", "init.cpp", - "init_first_stage.cpp", "keychords.cpp", "log.cpp", "parser.cpp", diff --git a/init/init_first_stage.cpp b/init/first_stage_mount.cpp similarity index 95% rename from init/init_first_stage.cpp rename to init/first_stage_mount.cpp index 0ee020384..8ded87373 100644 --- a/init/init_first_stage.cpp +++ b/init/first_stage_mount.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "init_first_stage.h" +#include "first_stage_mount.h" #include #include @@ -125,11 +125,12 @@ static inline bool IsDmLinearEnabled() { if (checked) { return enabled; } - import_kernel_cmdline(false, [](const std::string& key, const std::string& value, bool in_qemu) { - if (key == "androidboot.logical_partitions" && value == "1") { - enabled = true; - } - }); + import_kernel_cmdline(false, + [](const std::string& key, const std::string& value, bool in_qemu) { + if (key == "androidboot.logical_partitions" && value == "1") { + enabled = true; + } + }); checked = true; return enabled; } @@ -149,9 +150,9 @@ FirstStageMount::FirstStageMount() } auto boot_devices = fs_mgr_get_boot_devices(); - device_handler_ = - std::make_unique(std::vector{}, std::vector{}, - std::vector{}, std::move(boot_devices), false); + device_handler_ = std::make_unique( + std::vector{}, std::vector{}, std::vector{}, + std::move(boot_devices), false); } std::unique_ptr FirstStageMount::Create() { @@ -484,7 +485,7 @@ ListenerAction FirstStageMountVBootV2::UeventCallback(const Uevent& uevent) { // as it finds them, so this must happen first. if (!uevent.partition_name.empty() && required_devices_partition_names_.find(uevent.partition_name) != - required_devices_partition_names_.end()) { + required_devices_partition_names_.end()) { // GetBlockDeviceSymlinks() will return three symlinks at most, depending on // the content of uevent. by-name symlink will be at [0] if uevent->partition_name // is not empty. e.g., @@ -492,7 +493,7 @@ ListenerAction FirstStageMountVBootV2::UeventCallback(const Uevent& uevent) { // - /dev/block/platform/soc.0/f9824900.sdhci/mmcblk0p1 std::vector links = device_handler_->GetBlockDeviceSymlinks(uevent); if (!links.empty()) { - auto[it, inserted] = by_name_symlink_map_.emplace(uevent.partition_name, links[0]); + auto [it, inserted] = by_name_symlink_map_.emplace(uevent.partition_name, links[0]); if (!inserted) { LOG(ERROR) << "Partition '" << uevent.partition_name << "' already existed in the by-name symlink map with a value of '" @@ -508,7 +509,7 @@ bool FirstStageMountVBootV2::SetUpDmVerity(fstab_rec* fstab_rec) { if (fs_mgr_is_avb(fstab_rec)) { if (!InitAvbHandle()) return false; SetUpAvbHashtreeResult hashtree_result = - avb_handle_->SetUpAvbHashtree(fstab_rec, false /* wait_for_verity_dev */); + avb_handle_->SetUpAvbHashtree(fstab_rec, false /* wait_for_verity_dev */); switch (hashtree_result) { case SetUpAvbHashtreeResult::kDisabled: return true; // Returns true to mount the partition. @@ -585,7 +586,7 @@ void SetInitAvbVersionInRecovery() { } FsManagerAvbUniquePtr avb_handle = - FsManagerAvbHandle::Open(std::move(avb_first_mount.by_name_symlink_map_)); + FsManagerAvbHandle::Open(std::move(avb_first_mount.by_name_symlink_map_)); if (!avb_handle) { PLOG(ERROR) << "Failed to open FsManagerAvbHandle for INIT_AVB_VERSION"; return; diff --git a/init/init_first_stage.h b/init/first_stage_mount.h similarity index 92% rename from init/init_first_stage.h rename to init/first_stage_mount.h index c7a386718..21d87fd48 100644 --- a/init/init_first_stage.h +++ b/init/first_stage_mount.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef _INIT_FIRST_STAGE_H -#define _INIT_FIRST_STAGE_H +#pragma once namespace android { namespace init { @@ -25,5 +24,3 @@ void SetInitAvbVersionInRecovery(); } // namespace init } // namespace android - -#endif diff --git a/init/init.cpp b/init/init.cpp index 686cd6ed9..5352450b0 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -48,8 +48,8 @@ #include "action_parser.h" #include "epoll.h" +#include "first_stage_mount.h" #include "import_parser.h" -#include "init_first_stage.h" #include "keychords.h" #include "log.h" #include "property_service.h"