Loading init/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -68,6 +68,7 @@ cc_defaults { "libpropertyinfoparser", "libpropertyinfoparser", ], ], shared_libs: [ shared_libs: [ "libbacktrace", "libbase", "libbase", "libbinder", "libbinder", "libbootloader_message", "libbootloader_message", Loading init/Android.mk +4 −0 Original line number Original line Diff line number Diff line Loading @@ -105,6 +105,10 @@ LOCAL_STATIC_LIBRARIES := \ libcap \ libcap \ libgsi \ libgsi \ libcom.android.sysprop.apex \ libcom.android.sysprop.apex \ liblzma \ libdexfile_support \ libunwindstack \ libbacktrace \ LOCAL_SANITIZE := signed-integer-overflow LOCAL_SANITIZE := signed-integer-overflow # First stage init is weird: it may start without stdout/stderr, and no /proc. # First stage init is weird: it may start without stdout/stderr, and no /proc. Loading init/first_stage_init.cpp +2 −6 Original line number Original line Diff line number Diff line Loading @@ -33,7 +33,6 @@ #include <android-base/chrono_utils.h> #include <android-base/chrono_utils.h> #include <android-base/file.h> #include <android-base/file.h> #include <android-base/logging.h> #include <android-base/logging.h> #include <cutils/android_reboot.h> #include <private/android_filesystem_config.h> #include <private/android_filesystem_config.h> #include "debug_ramdisk.h" #include "debug_ramdisk.h" Loading Loading @@ -168,13 +167,10 @@ int FirstStageMain(int argc, char** argv) { "mode=0755,uid=0,gid=0")); "mode=0755,uid=0,gid=0")); #undef CHECKCALL #undef CHECKCALL SetStdioToDevNull(argv); // Now that tmpfs is mounted on /dev and we have /dev/kmsg, we can actually // Now that tmpfs is mounted on /dev and we have /dev/kmsg, we can actually // talk to the outside world... // talk to the outside world... // We need to set up stdin/stdout/stderr for child processes forked from first InitKernelLogging(argv); // 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()) { if (!errors.empty()) { for (const auto& [error_string, error_errno] : errors) { for (const auto& [error_string, error_errno] : errors) { Loading init/host_init_stubs.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,12 @@ extern uint32_t (*property_set)(const std::string& name, const std::string& valu uint32_t HandlePropertySet(const std::string& name, const std::string& value, uint32_t HandlePropertySet(const std::string& name, const std::string& value, const std::string& source_context, const ucred& cr, std::string* error); const std::string& source_context, const ucred& cr, std::string* error); // reboot_utils.h inline void SetFatalRebootTarget() {} inline void __attribute__((noreturn)) InitFatalReboot() { abort(); } // selinux.h // selinux.h int SelinuxGetVendorAndroidVersion(); int SelinuxGetVendorAndroidVersion(); void SelabelInitialize(); void SelabelInitialize(); Loading init/init.cpp +2 −14 Original line number Original line Diff line number Diff line Loading @@ -38,7 +38,6 @@ #include <android-base/properties.h> #include <android-base/properties.h> #include <android-base/stringprintf.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/strings.h> #include <cutils/android_reboot.h> #include <fs_avb/fs_avb.h> #include <fs_avb/fs_avb.h> #include <fs_mgr_vendor_overlay.h> #include <fs_mgr_vendor_overlay.h> #include <keyutils.h> #include <keyutils.h> Loading Loading @@ -601,17 +600,6 @@ void HandleKeychord(const std::vector<int>& keycodes) { } } } } static void InitAborter(const char* abort_message) { // When init forks, it continues to use this aborter for LOG(FATAL), but we want children to // simply abort instead of trying to reboot the system. if (getpid() != 1) { android::base::DefaultAborter(abort_message); return; } RebootSystem(ANDROID_RB_RESTART2, "bootloader"); } static void GlobalSeccomp() { static void GlobalSeccomp() { import_kernel_cmdline(false, [](const std::string& key, const std::string& value, import_kernel_cmdline(false, [](const std::string& key, const std::string& value, bool in_qemu) { bool in_qemu) { Loading @@ -632,8 +620,8 @@ int SecondStageMain(int argc, char** argv) { InstallRebootSignalHandlers(); InstallRebootSignalHandlers(); } } // We need to set up stdin/stdout/stderr again now that we're running in init's context. SetStdioToDevNull(argv); InitKernelLogging(argv, InitAborter); InitKernelLogging(argv); LOG(INFO) << "init second stage started!"; LOG(INFO) << "init second stage started!"; // Set init and its forked children's oom_adj. // Set init and its forked children's oom_adj. Loading Loading
init/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -68,6 +68,7 @@ cc_defaults { "libpropertyinfoparser", "libpropertyinfoparser", ], ], shared_libs: [ shared_libs: [ "libbacktrace", "libbase", "libbase", "libbinder", "libbinder", "libbootloader_message", "libbootloader_message", Loading
init/Android.mk +4 −0 Original line number Original line Diff line number Diff line Loading @@ -105,6 +105,10 @@ LOCAL_STATIC_LIBRARIES := \ libcap \ libcap \ libgsi \ libgsi \ libcom.android.sysprop.apex \ libcom.android.sysprop.apex \ liblzma \ libdexfile_support \ libunwindstack \ libbacktrace \ LOCAL_SANITIZE := signed-integer-overflow LOCAL_SANITIZE := signed-integer-overflow # First stage init is weird: it may start without stdout/stderr, and no /proc. # First stage init is weird: it may start without stdout/stderr, and no /proc. Loading
init/first_stage_init.cpp +2 −6 Original line number Original line Diff line number Diff line Loading @@ -33,7 +33,6 @@ #include <android-base/chrono_utils.h> #include <android-base/chrono_utils.h> #include <android-base/file.h> #include <android-base/file.h> #include <android-base/logging.h> #include <android-base/logging.h> #include <cutils/android_reboot.h> #include <private/android_filesystem_config.h> #include <private/android_filesystem_config.h> #include "debug_ramdisk.h" #include "debug_ramdisk.h" Loading Loading @@ -168,13 +167,10 @@ int FirstStageMain(int argc, char** argv) { "mode=0755,uid=0,gid=0")); "mode=0755,uid=0,gid=0")); #undef CHECKCALL #undef CHECKCALL SetStdioToDevNull(argv); // Now that tmpfs is mounted on /dev and we have /dev/kmsg, we can actually // Now that tmpfs is mounted on /dev and we have /dev/kmsg, we can actually // talk to the outside world... // talk to the outside world... // We need to set up stdin/stdout/stderr for child processes forked from first InitKernelLogging(argv); // 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()) { if (!errors.empty()) { for (const auto& [error_string, error_errno] : errors) { for (const auto& [error_string, error_errno] : errors) { Loading
init/host_init_stubs.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,12 @@ extern uint32_t (*property_set)(const std::string& name, const std::string& valu uint32_t HandlePropertySet(const std::string& name, const std::string& value, uint32_t HandlePropertySet(const std::string& name, const std::string& value, const std::string& source_context, const ucred& cr, std::string* error); const std::string& source_context, const ucred& cr, std::string* error); // reboot_utils.h inline void SetFatalRebootTarget() {} inline void __attribute__((noreturn)) InitFatalReboot() { abort(); } // selinux.h // selinux.h int SelinuxGetVendorAndroidVersion(); int SelinuxGetVendorAndroidVersion(); void SelabelInitialize(); void SelabelInitialize(); Loading
init/init.cpp +2 −14 Original line number Original line Diff line number Diff line Loading @@ -38,7 +38,6 @@ #include <android-base/properties.h> #include <android-base/properties.h> #include <android-base/stringprintf.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/strings.h> #include <cutils/android_reboot.h> #include <fs_avb/fs_avb.h> #include <fs_avb/fs_avb.h> #include <fs_mgr_vendor_overlay.h> #include <fs_mgr_vendor_overlay.h> #include <keyutils.h> #include <keyutils.h> Loading Loading @@ -601,17 +600,6 @@ void HandleKeychord(const std::vector<int>& keycodes) { } } } } static void InitAborter(const char* abort_message) { // When init forks, it continues to use this aborter for LOG(FATAL), but we want children to // simply abort instead of trying to reboot the system. if (getpid() != 1) { android::base::DefaultAborter(abort_message); return; } RebootSystem(ANDROID_RB_RESTART2, "bootloader"); } static void GlobalSeccomp() { static void GlobalSeccomp() { import_kernel_cmdline(false, [](const std::string& key, const std::string& value, import_kernel_cmdline(false, [](const std::string& key, const std::string& value, bool in_qemu) { bool in_qemu) { Loading @@ -632,8 +620,8 @@ int SecondStageMain(int argc, char** argv) { InstallRebootSignalHandlers(); InstallRebootSignalHandlers(); } } // We need to set up stdin/stdout/stderr again now that we're running in init's context. SetStdioToDevNull(argv); InitKernelLogging(argv, InitAborter); InitKernelLogging(argv); LOG(INFO) << "init second stage started!"; LOG(INFO) << "init second stage started!"; // Set init and its forked children's oom_adj. // Set init and its forked children's oom_adj. Loading