redo boot around an explicit system volume and fixed kernel/HAL images, redo volumes and filesystem paths around capabilities instead of drive numbers and kernel CWD state, add a capability/security model with derived and revocable handles and security contexts, add port IPC and rssrv to manage the userspace resource namespace and publish the system volume, move process, dll and path loading to userspace and add process builder syscalls, init now supervises rssrv and the session process, redo the syscall ABI around request structs and four arguments, add a volume manager and proper partition arrival/removal handling so FAT and NTFS mount dynamically, clean up the HAL/DDK boundary so drivers don't depend on HAL internals, save fpu state properly now, the serial driver doesn't hang on a missing port, fix AHCI startup races, fix timeout accounting, fix shared mmap writeback, more smoke tests
This commit is contained in:
1 parent
4add6789ba
commit
f882d339fb
232 files changed
+20934
-8898
No files matched your search
@@ -3,6 +3,8 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <ntlite/syscall.h>
|
||||
#include <ntlite/module_loader.h>
|
||||
#include <ntlite/resource.h>
|
||||
#include "posix.h"
|
||||
#include "posix_path.h"
|
||||
#include "posix_fd.h"
|
||||
@@ -43,22 +45,45 @@ __declspec(dllexport) void* dlopen(const char* filename, int flags) {
|
||||
}
|
||||
|
||||
char native[512];
|
||||
const char* path = PosixTranslatePath(filename, native, sizeof(native));
|
||||
if (!path || strcmp(path, SYNTH_DEVNULL) == 0 || strcmp(path, SYNTH_DEVZERO) == 0) {
|
||||
uint32_t status = PosixProcessPath(filename, native, sizeof(native));
|
||||
if (status != NTLSTATUS_SUCCESS) {
|
||||
errno = EINVAL;
|
||||
DlSetError("dlopen path is not a loadable module");
|
||||
return 0;
|
||||
}
|
||||
if (!strchr(native, '/')) {
|
||||
size_t length = strlen(native);
|
||||
if (length + sizeof("system/") > sizeof(native)) {
|
||||
errno = ERANGE;
|
||||
DlSetError("dlopen path is too long");
|
||||
return 0;
|
||||
}
|
||||
memmove(native + 7, native, length + 1u);
|
||||
memcpy(native, "system/", 7);
|
||||
}
|
||||
|
||||
uint32_t handle = 0;
|
||||
SYS_LOAD_MODULE_REQUEST req;
|
||||
SYS_HANDLE root = SYS_HANDLE_INVALID;
|
||||
status = NtlResourceOpenSystemRoot(SYS_RIGHT_QUERY | SYS_VOLUME_RIGHT_OPEN, &root);
|
||||
if (status != NTLSTATUS_SUCCESS) {
|
||||
DlSetStatusError("dlopen system root failed", status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
NTL_MODULE_HANDLE handle = NTL_MODULE_HANDLE_INVALID;
|
||||
NTL_LOAD_MODULE_AT_REQUEST req;
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.Size = sizeof(req);
|
||||
req.Path = SysSvFromCstr(path);
|
||||
req.Flags = NTL_MODULE_LOAD_FLAG_NONE;
|
||||
req.RootHandle = root;
|
||||
req.Path = SysSvFromCstr(native);
|
||||
req.ModuleRootHandle = root;
|
||||
req.ModuleDirectory = SYS_SV_LITERAL("system");
|
||||
req.ResolveModuleName = PosixResolveModuleName;
|
||||
req.ModuleHandleOut = &handle;
|
||||
|
||||
uint32_t status = SysLoadModule(&req);
|
||||
if (status != NTLSTATUS_SUCCESS || handle == 0) {
|
||||
status = NtlLoadModuleAt(&req);
|
||||
(void)SysCloseHandle(root);
|
||||
if (status != NTLSTATUS_SUCCESS || handle == NTL_MODULE_HANDLE_INVALID) {
|
||||
DlSetStatusError("dlopen failed", status);
|
||||
return 0;
|
||||
}
|
||||
@@ -76,14 +101,8 @@ __declspec(dllexport) void* dlsym(void* handle, const char* symbol) {
|
||||
}
|
||||
|
||||
uintptr_t address = 0;
|
||||
SYS_GET_MODULE_EXPORT_REQUEST req;
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.Size = sizeof(req);
|
||||
req.ModuleHandle = (uint32_t)(uintptr_t)handle;
|
||||
req.Name = SysSvFromCstr(symbol);
|
||||
req.AddressOut = &address;
|
||||
|
||||
uint32_t status = SysGetModuleExport(&req);
|
||||
uint32_t status = NtlGetModuleExport((NTL_MODULE_HANDLE)(uintptr_t)handle,
|
||||
SysSvFromCstr(symbol), &address);
|
||||
if (status != NTLSTATUS_SUCCESS || address == 0) {
|
||||
DlSetStatusError("dlsym failed", status);
|
||||
return 0;
|
||||
@@ -101,7 +120,7 @@ __declspec(dllexport) int dlclose(void* handle) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t status = SysUnloadModule((uint32_t)(uintptr_t)handle);
|
||||
uint32_t status = NtlUnloadModule((NTL_MODULE_HANDLE)(uintptr_t)handle);
|
||||
if (status != NTLSTATUS_SUCCESS) {
|
||||
DlSetStatusError("dlclose failed", status);
|
||||
return -1;
|
||||
|
||||
Reference in new issue
Block a user