feat: libc - add pread/pwrite
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018Ae69wJS7sueQMUwNxV3nX
This commit is contained in:
@@ -12,4 +12,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define MONTAUK_BUILD_NUMBER 89
|
#define MONTAUK_BUILD_NUMBER 90
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ int read(int fd, void *buf, size_t count);
|
|||||||
int write(int fd, const void *buf, size_t count);
|
int write(int fd, const void *buf, size_t count);
|
||||||
int close(int fd);
|
int close(int fd);
|
||||||
long lseek(int fd, long offset, int whence);
|
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);
|
int chdir(const char *path);
|
||||||
char *getcwd(char *buf, size_t size);
|
char *getcwd(char *buf, size_t size);
|
||||||
int access(const char *path, int mode);
|
int access(const char *path, int mode);
|
||||||
|
|||||||
@@ -2047,6 +2047,24 @@ int write(int fd, const void *buf, size_t count) {
|
|||||||
return ret;
|
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) {
|
int close(int fd) {
|
||||||
if (fd >= 0 && fd < _FD_POS_MAX)
|
if (fd >= 0 && fd < _FD_POS_MAX)
|
||||||
_fd_pos[fd] = 0;
|
_fd_pos[fd] = 0;
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user