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:
maksw committed 2026-08-20 12:33:17 +02:00
1 parent 4add6789ba
commit f882d339fb
232 files changed
+20934 -8898

No files matched your search

+36 -136
View File
@@ -1,175 +1,75 @@
// Realpath ABI smoke test.
// Verifies lexical canonicalization, size reporting, and root clamping.
// Userspace realpath smoke test.
// Verifies native resource-path canonicalization and size reporting.
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <ntlite/syscall.h>
#include <ntlite/path.h>
// Prints one NUL-terminated string to the kernel console.
static void print(const char* s) {
SYS_WRITE_CONSOLE_REQUEST req = { SysSvFromCstr(s) };
SYS_WRITE_CONSOLE_REQUEST req = { sizeof(req), SysSvFromCstr(s) };
SysWriteConsole(&req);
}
// Prints one unsigned integer to the kernel console.
static void print_u64(uint64_t v) {
char buf[32];
int i = 0;
if (v == 0) {
print("0");
return;
}
while (v && i < (int)sizeof(buf)) {
buf[i++] = (char)('0' + (v % 10));
v /= 10;
}
while (i--) {
char c = buf[i];
SYS_WRITE_CONSOLE_REQUEST req = { SysSvFromParts(&c, 1) };
SysWriteConsole(&req);
}
}
// Terminates the current test process.
static void exit_now(int code) {
while (true) SysExitProcess(code);
}
// Fails the test with one status value.
static void fail_status(const char* what, uint32_t status) {
print("realpath_smoke: ");
print(what);
print(" status=");
print_u64(status);
print("\n");
(void)status;
print("realpath_smoke: "); print(what); print("\n");
exit_now(1);
}
// Fails the test with one plain message.
static void fail(const char* what) {
print("realpath_smoke: ");
print(what);
print("\n");
print("realpath_smoke: "); print(what); print("\n");
exit_now(1);
}
// Appends one string to a fixed test buffer.
static void append(char* out, size_t cap, const char* suffix) {
size_t len = strlen(out);
size_t add = strlen(suffix);
if (len + add + 1 > cap) fail("test buffer too small");
memcpy(out + len, suffix, add + 1);
}
// Builds the current drive root path.
static void get_current_drive_root(char* out, size_t cap) {
char current[SYS_CWD_MAX];
size_t required = 0;
SYS_REAL_PATH_REQUEST req = {
sizeof(req),
SYS_REAL_PATH_FLAG_NONE,
SysSvFromCstr("."),
current,
sizeof(current),
&required,
};
uint32_t status = SysRealPath(&req);
if (status != NTLSTATUS_SUCCESS) fail_status("query current path", status);
if (required < 4 || current[0] < '0' || current[0] > '7' || current[1] != ':' || current[2] != '/')
fail("current path is not native drive-rooted");
if (cap < 4) fail("drive root output too small");
out[0] = current[0];
out[1] = ':';
out[2] = '/';
out[3] = '\0';
}
// Resolves a path and compares the exact native string.
static void expect_realpath(const char* input, const char* expected) {
char out[SYS_CWD_MAX];
char out[SYS_PATH_MAX + 1u];
size_t required = 0;
SYS_REAL_PATH_REQUEST req = {
sizeof(req),
SYS_REAL_PATH_FLAG_NONE,
SysSvFromCstr(input),
out,
sizeof(out),
&required,
};
uint32_t status = SysRealPath(&req);
uint32_t status = NtlRealPath(SysSvFromCstr(input), out, sizeof(out), &required);
if (status != NTLSTATUS_SUCCESS) fail_status("realpath", status);
if (required != strlen(expected) + 1) fail("required size mismatch");
if (required != strlen(expected) + 1u) fail("required size mismatch");
if (strcmp(out, expected) != 0) fail("resolved path mismatch");
}
// Verifies size-only and too-small buffer behavior.
static void check_size_reporting(const char* input, const char* expected) {
size_t required = 0;
SYS_REAL_PATH_REQUEST query = {
sizeof(query),
SYS_REAL_PATH_FLAG_NONE,
SysSvFromCstr(input),
(char*)0,
0,
&required,
};
uint32_t status = SysRealPath(&query);
if (status != NTLSTATUS_SUCCESS) fail_status("size query", status);
if (required != strlen(expected) + 1) fail("size query required mismatch");
char small[4];
size_t smallRequired = 0;
SYS_REAL_PATH_REQUEST smallReq = {
sizeof(smallReq),
SYS_REAL_PATH_FLAG_NONE,
SysSvFromCstr(input),
small,
sizeof(small),
&smallRequired,
};
status = SysRealPath(&smallReq);
if (status != NTLSTATUS_BUFFER_TOO_SMALL) fail_status("small buffer", status);
if (smallRequired != required) fail("small required mismatch");
}
// Program entry point.
int main(void) {
print("realpath_smoke: start\n");
char root[4];
get_current_drive_root(root, sizeof(root));
expect_realpath("/SystemRoot//foo///bar/./", "/SystemRoot/foo/bar");
char input[SYS_CWD_MAX];
char expected[SYS_CWD_MAX];
char cwd[SYS_PATH_MAX + 1u];
size_t cwdRequired = 0;
uint32_t status = NtlGetCurrentDirectory(cwd, sizeof(cwd), &cwdRequired);
if (status != NTLSTATUS_SUCCESS) fail_status("get cwd", status);
memcpy(input, root, sizeof(root));
append(input, sizeof(input), "//foo///bar\\baz/.");
memcpy(expected, root, sizeof(root));
append(expected, sizeof(expected), "foo/bar/baz");
expect_realpath(input, expected);
check_size_reporting(input, expected);
char expected[SYS_PATH_MAX + 1u];
size_t cwdLength = strlen(cwd);
if (cwdLength + sizeof("/missing_file") > sizeof(expected)) fail("expected buffer too small");
memcpy(expected, cwd, cwdLength);
memcpy(expected + cwdLength, "/missing_file", sizeof("/missing_file"));
expect_realpath("missing_realpath_dir/../missing_file", expected);
memcpy(input, root, sizeof(root));
append(input, sizeof(input), "../../root_escape");
memcpy(expected, root, sizeof(root));
append(expected, sizeof(expected), "root_escape");
expect_realpath(input, expected);
size_t required = 0;
status = NtlRealPath(SYS_SV_LITERAL("/SystemRoot/system/init.exe"), (char*)0, 0, &required);
if (status != NTLSTATUS_SUCCESS || required != sizeof("/SystemRoot/system/init.exe"))
fail_status("size query", status);
char small[4];
size_t smallRequired = 0;
status = NtlRealPath(SYS_SV_LITERAL("/SystemRoot/system/init.exe"), small, sizeof(small), &smallRequired);
if (status != NTLSTATUS_BUFFER_TOO_SMALL || smallRequired != required)
fail_status("small buffer", status);
SYS_REAL_PATH_REQUEST currentReq = {
sizeof(currentReq),
SYS_REAL_PATH_FLAG_NONE,
SysSvFromCstr("."),
expected,
sizeof(expected),
(size_t*)0,
};
uint32_t status = SysRealPath(&currentReq);
if (status != NTLSTATUS_SUCCESS) fail_status("current realpath", status);
expect_realpath("/SystemRoot/foo/../bar", "/SystemRoot/bar");
memcpy(input, "missing_realpath_dir/../missing_file", sizeof("missing_realpath_dir/../missing_file"));
append(expected, sizeof(expected), expected[strlen(expected) - 1] == '/' ? "missing_file" : "/missing_file");
expect_realpath(input, expected);
status = NtlRealPath(SYS_SV_LITERAL("/SystemRoot/../../escape"), expected, sizeof(expected), (size_t*)0);
if (status != NTLSTATUS_ACCESS_DENIED) fail_status("resource-root traversal", status);
status = NtlRealPath(SYS_SV_LITERAL("/SystemRoot/foo\\bar"), expected, sizeof(expected), (size_t*)0);
if (status != NTLSTATUS_INVALID_PARAMETER) fail_status("native backslash", status);
print("realpath_smoke: PASS\n");
exit_now(0);