2#include "init-module-syscalls.h"
3#include "pedigree/kernel/linker/KernelElf.h"
4#include "pedigree/kernel/process/Process.h"
5#include "pedigree/kernel/process/TerminationDeferral.h"
6#include "pedigree/kernel/process/Thread.h"
7#include "pedigree/kernel/processor/Processor.h"
8#include "pedigree/kernel/processor/ProcessorInformation.h"
9#include "pedigree/kernel/syscallError.h"
11#include "PosixSubsystem.h"
12#include "user-namespace.h"
14int posix_init_module(
const void* image,
size_t length,
const char* parameters) {
17 if (!posix_global_capable(16)) {
18 SYSCALL_ERROR(NotEnoughPermissions);
24 SYSCALL_ERROR(BadAddress);
28 SYSCALL_ERROR(OperationNotSupported);
32 using Result = KernelElf::RuntimeLoadResult;
33 Result result = Result::Busy;
34 bool copyFailed =
false;
37 result = kernel.beginRuntimeModuleLoad(length, load);
38 if (result == Result::Ready) {
41 result = kernel.loadModuleRuntime(load);
46 SYSCALL_ERROR(BadAddress);
53 case Result::InvalidImage:
54 case Result::UnsupportedImage:
55 case Result::ImageTooLarge:
56 SYSCALL_ERROR(ExecFormatError);
58 case Result::NoMemory:
59 SYSCALL_ERROR(OutOfMemory);
61 case Result::Shutdown:
62 SYSCALL_ERROR(NotEnoughPermissions);
64 case Result::Duplicate:
65 SYSCALL_ERROR(FileExists);
67 case Result::MissingDependency:
68 SYSCALL_ERROR(DoesNotExist);
70 case Result::EntryFailed:
71 SYSCALL_ERROR(DeviceDoesNotExist);
73 case Result::ProtectionFailed:
74 SYSCALL_ERROR(IoError);
78 SYSCALL_ERROR(DeviceBusy);
static KernelElf & instance()
static bool copyFromUser(void *destination, const void *source, size_t count, size_t elementSize=1)
static ProcessorInformation & information()
void setErrno(size_t err)