os, syscall: implement ReadAt for unix

Windows will take more work, so test is skipped there.
This commit is contained in:
Dan Kegel
2021-11-20 11:43:52 -08:00
committed by Ron Evans
parent 47db50b273
commit f79f6b0e62
7 changed files with 102 additions and 3 deletions
+13
View File
@@ -37,6 +37,15 @@ func Read(fd int, p []byte) (n int, err error) {
return
}
func Pread(fd int, p []byte, offset int64) (n int, err error) {
buf, count := splitSlice(p)
n = libc_pread(int32(fd), buf, uint(count), offset)
if n < 0 {
err = getErrno()
}
return
}
func Seek(fd int, offset int64, whence int) (off int64, err error) {
return 0, ENOSYS // TODO
}
@@ -169,6 +178,10 @@ func libc_getenv(name *byte) *byte
//export read
func libc_read(fd int32, buf *byte, count uint) int
// ssize_t pread(int fd, void *buf, size_t count, off_t offset);
//export pread
func libc_pread(fd int32, buf *byte, count uint, offset int64) int
// int open(const char *pathname, int flags, mode_t mode);
//export open
func libc_open(pathname *byte, flags int32, mode uint32) int32