android系列-init SetupSelinux

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));
}
相关推荐
2501_9151063222 分钟前
全面理解 iOS 帧率,构建从渲染到系统行为的多工具协同流畅度分析体系
android·ios·小程序·https·uni-app·iphone·webview
繁星星繁30 分钟前
【Mysql】数据库基础
android·数据库·mysql
李坤林38 分钟前
Android 12 中 App 与 SurfaceFlinger(SF)的 Vsync 通信机制
android·surfaceflinger
高远-临客38 分钟前
unity IL2CPP模式下中使用UMP插件打包后无法播放视频监控报错问题解决方案
android·unity·音视频
装不满的克莱因瓶1 小时前
Windows下安装Dart
android·flutter·dart·移动端
Yao_YongChao1 小时前
adb wifi连接Android手机
android·adb·智能手机·无线连接手机·wifi连接手机
安果移不动1 小时前
git Cherry-Pick合并分支上的某些commits-》Android studio
android·git·android studio
灵感菇_2 小时前
Android Broadcast全面解析
android·广播·四大组件
byc2 小时前
Android 存储目录<内部存储,外部存储app专属,外部存储公共>
android·面试
RollingPin2 小时前
React Native与Flutter的对比
android·flutter·react native·ios·js·移动端·跨平台开发