20 #include "modules/Module.h" 21 #include "modules/subsys/posix/FileDescriptor.h" 22 #include "modules/subsys/posix/PosixProcess.h" 23 #include "modules/subsys/posix/PosixSubsystem.h" 24 #include "modules/system/vfs/VFS.h" 25 #include "pedigree/kernel/Log.h" 26 #include "pedigree/kernel/Subsystem.h" 27 #include "pedigree/kernel/compiler.h" 28 #include "pedigree/kernel/core/BootIO.h" 29 #include "pedigree/kernel/process/Process.h" 30 #include "pedigree/kernel/process/Thread.h" 31 #include "pedigree/kernel/processor/Processor.h" 32 #include "pedigree/kernel/processor/ProcessorInformation.h" 33 #include "pedigree/kernel/utilities/StaticString.h" 34 #include "pedigree/kernel/utilities/String.h" 35 #include "pedigree/kernel/utilities/Vector.h" 36 #include "pedigree/kernel/utilities/new" 40 static Mutex g_Started(
false);
42 static void error(
const char *s)
48 bootIO.
write(str, BootIO::Red, BootIO::Black);
52 static int init_stage2(
void *param)
54 #if defined(HOSTED) && defined(HAS_ADDRESS_SANITIZER) 55 extern void system_reset();
56 NOTICE(
"Note: ASAN build, so triggering a restart now.");
61 bool tryingLinux =
false;
65 String init_path(
"root»/applications/init");
66 NOTICE(
"Searching for init program at " << init_path);
71 "Did not find " << init_path
72 <<
", trying for a Linux userspace...");
73 init_path =
"root»/sbin/init";
76 NOTICE(
"Searching for Linux init at " << init_path);
80 error(
"failed to find init program (tried root»/applications/init and root»/sbin/init)");
84 NOTICE(
"Found an init program at " << init_path);
97 if (!pProcess->getSubsystem()->
invoke(file, init_path, argv, env))
99 error(
"failed to load init program");
118 pProcess->setUserId(0);
119 pProcess->setGroupId(0);
120 pProcess->setEffectiveUserId(0);
121 pProcess->setEffectiveGroupId(0);
122 pProcess->setSavedUserId(0);
123 pProcess->setSavedGroupId(0);
130 pProcess->setSubsystem(pSubsystem);
136 error(
"dev»/null does not exist");
155 static void destroy()
159 #if defined(X86_COMMON) 160 #define __MOD_DEPS "vfs", "posix", "linker", "users" 161 #define __MOD_DEPS_OPT "gfx-deps", "mountroot", "confignics" 163 #define __MOD_DEPS "vfs", "posix", "linker", "users" 164 #define __MOD_DEPS_OPT "mountroot", "confignics" 166 MODULE_INFO(
"init", &init, &destroy, __MOD_DEPS);
167 #ifdef __MOD_DEPS_OPT 168 MODULE_OPTIONAL_DEPENDS(__MOD_DEPS_OPT);
File * find(const String &path, File *pStartNode=0)
void pushBack(const T &value)
bool acquire(size_t n=1, size_t timeoutSecs=0, size_t timeoutUsecs=0)
A vector / dynamic array.
EXPORTED_PUBLIC void write(T &str, Colour foreColour, Colour backColour)
static ProcessorInformation & information()
void addFileDescriptor(size_t fd, FileDescriptor *pFd)
virtual bool invoke(const char *name, Vector< String > &argv, Vector< String > &env)=0
static void setInit(Process *pProcess)
LargeStaticString & description()