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));
}
相关推荐
青小莫38 分钟前
C++之模板
android·java·c++
装不满的克莱因瓶1 小时前
Android Studio 的模拟器如何上传本地图片到手机相册
android·智能手机·android studio
三金121382 小时前
深入解析MySQL EXPLAIN
android
_李小白2 小时前
【Android 美颜相机】第十一天:GPUImageFilter解析
android·数码相机
dawudayudaxue2 小时前
sqlite在安卓下使用ndk的交叉编译
android·数据库·sqlite
YIN_尹2 小时前
【MySQL】表的约束(下)
android·数据库·mysql
爱编码的傅同学2 小时前
【线程的同步与互斥】初识互斥量与锁
android·java·开发语言
_李小白2 小时前
【Android 美颜相机】第十天:YUV420SP和RGB
android·数码相机
2501_944526422 小时前
Flutter for OpenHarmony 万能游戏库App实战 - 收藏功能实现
android·java·开发语言·javascript·python·flutter·游戏
2501_944526422 小时前
Flutter for OpenHarmony 万能游戏库App实战 - 个人中心实现
android·java·javascript·python·flutter·游戏