implement proper IRQL, DPCs, kernel and user APCs, alertable waits, async file I/O with cancellation, trap frames, selftests, a real driver/device model, native async FAT32, VFAT dotfile fixes, syscall ABI cleanup, async_apc and async_cancel tests, POSIX multi-volume paths, and pimp the readme.

This commit is contained in:
maksw committed 2026-05-19 20:56:15 +02:00
1 parent f5fd7bdd75
commit 529f816166
75 files changed
+9969 -5675

No files matched your search

+38 -21
View File
@@ -3,29 +3,36 @@
#include <string.h>
#include "posix_path.h"
// The drive letter used as the POSIX filesystem root.
// A future SYS_GET_BOOT_DRIVE could populate this; hardcoded for v1.
static const char gRootDrive = '0';
static void FlipSlashes(char* s) {
for (; *s; s++) if (*s == '/') *s = '\\';
}
static int IsDriveMount(const char* p) {
return p && p[0] == '/' && p[1] >= '0' && p[1] <= '7' &&
(p[2] == '\0' || p[2] == '/');
}
const char* PosixTranslatePath(const char* in, char* out, size_t outSize) {
if (!in || !out || outSize < 4) return out;
// Synthetic devices
if (strcmp(in, "/dev/null") == 0) return SYNTH_DEVNULL;
if (strcmp(in, "/dev/zero") == 0) return SYNTH_DEVZERO;
// /proc/self/* - read-only synthesized files; flag with a sentinel so
// posix_io.c can intercept them without opening a real file.
// (In v1 only /proc/self/pid is handled; others fall through to ENOENT.)
if (IsDriveMount(in)) {
out[0] = in[1];
out[1] = ':';
out[2] = '/';
const char* rest = (in[2] == '/') ? in + 3 : "";
size_t restLen = strlen(rest);
if (restLen + 4 > outSize) restLen = outSize - 4;
memcpy(out + 3, rest, restLen);
out[3 + restLen] = '\0';
FlipSlashes(out);
return out;
}
if (in[0] == '/') {
// Absolute POSIX path -> C:\...
// outSize must fit "C:\" + rest
out[0] = gRootDrive;
out[0] = '0';
out[1] = ':';
out[2] = '/';
size_t rest = strlen(in + 1);
@@ -33,7 +40,6 @@ const char* PosixTranslatePath(const char* in, char* out, size_t outSize) {
memcpy(out + 3, in + 1, rest);
out[3 + rest] = '\0';
} else {
// Relative - pass through with slash flip only
size_t len = strlen(in);
if (len + 1 > outSize) len = outSize - 1;
memcpy(out, in, len);
@@ -47,16 +53,27 @@ const char* PosixTranslatePath(const char* in, char* out, size_t outSize) {
void NativeToPosix(const char* in, char* out, size_t outSize) {
if (!in || !out || outSize == 0) return;
// Strip "X:\" prefix if present
const char* src = in;
if (src[0] != '\0' && src[1] == ':' && (src[2] == '\\' || src[2] == '/'))
src += 2; // skip "C:", leave the leading backslash
char drive = 0;
if (src[0] >= '0' && src[0] <= '7' && src[1] == ':' &&
(src[2] == '\\' || src[2] == '/')) {
drive = src[0];
src += 3;
}
size_t len = strlen(src);
if (len + 1 > outSize) len = outSize - 1;
memcpy(out, src, len);
out[len] = '\0';
size_t pos = 0;
if (drive && drive != '0') {
if (outSize < 4) { out[0] = '\0'; return; }
out[pos++] = '/';
out[pos++] = drive;
if (*src) out[pos++] = '/';
} else {
out[pos++] = '/';
}
// Backslash -> forward slash
for (char* p = out; *p; p++) if (*p == '\\') *p = '/';
while (*src && pos + 1 < outSize) {
out[pos++] = (*src == '\\') ? '/' : *src;
src++;
}
out[pos] = '\0';
}