Improve system call documentation

This change also introduces partial faccessat() support for zipos and
makes some slight breaking changes in errno results. close() is fixed
to use `EBADF` rather than `EINVAL` and we're now using `ENOTSUP` not
`EOPNOTSUPP` to indicate that zipos doesn't support a system call yet
This commit is contained in:
Justine Tunney 2022-10-02 07:42:44 -07:00
parent 0b5f84dd20
commit ad97775370
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
18 changed files with 273 additions and 67 deletions

View file

@ -21,20 +21,21 @@
#include "libc/sysv/consts/o.h"
/**
* Creates new file, returning open()'d file descriptor.
* Creates file.
*
* This function is shorthand for:
* This is equivalent to saying:
*
* open(file, O_CREAT | O_WRONLY | O_TRUNC, mode)
* int fd = openat(AT_FDCWD, file, O_CREAT | O_WRONLY | O_TRUNC, mode);
*
* @param file is a UTF-8 string, which is truncated if it exists
* @param mode is an octal user/group/other permission, e.g. 0755
* @return a number registered with the system to track the open file,
* which must be stored using a 64-bit type in order to support both
* System V and Windows, and must be closed later on using close()
* @see open(), touch()
* @param file specifies filesystem path to create
* @param mode is octal bits, e.g. 0644 usually
* @return file descriptor, or -1 w/ errno
* @see openat() for further documentation
* @asyncsignalsafe
* @restartable
* @threadsafe
* @vforksafe
*/
dontdiscard int creat(const char *file, uint32_t mode) {
int creat(const char *file, uint32_t mode) {
return openat(AT_FDCWD, file, O_CREAT | O_WRONLY | O_TRUNC, mode);
}