diff --git a/kernel/src/Api/BuildNo.hpp b/kernel/src/Api/BuildNo.hpp index 4969990..cd8a9ce 100644 --- a/kernel/src/Api/BuildNo.hpp +++ b/kernel/src/Api/BuildNo.hpp @@ -12,4 +12,4 @@ #pragma once -#define MONTAUK_BUILD_NUMBER 89 +#define MONTAUK_BUILD_NUMBER 90 diff --git a/programs/include/libc/unistd.h b/programs/include/libc/unistd.h index 2217bbd..7190705 100644 --- a/programs/include/libc/unistd.h +++ b/programs/include/libc/unistd.h @@ -23,6 +23,8 @@ int read(int fd, void *buf, size_t count); int write(int fd, const void *buf, size_t count); int close(int fd); long lseek(int fd, long offset, int whence); +ssize_t pread(int fd, void *buf, size_t count, off_t offset); +ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset); int chdir(const char *path); char *getcwd(char *buf, size_t size); int access(const char *path, int mode); diff --git a/programs/lib/libc/libc.c b/programs/lib/libc/libc.c index 536ca97..d6eb746 100644 --- a/programs/lib/libc/libc.c +++ b/programs/lib/libc/libc.c @@ -2047,6 +2047,24 @@ int write(int fd, const void *buf, size_t count) { return ret; } +/* + * Positioned I/O. SYS_READ/SYS_FWRITE already take an explicit file position, + * so these pass the caller's offset straight through and never consult or + * update _fd_pos -- unlike an lseek/read/lseek-back emulation, the shared file + * offset is genuinely left alone. + */ +ssize_t pread(int fd, void *buf, size_t count, off_t offset) { + if (buf == NULL || offset < 0) return -1; + return (ssize_t)_zos_syscall4(SYS_READ, (long)fd, (long)buf, + (long)offset, (long)count); +} + +ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) { + if (buf == NULL || offset < 0) return -1; + return (ssize_t)_zos_syscall4(SYS_FWRITE, (long)fd, (long)buf, + (long)offset, (long)count); +} + int close(int fd) { if (fd >= 0 && fd < _FD_POS_MAX) _fd_pos[fd] = 0; diff --git a/programs/lib/libc/obj/libc.o b/programs/lib/libc/obj/libc.o index 837de66..e8cb0ff 100644 Binary files a/programs/lib/libc/obj/libc.o and b/programs/lib/libc/obj/libc.o differ