build.bat can create the image if missing, split the shell into native, posix and win32, clean up the build by moving executables into directories, the bootloader is no longer responsible to resolve drivers, fix ResolvePath, every process gets a copy of a module (dll), the child always inherits the cwd, fix function exports in posix, add unlink and exit to posix, add path translator to win32, first bugcheck.

This commit is contained in:
maksw committed 2026-05-13 09:24:16 +02:00
1 parent 0c7f461c6d
commit f80e66ecde
38 files changed
+1620 -462

No files matched your search

+6 -14
View File
@@ -1,17 +1,9 @@
// posix_dir.c - chdir, getcwd, opendir, readdir, closedir
#include <string.h>
#include <syscall.h>
#include "posix.h"
#include "posix_path.h"
extern uint32_t SysGetCurrentPid(void);
extern uint32_t SysSetCwd(const char* path);
extern uint32_t SysGetCwd(char* buf, size_t size);
extern uint32_t SysOpenDir(const char* path, uint32_t* handleOut);
extern uint32_t SysReadDir(uint32_t handle, void* entryOut);
extern void SysCloseHandle(uint32_t handle);
extern void* SysAlloc(size_t);
extern void SysFree(void*, size_t);
// KDIR_ENTRY layout mirrors io_file.h - duplicated here to avoid
// pulling kernel headers into posix.dll
#define KDIR_NAME_MAX 260
@@ -23,7 +15,7 @@ typedef struct {
#define KATTR_DIR 0x10
int chdir(const char* path) {
__declspec(dllexport) int chdir(const char* path) {
char native[512];
PosixTranslatePath(path, native, sizeof(native));
uint32_t s = SysSetCwd(native);
@@ -31,7 +23,7 @@ int chdir(const char* path) {
return 0;
}
char* getcwd(char* buf, size_t size) {
__declspec(dllexport) char* getcwd(char* buf, size_t size) {
if (!buf || size == 0) { errno = EINVAL; return (char*)0; }
char native[512];
uint32_t s = SysGetCwd(native, sizeof(native));
@@ -40,7 +32,7 @@ char* getcwd(char* buf, size_t size) {
return buf;
}
DIR* opendir(const char* path) {
__declspec(dllexport) DIR* opendir(const char* path) {
char native[512];
PosixTranslatePath(path, native, sizeof(native));
uint32_t kh;
@@ -55,7 +47,7 @@ DIR* opendir(const char* path) {
return d;
}
struct dirent* readdir(DIR* d) {
__declspec(dllexport) struct dirent* readdir(DIR* d) {
if (!d) { errno = EBADF; return (struct dirent*)0; }
KDIR_ENTRY ke;
uint32_t s = SysReadDir(d->KHandle, &ke);
@@ -70,7 +62,7 @@ struct dirent* readdir(DIR* d) {
return &d->Current;
}
int closedir(DIR* d) {
__declspec(dllexport) int closedir(DIR* d) {
if (!d) { errno = EBADF; return -1; }
SysCloseHandle(d->KHandle);
SysFree(d, sizeof(DIR));