2#include "module-syscalls.h"
3#include "pedigree/kernel/linker/KernelElf.h"
4#include "pedigree/kernel/process/Process.h"
5#include "pedigree/kernel/process/Thread.h"
6#include "pedigree/kernel/process/Uninterruptible.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_delete_module(
const char* name,
unsigned int flags) {
17 if (!posix_global_capable(16)) {
18 SYSCALL_ERROR(NotEnoughPermissions);
21 constexpr unsigned int nonblocking = 0x800;
22 constexpr unsigned int force = 0x200;
23 if (flags & ~(nonblocking | force)) {
24 SYSCALL_ERROR(InvalidArgument);
28 SYSCALL_ERROR(OperationNotSupported);
32 constexpr size_t nameBytes = 64 -
sizeof(
unsigned long);
35 if (copied != PosixSubsystem::UserStringSuccess) {
36 syscallError(copied == PosixSubsystem::UserStringTooLong ? Error::DoesNotExist
40 if (!copiedName.length()) {
41 SYSCALL_ERROR(DoesNotExist);
45 using Result = KernelElf::RuntimeUnloadResult;
48 case Result::Unloaded:
52 case Result::NotFound:
53 SYSCALL_ERROR(DoesNotExist);
57 SYSCALL_ERROR(DeviceBusy);
59 case Result::DependedOn:
60 SYSCALL_ERROR(NoMoreProcesses);
62 case Result::Shutdown:
63 SYSCALL_ERROR(NotEnoughPermissions);
static KernelElf & instance()
RuntimeUnloadResult unloadModuleRuntime(const char *name)
static UserStringResult copyUserString(const char *userString, String ©, size_t maxLength)
static ProcessorInformation & information()
void setErrno(size_t err)