From f32bc7cd29fa8aeec69f41a2457445c356e1556c Mon Sep 17 00:00:00 2001 From: Haoyu Tang Date: Sat, 5 Jan 2019 09:31:28 +0800 Subject: [PATCH] init: remove the restriction of arguments X86 Kernel could pass CPU capablity to init as argument. This will cause init can't start first-stage because unknown argument. Need remove this restriction of arguments to start init successfully. Fixes: 122435289 Test: Android init can start successfully Change-Id: I1d432e25553589dd7f618e42ad238b9372dbe34f Signed-off-by: Haoyu Tang Signed-off-by: Xihua Chen --- init/main.cpp | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/init/main.cpp b/init/main.cpp index 868c409d0..2ce46efd8 100644 --- a/init/main.cpp +++ b/init/main.cpp @@ -57,27 +57,22 @@ int main(int argc, char** argv) { return ueventd_main(argc, argv); } - if (argc < 2) { - return FirstStageMain(argc, argv); + if (argc > 1) { + if (!strcmp(argv[1], "subcontext")) { + android::base::InitLogging(argv, &android::base::KernelLogger); + const BuiltinFunctionMap function_map; + + return SubcontextMain(argc, argv, &function_map); + } + + if (!strcmp(argv[1], "selinux_setup")) { + return SetupSelinux(argv); + } + + if (!strcmp(argv[1], "second_stage")) { + return SecondStageMain(argc, argv); + } } - if (!strcmp(argv[1], "subcontext")) { - android::base::InitLogging(argv, &android::base::KernelLogger); - const BuiltinFunctionMap function_map; - - return SubcontextMain(argc, argv, &function_map); - } - - if (!strcmp(argv[1], "selinux_setup")) { - return SetupSelinux(argv); - } - - if (!strcmp(argv[1], "second_stage")) { - return SecondStageMain(argc, argv); - } - - android::base::InitLogging(argv, &android::base::KernelLogger); - - LOG(ERROR) << "Unknown argument passed to init '" << argv[1] << "'"; - return 1; + return FirstStageMain(argc, argv); }