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

@ -18,10 +18,10 @@
*/
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/calls/syscall-nt.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sysv/errfuns.h"
/**
@ -38,16 +38,19 @@
* @param newfd if already assigned, is silently closed beforehand;
* unless it's equal to oldfd, in which case dup2() is a no-op
* @return new file descriptor, or -1 w/ errno
* @raise EBADF is oldfd isn't open
* @raise EBADF is newfd negative or too big
* @raise EPERM if pledge() is in play without stdio
* @raise EMFILE if `RLIMIT_NOFILE` has been reached
* @raise ENOTSUP if `oldfd` is on zip file system
* @raise EINTR if a signal handler was called
* @raise EBADF is `newfd` negative or too big
* @raise EBADF is `oldfd` isn't open
* @asyncsignalsafe
* @vforksafe
*/
int dup2(int oldfd, int newfd) {
int rc;
if (__isfdkind(oldfd, kFdZip)) {
rc = eopnotsupp();
rc = enotsup();
} else if (!IsWindows()) {
rc = sys_dup2(oldfd, newfd);
} else if (newfd < 0) {