libc: add pread, pwrite; sys_pread, sys_pwrite

This commit is contained in:
K. Lange 2024-02-08 16:48:44 +09:00
parent b96c18b508
commit 2eb7d97464
3 changed files with 25 additions and 0 deletions

View File

@ -106,4 +106,7 @@ extern long pathconf(const char *path, int name);
extern int getgroups(int size, gid_t list[]);
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);
_End_C_Header

11
libc/unistd/pread.c Normal file
View File

@ -0,0 +1,11 @@
#include <unistd.h>
#include <errno.h>
#include <syscall.h>
#include <syscall_nums.h>
DEFN_SYSCALL4(pread, SYS_PREAD, int, void *, size_t, off_t);
ssize_t pread(int fd, void *buf, size_t count, off_t offset) {
__sets_errno(syscall_pread(fd,buf,count,offset));
}

11
libc/unistd/pwrite.c Normal file
View File

@ -0,0 +1,11 @@
#include <unistd.h>
#include <errno.h>
#include <syscall.h>
#include <syscall_nums.h>
DEFN_SYSCALL4(pwrite, SYS_PWRITE, int, const void *, size_t, off_t);
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) {
__sets_errno(syscall_pwrite(fd,buf,count,offset));
}