Loading init/init.cpp +2 −18 Original line number Diff line number Diff line Loading @@ -581,23 +581,6 @@ static void InitAborter(const char* abort_message) { RebootSystem(ANDROID_RB_RESTART2, "bootloader"); } static void InitKernelLogging(char* argv[]) { // Make stdin/stdout/stderr all point to /dev/null. int fd = open("/sys/fs/selinux/null", O_RDWR); if (fd == -1) { int saved_errno = errno; android::base::InitLogging(argv, &android::base::KernelLogger, InitAborter); errno = saved_errno; PLOG(FATAL) << "Couldn't open /sys/fs/selinux/null"; } dup2(fd, 0); dup2(fd, 1); dup2(fd, 2); if (fd > 2) close(fd); android::base::InitLogging(argv, &android::base::KernelLogger, InitAborter); } static void GlobalSeccomp() { import_kernel_cmdline(false, [](const std::string& key, const std::string& value, bool in_qemu) { Loading Loading @@ -654,7 +637,8 @@ int main(int argc, char** argv) { SetupSelinux(argv); } InitKernelLogging(argv); // We need to set up stdin/stdout/stderr again now that we're running in init's context. InitKernelLogging(argv, InitAborter); LOG(INFO) << "init second stage started!"; // Enable seccomp if global boot option was passed (otherwise it is enabled in zygote). Loading init/init_first_stage.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -102,9 +102,11 @@ int main(int argc, char** argv) { // Now that tmpfs is mounted on /dev and we have /dev/kmsg, we can actually // talk to the outside world... android::base::InitLogging(argv, &android::base::KernelLogger, [](const char*) { RebootSystem(ANDROID_RB_RESTART2, "bootloader"); }); // We need to set up stdin/stdout/stderr for child processes forked from first // stage init as part of the mount process. This closes /dev/console if the // kernel had previously opened it. auto reboot_bootloader = [](const char*) { RebootSystem(ANDROID_RB_RESTART2, "bootloader"); }; InitKernelLogging(argv, reboot_bootloader); if (!errors.empty()) { for (const auto& [error_string, error_errno] : errors) { Loading init/util.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -436,5 +436,21 @@ bool IsLegalPropertyName(const std::string& name) { return true; } void InitKernelLogging(char** argv, std::function<void(const char*)> abort_function) { // Make stdin/stdout/stderr all point to /dev/null. int fd = open("/dev/null", O_RDWR); if (fd == -1) { int saved_errno = errno; android::base::InitLogging(argv, &android::base::KernelLogger, std::move(abort_function)); errno = saved_errno; PLOG(FATAL) << "Couldn't open /dev/null"; } dup2(fd, 0); dup2(fd, 1); dup2(fd, 2); if (fd > 2) close(fd); android::base::InitLogging(argv, &android::base::KernelLogger, std::move(abort_function)); } } // namespace init } // namespace android init/util.h +2 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,8 @@ bool is_android_dt_value_expected(const std::string& sub_path, const std::string bool IsLegalPropertyName(const std::string& name); void InitKernelLogging(char** argv, std::function<void(const char*)> abort_function); } // namespace init } // namespace android Loading Loading
init/init.cpp +2 −18 Original line number Diff line number Diff line Loading @@ -581,23 +581,6 @@ static void InitAborter(const char* abort_message) { RebootSystem(ANDROID_RB_RESTART2, "bootloader"); } static void InitKernelLogging(char* argv[]) { // Make stdin/stdout/stderr all point to /dev/null. int fd = open("/sys/fs/selinux/null", O_RDWR); if (fd == -1) { int saved_errno = errno; android::base::InitLogging(argv, &android::base::KernelLogger, InitAborter); errno = saved_errno; PLOG(FATAL) << "Couldn't open /sys/fs/selinux/null"; } dup2(fd, 0); dup2(fd, 1); dup2(fd, 2); if (fd > 2) close(fd); android::base::InitLogging(argv, &android::base::KernelLogger, InitAborter); } static void GlobalSeccomp() { import_kernel_cmdline(false, [](const std::string& key, const std::string& value, bool in_qemu) { Loading Loading @@ -654,7 +637,8 @@ int main(int argc, char** argv) { SetupSelinux(argv); } InitKernelLogging(argv); // We need to set up stdin/stdout/stderr again now that we're running in init's context. InitKernelLogging(argv, InitAborter); LOG(INFO) << "init second stage started!"; // Enable seccomp if global boot option was passed (otherwise it is enabled in zygote). Loading
init/init_first_stage.cpp +5 −3 Original line number Diff line number Diff line Loading @@ -102,9 +102,11 @@ int main(int argc, char** argv) { // Now that tmpfs is mounted on /dev and we have /dev/kmsg, we can actually // talk to the outside world... android::base::InitLogging(argv, &android::base::KernelLogger, [](const char*) { RebootSystem(ANDROID_RB_RESTART2, "bootloader"); }); // We need to set up stdin/stdout/stderr for child processes forked from first // stage init as part of the mount process. This closes /dev/console if the // kernel had previously opened it. auto reboot_bootloader = [](const char*) { RebootSystem(ANDROID_RB_RESTART2, "bootloader"); }; InitKernelLogging(argv, reboot_bootloader); if (!errors.empty()) { for (const auto& [error_string, error_errno] : errors) { Loading
init/util.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -436,5 +436,21 @@ bool IsLegalPropertyName(const std::string& name) { return true; } void InitKernelLogging(char** argv, std::function<void(const char*)> abort_function) { // Make stdin/stdout/stderr all point to /dev/null. int fd = open("/dev/null", O_RDWR); if (fd == -1) { int saved_errno = errno; android::base::InitLogging(argv, &android::base::KernelLogger, std::move(abort_function)); errno = saved_errno; PLOG(FATAL) << "Couldn't open /dev/null"; } dup2(fd, 0); dup2(fd, 1); dup2(fd, 2); if (fd > 2) close(fd); android::base::InitLogging(argv, &android::base::KernelLogger, std::move(abort_function)); } } // namespace init } // namespace android
init/util.h +2 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,8 @@ bool is_android_dt_value_expected(const std::string& sub_path, const std::string bool IsLegalPropertyName(const std::string& name); void InitKernelLogging(char** argv, std::function<void(const char*)> abort_function); } // namespace init } // namespace android Loading