1.FirstStageMain
cpp
//android10\system\core\init\first_stage_init.cpp
int FirstStageMain(int argc, char** argv) {
const char* path = "/system/bin/init";
const char* args[] = {path, "selinux_setup", nullptr};
execv(path, const_cast<char**>(args));
}
2.main
cpp
//android10\system\core\init\main.cpp
int main(int argc, char** argv) {
if (argc > 1) {
if (!strcmp(argv[1], "selinux_setup")) {
return SetupSelinux(argv);
}
}
}
3.SetupSelinux
java
//android10\system\core\init\selinux.cpp
int SetupSelinux(char** argv) {
InitKernelLogging(argv); //为啥调用多次
// Set up SELinux, loading the SELinux policy.
SelinuxSetupKernelLogging();
SelinuxInitialize();
const char* path = "/system/bin/init";
const char* args[] = {path, "second_stage", nullptr};//4.second_stage
execv(path, const_cast<char**>(args));
}