Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72fe2840 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "init: move "started at" environment var names to headers"

parents a6e6c7d9 44505ecd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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";
+2 −0
Original line number Diff line number Diff line
@@ -21,5 +21,7 @@ namespace init {

int FirstStageMain(int argc, char** argv);

static constexpr char kEnvFirstStageStartedAt[] = "FIRST_STAGE_STARTED_AT";

}  // namespace init
}  // namespace android
+5 −6
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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};
+2 −0
Original line number Diff line number Diff line
@@ -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