Improve docs of more system calls

This change also found a few POSIX compliance bugs with errnos. Another
bug was discovered where, on Windows, pread() and pwrite() could modify
the file position in cases where ReadFile() returned an error e.g. when
seeking past the end of file. We also have more tests!
This commit is contained in:
Justine Tunney 2022-10-02 22:14:33 -07:00
parent af24c19db3
commit ccbae7799e
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
39 changed files with 589 additions and 175 deletions

View file

@ -29,7 +29,9 @@
#include "libc/sysv/errfuns.h"
/**
* Writes to file at offset, thus avoiding superfluous lseek().
* Writes to file at offset.
*
* This function never changes the current position of `fd`.
*
* @param fd is something open()'d earlier, noting pipes might not work
* @param buf is copied from, cf. copy_file_range(), sendfile(), etc.
@ -41,6 +43,7 @@
* impossible unless size was passed as zero to do an error check
* @see pread(), write()
* @asyncsignalsafe
* @threadsafe
* @vforksafe
*/
ssize_t pwrite(int fd, const void *buf, size_t size, int64_t offset) {