isolate POSIX builds from the host UCRT, wire lwext4 and ntfs-3g as ext4.sys and ntfs.sys, split the FAT driver into directory/file/async/driver/mount units, add posixsrv and dwm plus input/console/desktop syscall clients and a pile of new smoke targets, rename serial.sys to cereal.sys, name HDA/USB/lwIP/AHCI workers, harden ATA probing/reset/removal around actual hardware deadlines, absent-channel detection, diagnostics and explicit worker lifetime, redo ACPI S5 shutdown around GAS/MMIO and HW-reduced firmware, scan SSDTs for _S5 and deal with Intel SMI sleep trapping, make serial and SMP timeouts use real monotonic deadlines, add thread names and fix terminal thread teardown, scheduler and APC prepare/commit races, make advisory file locks queryable and preserve split ranges and add mutable file append state, add shared-memory pipes with kernel-assisted wait/wake, introduce capability-scoped input and display managers, split surface map rights into read/write, add explicit unmap and replace present with commit/generation/damage tracking while keeping physical presentation under the display manager, decouple native exception classes from Win32 exception numbers and translate them in kernel32, add opaque process startup data, bump the resource protocol to v3 with namespace directories, symlinks and enumeration and service control to v2 with generic READY handle exports, add the new POSIX errno/status surface and rebuild fds around posixsrv-owned shared open descriptions, descriptor-local flags, exact inheritance snapshots, dup/fcntl/record locks and shared-ring pipes, add waitpid, POSIX credentials/groups/sessions/passwd/group lookups and move sockets onto stable open descriptions, port the shells and apps to the new console/input services and surface commit API, teach init to load services.ini and start/supervise RSSRV, DWM and generic services under restricted capabilities while publishing their endpoints through RSSRV, split RSSRV into namespace, volume, display, session, input, console and resource components and make /SystemRoot a real symlink to the independently published system volume, shift the syscall table again, expand lock/resource/surface/POSIX/service/thread smoke coverage, make docs scream ASK QUESTIONS and DISCUSS at LLMs, replace MIT No Attribution with WTFPL+.
This commit is contained in:
1 parent
3dacbd32c8
commit
73abd6f90d
441 files changed
+187073
-6549
No files matched your search
@@ -4,7 +4,7 @@
|
||||
#include <ntlite/syscall.h>
|
||||
#include <ntlite/path.h>
|
||||
#include <stdlib.h>
|
||||
#include "posix.h"
|
||||
#include "posix_internal.h"
|
||||
#include "posix_fd.h"
|
||||
#include "posix_path.h"
|
||||
|
||||
@@ -12,31 +12,74 @@ typedef SYS_DIR_ENTRY KDIR_ENTRY;
|
||||
|
||||
#define KATTR_DIR 0x10
|
||||
|
||||
// Implements the chdir operation.
|
||||
// Publishes the process-local native CWD into the authoritative posixsrv process record.
|
||||
static KSTATUS PosixPublishCurrentDirectory(const char* nativeDirectory) {
|
||||
if (!nativeDirectory) return NTLSTATUS_INVALID_PARAMETER;
|
||||
size_t length = strlen(nativeDirectory);
|
||||
if (length == 0 || length > SYS_PATH_MAX) return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
NTL_POSIX_REQUEST request;
|
||||
memset(&request, 0, sizeof(request));
|
||||
request.Size = sizeof(request);
|
||||
request.Version = NTL_POSIX_PROTOCOL_VERSION;
|
||||
request.Operation = NTL_POSIX_OP_SET_CURRENT_DIRECTORY;
|
||||
request.Flags = NTL_POSIX_REQUEST_FLAG_NONE;
|
||||
request.PathLength = (uint32_t)length;
|
||||
memcpy(request.Path, nativeDirectory, length + 1u);
|
||||
|
||||
NTL_POSIX_REPLY reply;
|
||||
KSTATUS status = PosixRuntimeCallServer(&request, &reply);
|
||||
if (!KSUCCESS(status)) return status;
|
||||
return reply.Status;
|
||||
}
|
||||
|
||||
// Implements chdir while keeping the local path resolver and posixsrv authority synchronized.
|
||||
__declspec(dllexport) int chdir(const char* path) {
|
||||
char native[512];
|
||||
PosixTranslatePath(path, native, sizeof(native));
|
||||
uint32_t s = NtlSetCurrentDirectory(SysSvFromCstr(native));
|
||||
if (s != 0) { errno = ENOENT; return -1; }
|
||||
if (!path) { errno = EINVAL; return -1; }
|
||||
|
||||
char oldNative[SYS_PATH_MAX + 1u];
|
||||
size_t oldRequired = 0;
|
||||
KSTATUS status = NtlGetCurrentDirectory(oldNative, sizeof(oldNative), &oldRequired);
|
||||
if (!KSUCCESS(status)) { errno = PosixStatusToErrno(status); return -1; }
|
||||
|
||||
char native[SYS_PATH_MAX + 1u];
|
||||
const char* translated = PosixTranslatePath(path, native, sizeof(native));
|
||||
if (translated != native || native[0] == '\0') { errno = EINVAL; return -1; }
|
||||
|
||||
status = NtlSetCurrentDirectory(SysSvFromCstr(native));
|
||||
if (!KSUCCESS(status)) { errno = PosixStatusToErrno(status); return -1; }
|
||||
|
||||
char canonical[SYS_PATH_MAX + 1u];
|
||||
size_t required = 0;
|
||||
status = NtlGetCurrentDirectory(canonical, sizeof(canonical), &required);
|
||||
if (KSUCCESS(status)) status = PosixPublishCurrentDirectory(canonical);
|
||||
if (!KSUCCESS(status)) {
|
||||
(void)NtlSetCurrentDirectory(SysSvFromCstr(oldNative));
|
||||
errno = PosixStatusToErrno(status);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Implements the getcwd operation.
|
||||
// Implements getcwd from the server-owned POSIX process attribute.
|
||||
__declspec(dllexport) char* getcwd(char* buf, size_t size) {
|
||||
if (!buf || size == 0) { errno = EINVAL; return (char*)0; }
|
||||
|
||||
char native[SYS_PATH_MAX + 1u];
|
||||
size_t required = 0;
|
||||
uint32_t status = NtlGetCurrentDirectory(native, sizeof(native), &required);
|
||||
if (status != NTLSTATUS_SUCCESS) {
|
||||
errno = ERANGE;
|
||||
NTL_POSIX_REPLY reply;
|
||||
KSTATUS status = PosixRuntimeGetProcessAttributes(&reply);
|
||||
if (!KSUCCESS(status)) {
|
||||
errno = PosixStatusToErrno(status);
|
||||
return (char*)0;
|
||||
}
|
||||
if (reply.CurrentDirectoryLength == 0 || reply.CurrentDirectoryLength > SYS_PATH_MAX ||
|
||||
reply.CurrentDirectory[reply.CurrentDirectoryLength] != '\0') {
|
||||
errno = EIO;
|
||||
return (char*)0;
|
||||
}
|
||||
|
||||
char posix[SYS_PATH_MAX + 1];
|
||||
NativeToPosix(native, posix, sizeof(posix));
|
||||
|
||||
size_t needed = strlen(posix) + 1;
|
||||
char posix[SYS_PATH_MAX + 1u];
|
||||
NativeToPosix(reply.CurrentDirectory, posix, sizeof(posix));
|
||||
size_t needed = strlen(posix) + 1u;
|
||||
if (needed > size) {
|
||||
errno = ERANGE;
|
||||
return (char*)0;
|
||||
@@ -180,26 +223,37 @@ __declspec(dllexport) int stat(const char* path, struct stat* out) {
|
||||
__declspec(dllexport) int fstat(int fd, struct stat* out) {
|
||||
if (!out) { errno = EINVAL; return -1; }
|
||||
|
||||
uint32_t pid = SysGetCurrentPid();
|
||||
FD_ENTRY* e = FdGet(pid, fd);
|
||||
if (!e) return -1;
|
||||
POSIX_OPEN_DESCRIPTION* description = PosixFdAcquire(fd);
|
||||
if (!description) return -1;
|
||||
|
||||
switch (e->Type) {
|
||||
case FD_CONSOLE_R:
|
||||
case FD_CONSOLE_W:
|
||||
case FD_DEVNULL:
|
||||
case FD_DEVZERO:
|
||||
return PosixFillSyntheticStat(S_IFCHR, out);
|
||||
case FD_SOCKET:
|
||||
return PosixFillSyntheticStat(S_IFSOCK, out);
|
||||
case FD_FILE: {
|
||||
int result = -1;
|
||||
switch (description->Type) {
|
||||
case PosixFdConsoleRead:
|
||||
case PosixFdConsoleWrite:
|
||||
case PosixFdDevNull:
|
||||
case PosixFdDevZero:
|
||||
result = PosixFillSyntheticStat(S_IFCHR, out);
|
||||
break;
|
||||
case PosixFdSocket:
|
||||
result = PosixFillSyntheticStat(S_IFSOCK, out);
|
||||
break;
|
||||
case PosixFdPipeRead:
|
||||
case PosixFdPipeWrite:
|
||||
result = PosixFillSyntheticStat(S_IFIFO, out);
|
||||
break;
|
||||
case PosixFdFile: {
|
||||
SYS_FILE_STAT nativeStat;
|
||||
uint32_t s = SysGetFileStat(e->KHandle, &nativeStat);
|
||||
if (s != 0) { errno = PosixStatusToErrno(s); return -1; }
|
||||
return PosixFillStat(&nativeStat, out);
|
||||
uint32_t status = SysGetFileStat(description->KHandle, &nativeStat);
|
||||
if (status != NTLSTATUS_SUCCESS)
|
||||
errno = PosixStatusToErrno(status);
|
||||
else
|
||||
result = PosixFillStat(&nativeStat, out);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
PosixFdRelease(description);
|
||||
return result;
|
||||
}
|
||||
Reference in new issue
Block a user