9.7 read/write

ssize_t read(int fd, void *buffer, size_t count, size_t offset, int flags);
ssize_t write(int fd, void *buffer, size_t count, size_t offset, int flags);

These syscalls attempts to read or write up to passed count from the passed file descriptor.

On files that support seeking, the operation commences at the file offset, and the file offset is incremented by the number of bytes read or written. If the file offset is at or past the end of file, no bytes are read or written, and the operation returns zero.

offset can be used to pass an offset in conjunction with flags.

flags for now only supports being 0 or 1. If 0, it will update the offset in file as normal, if 1, it will not update the offset, and instead of using the local offset, will start the operation from offset, to do an operation similar to POSIX-standard pread and pwrite.

These syscalls returns the number of bytes operated on, or -1 on failure. errno is to be set to: