init: move "started at" environment var names to headers
Move "FIRST_STAGE_STARTED_AT" to env_first_stage_started_at variable in first_stage_init.h. Move "SELINUX_STARTED_AT" to env_selinux_started_at variable in selinux.h. Test: build Bug: 124491153 Bug: 129780532 Change-Id: I512d1835dcee5a3d034ac453b27b0709eed23cff
This commit is contained in:
parent
a6e6c7d966
commit
44505ecdd9
5 changed files with 11 additions and 8 deletions
|
@ -235,7 +235,7 @@ int FirstStageMain(int argc, char** argv) {
|
|||
|
||||
SetInitAvbVersionInRecovery();
|
||||
|
||||
setenv("FIRST_STAGE_STARTED_AT", std::to_string(start_time.time_since_epoch().count()).c_str(),
|
||||
setenv(kEnvFirstStageStartedAt, std::to_string(start_time.time_since_epoch().count()).c_str(),
|
||||
1);
|
||||
|
||||
const char* path = "/system/bin/init";
|
||||
|
|
|
@ -21,5 +21,7 @@ namespace init {
|
|||
|
||||
int FirstStageMain(int argc, char** argv);
|
||||
|
||||
static constexpr char kEnvFirstStageStartedAt[] = "FIRST_STAGE_STARTED_AT";
|
||||
|
||||
} // namespace init
|
||||
} // namespace android
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include "action_parser.h"
|
||||
#include "boringssl_self_test.h"
|
||||
#include "epoll.h"
|
||||
#include "first_stage_init.h"
|
||||
#include "first_stage_mount.h"
|
||||
#include "import_parser.h"
|
||||
#include "keychords.h"
|
||||
|
@ -630,20 +631,18 @@ static void UmountDebugRamdisk() {
|
|||
|
||||
static void RecordStageBoottimes(const boot_clock::time_point& second_stage_start_time) {
|
||||
int64_t first_stage_start_time_ns = -1;
|
||||
static constexpr char first_stage_started_at[] = "FIRST_STAGE_STARTED_AT";
|
||||
if (auto first_stage_start_time_str = getenv(first_stage_started_at);
|
||||
if (auto first_stage_start_time_str = getenv(kEnvFirstStageStartedAt);
|
||||
first_stage_start_time_str) {
|
||||
property_set("ro.boottime.init", first_stage_start_time_str);
|
||||
android::base::ParseInt(first_stage_start_time_str, &first_stage_start_time_ns);
|
||||
}
|
||||
unsetenv(first_stage_started_at);
|
||||
unsetenv(kEnvFirstStageStartedAt);
|
||||
|
||||
int64_t selinux_start_time_ns = -1;
|
||||
static constexpr char selinux_started_at[] = "SELINUX_STARTED_AT";
|
||||
if (auto selinux_start_time_str = getenv(selinux_started_at); selinux_start_time_str) {
|
||||
if (auto selinux_start_time_str = getenv(kEnvSelinuxStartedAt); selinux_start_time_str) {
|
||||
android::base::ParseInt(selinux_start_time_str, &selinux_start_time_ns);
|
||||
}
|
||||
unsetenv(selinux_started_at);
|
||||
unsetenv(kEnvSelinuxStartedAt);
|
||||
|
||||
if (selinux_start_time_ns == -1) return;
|
||||
if (first_stage_start_time_ns == -1) return;
|
||||
|
|
|
@ -544,7 +544,7 @@ int SetupSelinux(char** argv) {
|
|||
PLOG(FATAL) << "restorecon failed of /system/bin/init failed";
|
||||
}
|
||||
|
||||
setenv("SELINUX_STARTED_AT", std::to_string(start_time.time_since_epoch().count()).c_str(), 1);
|
||||
setenv(kEnvSelinuxStartedAt, std::to_string(start_time.time_since_epoch().count()).c_str(), 1);
|
||||
|
||||
const char* path = "/system/bin/init";
|
||||
const char* args[] = {path, "second_stage", nullptr};
|
||||
|
|
|
@ -35,6 +35,8 @@ bool SelabelLookupFileContextBestMatch(const std::string& key,
|
|||
const std::vector<std::string>& aliases, int type,
|
||||
std::string* result);
|
||||
|
||||
static constexpr char kEnvSelinuxStartedAt[] = "SELINUX_STARTED_AT";
|
||||
|
||||
} // namespace init
|
||||
} // namespace android
|
||||
|
||||
|
|
Loading…
Reference in a new issue