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));
}
相关推荐
范特西林9 分钟前
解剖麻雀:Binder 通信的整体架构全景图
android
范特西林12 分钟前
破冰之旅:为什么 Android 选择了 Binder?
android
奔跑中的蜗牛6662 小时前
一次播放器架构升级:Android 直播间 ANR 下降 60%
android
测试工坊4 小时前
Android 视频播放卡顿检测——帧率之外的第二战场
android
Kapaseker5 小时前
一杯美式深入理解 data class
android·kotlin
鹏多多5 小时前
Flutter使用screenshot进行截屏和截长图以及分享保存的全流程指南
android·前端·flutter
Carson带你学Android5 小时前
OpenClaw移动端要来了?Android官宣AI原生支持App Functions
android
黄林晴5 小时前
Android 删了 XML 预览,现在你必须学 Compose 了
android
三少爷的鞋6 小时前
Android 面试系列 | 内存泄露:从"手动配对"到"架构自愈"
android
恋猫de小郭6 小时前
什么 AI 写 Android 最好用?官方做了一个基准测试排名
android·前端·flutter