add ntfs.sys standalone driver target, change default usb vhd layout formatting to ntfs, implement Fat32CreateDir for directory creation support in the fat32 file system driver, add a dedicated HAL serial output endpoint for COM1 writes in hal_serial.c and subscribe serial to HAL text streams, introduce waitable kernel timers with KeTimerCreate, KeTimerSet, and KeTimerCancel alongside spinlock-protected global timer list initialization and scheduler tick tracking, implement SyscallWriteFileAsync system call for asynchronous non-blocking file writes, refactor NetSocketConnect and NetSocketSendTo to use generic SYS_SOCKET_ADDRESS_K structures instead of being hardcoded to IPv4, update gethostbyname and DNS name resolution to support IPv6 parsing via ResolveNameFamily, update tcpserve.exe with -4 and -6 command-line flags to accept and display IPv6 addresses, append size and version headers to all kernel telemetry and statistics structures including SYS_PMM_STATS, SYS_CPU_STATS, and SYS_SCHEDULER_STATS, update winmm timeGetTime to look up high-resolution hardware frequencies via SysGetTickFrequency, integrate 14 native smoke test applications.
This commit is contained in:
1 parent
2c4a68a75f
commit
ed3d065abd
156 files changed
+10509
-2643
No files matched your search
@@ -0,0 +1,177 @@
|
||||
// Realpath ABI smoke test.
|
||||
// Verifies lexical canonicalization, size reporting, and root clamping.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <ntlite/syscall.h>
|
||||
|
||||
// Prints one NUL-terminated string to the kernel console.
|
||||
static void print(const char* s) {
|
||||
SYS_WRITE_CONSOLE_REQUEST 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) {
|
||||
for (;;) 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");
|
||||
exit_now(1);
|
||||
}
|
||||
|
||||
// Fails the test with one plain message.
|
||||
static void fail(const char* what) {
|
||||
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 != STATUS_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];
|
||||
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);
|
||||
if (status != STATUS_SUCCESS) fail_status("realpath", status);
|
||||
if (required != strlen(expected) + 1) 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 != STATUS_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 != STATUS_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));
|
||||
|
||||
char input[SYS_CWD_MAX];
|
||||
char expected[SYS_CWD_MAX];
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
SYS_REAL_PATH_REQUEST currentReq = {
|
||||
sizeof(currentReq),
|
||||
SYS_REAL_PATH_FLAG_NONE,
|
||||
SysSvFromCstr("."),
|
||||
expected,
|
||||
sizeof(expected),
|
||||
(size_t*)0,
|
||||
};
|
||||
uint32_t status = SysRealPath(¤tReq);
|
||||
if (status != STATUS_SUCCESS) fail_status("current realpath", status);
|
||||
|
||||
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);
|
||||
|
||||
print("realpath_smoke: PASS\n");
|
||||
exit_now(0);
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user