diff --git a/build/bootstrap/compile.com b/build/bootstrap/compile.com index 0073592d..c460b3c6 100755 Binary files a/build/bootstrap/compile.com and b/build/bootstrap/compile.com differ diff --git a/examples/curl.c b/examples/curl.c index b46b4262..5915815a 100644 --- a/examples/curl.c +++ b/examples/curl.c @@ -20,7 +20,6 @@ #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/af.h" -#include "libc/sysv/consts/ai.h" #include "libc/sysv/consts/ipproto.h" #include "libc/sysv/consts/shut.h" #include "libc/sysv/consts/sock.h" diff --git a/libc/calls/calls.h b/libc/calls/calls.h index 360a7104..13dcf495 100644 --- a/libc/calls/calls.h +++ b/libc/calls/calls.h @@ -137,8 +137,8 @@ int mlockall(int); int munlock(const void *, size_t); int munlockall(void); int nice(int); -int open(const char *, int, ...) nodiscard; -int openanon(char *, unsigned) nodiscard; +int open(const char *, int, ...); +int openanon(char *, unsigned); int openat(int, const char *, int, ...); int pause(void); int personality(uint64_t); @@ -176,7 +176,7 @@ int stat(const char *, struct stat *); int symlink(const char *, const char *); int symlinkat(const char *, int, const char *); int sync_file_range(int, int64_t, int64_t, unsigned); -int sysinfo(struct sysinfo *) paramsnonnull(); +int sysinfo(struct sysinfo *); int touch(const char *, uint32_t); int truncate(const char *, uint64_t); int ttyname_r(int, char *, size_t); diff --git a/libc/calls/fcntl-nt.c b/libc/calls/fcntl-nt.c index 7dce493b..0017fc32 100644 --- a/libc/calls/fcntl-nt.c +++ b/libc/calls/fcntl-nt.c @@ -18,45 +18,98 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/internal.h" +#include "libc/calls/struct/flock.h" #include "libc/nt/enum/accessmask.h" #include "libc/nt/enum/fileflagandattributes.h" +#include "libc/nt/enum/filelockflags.h" #include "libc/nt/enum/filesharemode.h" #include "libc/nt/files.h" +#include "libc/nt/struct/byhandlefileinformation.h" +#include "libc/nt/struct/overlapped.h" #include "libc/sysv/consts/f.h" #include "libc/sysv/consts/fd.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/errfuns.h" -textwindows int sys_fcntl_nt(int fd, int cmd, unsigned arg) { +static textwindows int sys_fcntl_nt_lock(struct Fd *f, int cmd, uintptr_t arg) { + uint32_t flags; + struct flock *l; + struct NtOverlapped ov; + int64_t pos, off, len, size; + struct NtByHandleFileInformation info; + l = (struct flock *)arg; + len = l->l_len; + off = l->l_start; + if (!len || l->l_whence == SEEK_END) { + if (!GetFileInformationByHandle(f->handle, &info)) return __winerr(); + size = (uint64_t)info.nFileSizeHigh << 32 | info.nFileSizeLow; + } else { + size = 0; + } + if (l->l_whence != SEEK_SET) { + if (l->l_whence == SEEK_CUR) { + if (!SetFilePointerEx(f->handle, 0, &pos, SEEK_CUR)) return __winerr(); + off = pos + off; + } else if (l->l_whence == SEEK_END) { + off = size - off; + } else { + return einval(); + } + } + if (!len) len = size - off; + if (off < 0 || len < 0) return einval(); + offset2overlap(off, &ov); + if (l->l_type == F_RDLCK || l->l_type == F_WRLCK) { + flags = 0; + if (cmd == F_SETLK) flags |= kNtLockfileFailImmediately; + if (l->l_type == F_WRLCK) flags |= kNtLockfileExclusiveLock; + if (LockFileEx(f->handle, flags, 0, len, len >> 32, &ov)) { + return 0; + } else { + return __winerr(); + } + } else if (l->l_type == F_UNLCK) { + if (UnlockFileEx(f->handle, 0, len, len >> 32, &ov)) { + return 0; + } else { + return __winerr(); + } + } else { + return einval(); + } +} + +textwindows int sys_fcntl_nt(int fd, int cmd, uintptr_t arg) { uint32_t flags; if (__isfdkind(fd, kFdFile) || __isfdkind(fd, kFdSocket)) { - switch (cmd) { - case F_GETFL: - return g_fds.p[fd].flags & (O_ACCMODE | O_APPEND | O_ASYNC | O_DIRECT | - O_NOATIME | O_NONBLOCK); - case F_SETFL: - /* - * - O_APPEND doesn't appear to be tunable at cursory glance - * - O_NONBLOCK might require we start doing all i/o in threads - * - O_DSYNC / O_RSYNC / O_SYNC maybe if we fsync() everything - */ - return einval(); - case F_GETFD: - if (g_fds.p[fd].flags & O_CLOEXEC) { - return FD_CLOEXEC; - } else { - return 0; - } - case F_SETFD: - if (arg & FD_CLOEXEC) { - g_fds.p[fd].flags |= O_CLOEXEC; - return FD_CLOEXEC; - } else { - g_fds.p[fd].flags &= ~O_CLOEXEC; - return 0; - } - default: - return einval(); + if (cmd == F_GETFL) { + return g_fds.p[fd].flags & (O_ACCMODE | O_APPEND | O_ASYNC | O_DIRECT | + O_NOATIME | O_NONBLOCK); + } else if (cmd == F_SETFL) { + /* + * - O_APPEND doesn't appear to be tunable at cursory glance + * - O_NONBLOCK might require we start doing all i/o in threads + * - O_DSYNC / O_RSYNC / O_SYNC maybe if we fsync() everything + */ + return einval(); + } else if (cmd == F_GETFD) { + if (g_fds.p[fd].flags & O_CLOEXEC) { + return FD_CLOEXEC; + } else { + return 0; + } + } else if (cmd == F_SETFD) { + if (arg & FD_CLOEXEC) { + g_fds.p[fd].flags |= O_CLOEXEC; + return FD_CLOEXEC; + } else { + g_fds.p[fd].flags &= ~O_CLOEXEC; + return 0; + } + } else if (cmd == F_SETLK || cmd == F_SETLKW) { + return sys_fcntl_nt_lock(g_fds.p + fd, cmd, arg); + } else { + return einval(); } } else { return ebadf(); diff --git a/libc/calls/fcntl-sysv.c b/libc/calls/fcntl-sysv.c new file mode 100644 index 00000000..0e9a04ff --- /dev/null +++ b/libc/calls/fcntl-sysv.c @@ -0,0 +1,31 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2021 Justine Alexandra Roberts Tunney │ +│ │ +│ Permission to use, copy, modify, and/or distribute this software for │ +│ any purpose with or without fee is hereby granted, provided that the │ +│ above copyright notice and this permission notice appear in all copies. │ +│ │ +│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ +│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ +│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ +│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ +│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ +│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ +│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ +│ PERFORMANCE OF THIS SOFTWARE. │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/internal.h" +#include "libc/calls/struct/flock.h" +#include "libc/sysv/consts/f.h" + +int sys_fcntl(int fd, int cmd, uintptr_t arg) { + int rc; + bool islock; + islock = cmd == F_SETLK || cmd == F_SETLKW || cmd == F_GETLK; + if (islock) cosmo2flock(arg); + rc = __sys_fcntl(fd, cmd, arg); + if (islock) flock2cosmo(arg); + return rc; +} diff --git a/libc/calls/fcntl.c b/libc/calls/fcntl.c index 665a2acd..eff0dd9b 100644 --- a/libc/calls/fcntl.c +++ b/libc/calls/fcntl.c @@ -25,6 +25,12 @@ * * CHECK_NE(-1, fcntl(fd, F_SETFD, FD_CLOEXEC)); * + * This function implements POSIX Advisory Locks, e.g. + * + * CHECK_NE(-1, fcntl(zfd, F_SETLKW, &(struct flock){F_WRLCK})); + * // ... + * CHECK_NE(-1, fcntl(zfd, F_SETLK, &(struct flock){F_UNLCK})); + * * @param cmd can be F_{GET,SET}{FD,FL}, etc. * @param arg can be FD_CLOEXEC, etc. depending * @return 0 on success, or -1 w/ errno @@ -32,9 +38,9 @@ */ int fcntl(int fd, int cmd, ...) { va_list va; - unsigned arg; + uintptr_t arg; va_start(va, cmd); - arg = va_arg(va, unsigned); + arg = va_arg(va, uintptr_t); va_end(va); if (!IsWindows()) { return sys_fcntl(fd, cmd, arg); diff --git a/libc/calls/fixupnewfd.c b/libc/calls/fixupnewfd.c index 893601ba..c7a65c92 100644 --- a/libc/calls/fixupnewfd.c +++ b/libc/calls/fixupnewfd.c @@ -28,7 +28,7 @@ int __fixupnewfd(int fd, int flags) { if (fd != -1) { if (flags & O_CLOEXEC) { - sys_fcntl(fd, F_SETFD, FD_CLOEXEC); + __sys_fcntl(fd, F_SETFD, FD_CLOEXEC); } } return fd; diff --git a/libc/calls/flock.c b/libc/calls/flock.c index 1fbdae7b..c8f7af7f 100644 --- a/libc/calls/flock.c +++ b/libc/calls/flock.c @@ -23,6 +23,8 @@ /** * Acquires lock on file. * + * Please note multiple file descriptors means multiple locks. + * * @param op can have LOCK_{SH,EX,NB,UN} for shared, exclusive, * non-blocking, and unlocking * @return 0 on success, or -1 w/ errno diff --git a/libc/calls/fstat.c b/libc/calls/fstat.c index 0d5a0290..553f6b08 100644 --- a/libc/calls/fstat.c +++ b/libc/calls/fstat.c @@ -20,6 +20,7 @@ #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/dce.h" +#include "libc/intrin/asan.internal.h" #include "libc/sysv/errfuns.h" #include "libc/zipos/zipos.internal.h" @@ -28,6 +29,7 @@ * @asyncsignalsafe */ int fstat(int fd, struct stat *st) { + if (IsAsan() && (!st || !__asan_is_valid(st, sizeof(*st)))) return efault(); if (__isfdkind(fd, kFdZip)) { return weaken(__zipos_fstat)( (struct ZiposHandle *)(intptr_t)g_fds.p[fd].handle, st); diff --git a/libc/calls/fstatat.c b/libc/calls/fstatat.c index cb6c4a55..e9187388 100644 --- a/libc/calls/fstatat.c +++ b/libc/calls/fstatat.c @@ -20,7 +20,9 @@ #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/errno.h" +#include "libc/intrin/asan.internal.h" #include "libc/sysv/consts/at.h" +#include "libc/sysv/errfuns.h" #include "libc/zipos/zipos.internal.h" /** @@ -36,6 +38,7 @@ */ int fstatat(int dirfd, const char *path, struct stat *st, uint32_t flags) { struct ZiposUri zipname; + if (IsAsan() && (!st || !__asan_is_valid(st, sizeof(*st)))) return efault(); if (weaken(__zipos_stat) && weaken(__zipos_parseuri)(path, &zipname) != -1) { return weaken(__zipos_stat)(&zipname, st); } else if (!IsWindows()) { diff --git a/libc/calls/getcwd-xnu.c b/libc/calls/getcwd-xnu.c index c1ea1ec1..960d5691 100644 --- a/libc/calls/getcwd-xnu.c +++ b/libc/calls/getcwd-xnu.c @@ -34,7 +34,7 @@ char *sys_getcwd_xnu(char *res, size_t size) { if ((fd = sys_openat(AT_FDCWD, ".", O_RDONLY | O_DIRECTORY, 0)) != -1) { if (sys_fstat(fd, &st[0]) != -1) { if (st[0].st_dev && st[0].st_ino) { - if (sys_fcntl(fd, XNU_F_GETPATH, buf) != -1) { + if (__sys_fcntl(fd, XNU_F_GETPATH, (uintptr_t)buf) != -1) { if (sys_fstatat(AT_FDCWD, buf, &st[1], 0) != -1) { if (st[0].st_dev == st[1].st_dev && st[0].st_ino == st[1].st_ino) { if (memccpy(res, buf, '\0', size)) { diff --git a/libc/calls/getppid.c b/libc/calls/getppid.c index e4dbd566..7ab0b7c4 100644 --- a/libc/calls/getppid.c +++ b/libc/calls/getppid.c @@ -22,7 +22,7 @@ * Returns parent process id. * @asyncsignalsafe */ -int32_t getppid(void) { +int getppid(void) { if (!IsWindows()) { if (!IsNetbsd()) { return sys_getppid(); diff --git a/libc/calls/internal.h b/libc/calls/internal.h index 4c557186..c1fe14cc 100644 --- a/libc/calls/internal.h +++ b/libc/calls/internal.h @@ -109,6 +109,7 @@ char *sys_getcwd(char *, u64) hidden; char *sys_getcwd_xnu(char *, u64) hidden; i32 __sys_dup3(i32, i32, i32) hidden; i32 __sys_execve(const char *, char *const[], char *const[]) hidden; +i32 __sys_fcntl(i32, i32, u64) hidden; i32 __sys_fstat(i32, struct stat *) hidden; i32 __sys_fstatat(i32, const char *, struct stat *, i32) hidden; i32 __sys_getrusage(i32, struct rusage *) hidden; @@ -131,7 +132,7 @@ i32 sys_fchmod(i32, u32) hidden; i32 sys_fchmodat(i32, const char *, u32, u32) hidden; i32 sys_fchown(i64, u32, u32) hidden; i32 sys_fchownat(i32, const char *, u32, u32, u32) hidden; -i32 sys_fcntl(i32, i32, ...) hidden; +i32 sys_fcntl(i32, i32, u64) hidden; i32 sys_fdatasync(i32) hidden; i32 sys_flock(i32, i32) hidden; i32 sys_fstat(i32, struct stat *) hidden; @@ -229,6 +230,8 @@ int gethostname_nt(char *, size_t) hidden; size_t __iovec_size(const struct iovec *, size_t) hidden; void __rusage2linux(struct rusage *) hidden; ssize_t WritevUninterruptible(int, struct iovec *, int); +void flock2cosmo(uintptr_t); +void cosmo2flock(uintptr_t); /*───────────────────────────────────────────────────────────────────────────│─╗ │ cosmopolitan § syscalls » windows nt » veneers ─╬─│┼ @@ -245,7 +248,7 @@ int sys_execve_nt(const char *, char *const[], char *const[]) hidden; int sys_faccessat_nt(int, const char *, int, uint32_t) hidden; int sys_fadvise_nt(int, u64, u64, int) hidden; int sys_fchdir_nt(int) hidden; -int sys_fcntl_nt(int, int, unsigned) hidden; +int sys_fcntl_nt(int, int, uintptr_t) hidden; int sys_fdatasync_nt(int) hidden; int sys_flock_nt(int, int) hidden; int sys_fork_nt(void) hidden; diff --git a/libc/calls/metaflock.c b/libc/calls/metaflock.c new file mode 100644 index 00000000..a13b891c --- /dev/null +++ b/libc/calls/metaflock.c @@ -0,0 +1,164 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2021 Justine Alexandra Roberts Tunney │ +│ │ +│ Permission to use, copy, modify, and/or distribute this software for │ +│ any purpose with or without fee is hereby granted, provided that the │ +│ above copyright notice and this permission notice appear in all copies. │ +│ │ +│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ +│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ +│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ +│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ +│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ +│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ +│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ +│ PERFORMANCE OF THIS SOFTWARE. │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/internal.h" +#include "libc/calls/struct/flock.h" + +union metaflock { + struct flock cosmo; + struct flock_linux { + int16_t l_type; + int16_t l_whence; + int64_t l_start; + int64_t l_len; + int32_t l_pid; + } linux; + struct flock_xnu { + int64_t l_start; + int64_t l_len; + int32_t l_pid; + int16_t l_type; + int16_t l_whence; + } xnu; + struct flock_freebsd { + int64_t l_start; + int64_t l_len; + int32_t l_pid; + int16_t l_type; + int16_t l_whence; + int32_t l_sysid; + } freebsd; + struct flock_openbsd { + int64_t l_start; + int64_t l_len; + int32_t l_pid; + int16_t l_type; + int16_t l_whence; + } openbsd; + struct flock_netbsd { + int64_t l_start; + int64_t l_len; + int32_t l_pid; + int16_t l_type; + int16_t l_whence; + } netbsd; +}; + +void flock2cosmo(uintptr_t memory) { + int64_t l_start; + int64_t l_len; + int32_t l_pid; + int16_t l_type; + int16_t l_whence; + int32_t l_sysid; + union metaflock *u; + u = (union metaflock *)memory; + if (IsLinux()) { + l_start = u->linux.l_start; + l_len = u->linux.l_len; + l_pid = u->linux.l_pid; + l_type = u->linux.l_type; + l_whence = u->linux.l_whence; + l_sysid = 0; + } else if (IsXnu()) { + l_start = u->xnu.l_start; + l_len = u->xnu.l_len; + l_pid = u->xnu.l_pid; + l_type = u->xnu.l_type; + l_whence = u->xnu.l_whence; + l_sysid = 0; + } else if (IsFreebsd()) { + l_start = u->freebsd.l_start; + l_len = u->freebsd.l_len; + l_pid = u->freebsd.l_pid; + l_type = u->freebsd.l_type; + l_whence = u->freebsd.l_whence; + l_sysid = u->freebsd.l_sysid; + } else if (IsOpenbsd()) { + l_start = u->openbsd.l_start; + l_len = u->openbsd.l_len; + l_pid = u->openbsd.l_pid; + l_type = u->openbsd.l_type; + l_whence = u->openbsd.l_whence; + l_sysid = 0; + } else if (IsNetbsd()) { + l_start = u->netbsd.l_start; + l_len = u->netbsd.l_len; + l_pid = u->netbsd.l_pid; + l_type = u->netbsd.l_type; + l_whence = u->netbsd.l_whence; + l_sysid = 0; + } else { + return; + } + u->cosmo.l_start = l_start; + u->cosmo.l_len = l_len; + u->cosmo.l_pid = l_pid; + u->cosmo.l_type = l_type; + u->cosmo.l_whence = l_whence; + u->cosmo.l_sysid = l_sysid; +} + +void cosmo2flock(uintptr_t memory) { + int64_t l_start; + int64_t l_len; + int32_t l_pid; + int16_t l_type; + int16_t l_whence; + int32_t l_sysid; + union metaflock *u; + u = (union metaflock *)memory; + l_start = u->cosmo.l_start; + l_len = u->cosmo.l_len; + l_pid = u->cosmo.l_pid; + l_type = u->cosmo.l_type; + l_whence = u->cosmo.l_whence; + l_sysid = u->cosmo.l_sysid; + if (IsLinux()) { + u->linux.l_start = l_start; + u->linux.l_len = l_len; + u->linux.l_pid = l_pid; + u->linux.l_type = l_type; + u->linux.l_whence = l_whence; + } else if (IsXnu()) { + u->xnu.l_start = l_start; + u->xnu.l_len = l_len; + u->xnu.l_pid = l_pid; + u->xnu.l_type = l_type; + u->xnu.l_whence = l_whence; + } else if (IsFreebsd()) { + u->freebsd.l_start = l_start; + u->freebsd.l_len = l_len; + u->freebsd.l_pid = l_pid; + u->freebsd.l_type = l_type; + u->freebsd.l_whence = l_whence; + u->freebsd.l_sysid = l_sysid; + } else if (IsOpenbsd()) { + u->openbsd.l_start = l_start; + u->openbsd.l_len = l_len; + u->openbsd.l_pid = l_pid; + u->openbsd.l_type = l_type; + u->openbsd.l_whence = l_whence; + } else if (IsNetbsd()) { + u->netbsd.l_start = l_start; + u->netbsd.l_len = l_len; + u->netbsd.l_pid = l_pid; + u->netbsd.l_type = l_type; + u->netbsd.l_whence = l_whence; + } +} diff --git a/libc/calls/openat-sysv.c b/libc/calls/openat-sysv.c index 2bfbfdea..09dfc678 100644 --- a/libc/calls/openat-sysv.c +++ b/libc/calls/openat-sysv.c @@ -36,7 +36,7 @@ int sys_openat(int dirfd, const char *file, int flags, unsigned mode) { errno = err; fd = __sys_openat(dirfd, file, flags & ~O_CLOEXEC, mode); if (fd != -1 && (flags & O_CLOEXEC)) { - sys_fcntl(fd, F_SETFD, FD_CLOEXEC); + __sys_fcntl(fd, F_SETFD, FD_CLOEXEC); } } diff --git a/libc/calls/preadv.c b/libc/calls/preadv.c index 2467b937..3ad2b28f 100644 --- a/libc/calls/preadv.c +++ b/libc/calls/preadv.c @@ -23,6 +23,7 @@ #include "libc/calls/struct/iovec.h" #include "libc/dce.h" #include "libc/errno.h" +#include "libc/intrin/asan.internal.h" #include "libc/macros.internal.h" #include "libc/sysv/consts/iov.h" #include "libc/sysv/errfuns.h" @@ -45,6 +46,7 @@ ssize_t preadv(int fd, struct iovec *iov, int iovlen, int64_t off) { if (fd < 0) return einval(); if (iovlen < 0) return einval(); + if (IsAsan() && !__asan_is_valid_iov(iov, iovlen)) return efault(); if (fd < g_fds.n && g_fds.p[fd].kind == kFdZip) { return weaken(__zipos_read)( (struct ZiposHandle *)(intptr_t)g_fds.p[fd].handle, iov, iovlen, off); diff --git a/libc/calls/pwritev.c b/libc/calls/pwritev.c index 54231e6e..036ddfdb 100644 --- a/libc/calls/pwritev.c +++ b/libc/calls/pwritev.c @@ -22,6 +22,7 @@ #include "libc/calls/struct/iovec.h" #include "libc/dce.h" #include "libc/errno.h" +#include "libc/intrin/asan.internal.h" #include "libc/macros.internal.h" #include "libc/sysv/consts/iov.h" #include "libc/sysv/errfuns.h" @@ -49,6 +50,7 @@ ssize_t pwritev(int fd, const struct iovec *iov, int iovlen, int64_t off) { if (fd < 0) return einval(); if (iovlen < 0) return einval(); + if (IsAsan() && !__asan_is_valid_iov(iov, iovlen)) return efault(); if (fd < g_fds.n && g_fds.p[fd].kind == kFdZip) { return weaken(__zipos_write)( (struct ZiposHandle *)(intptr_t)g_fds.p[fd].handle, iov, iovlen, off); diff --git a/libc/calls/readv.c b/libc/calls/readv.c index 24212c20..0d2087aa 100644 --- a/libc/calls/readv.c +++ b/libc/calls/readv.c @@ -20,6 +20,7 @@ #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/intrin/asan.internal.h" #include "libc/sock/internal.h" #include "libc/sysv/errfuns.h" #include "libc/zipos/zipos.internal.h" @@ -31,18 +32,21 @@ * @asyncsignalsafe */ ssize_t readv(int fd, const struct iovec *iov, int iovlen) { - if (fd < 0) return einval(); - if (iovlen < 0) return einval(); - if (fd < g_fds.n && g_fds.p[fd].kind == kFdZip) { - return weaken(__zipos_read)( - (struct ZiposHandle *)(intptr_t)g_fds.p[fd].handle, iov, iovlen, -1); - } else if (!IsWindows() && !IsMetal()) { - return sys_readv(fd, iov, iovlen); - } else if (fd >= g_fds.n) { - return ebadf(); - } else if (IsMetal()) { - return sys_readv_metal(g_fds.p + fd, iov, iovlen); + if (fd >= 0 && iovlen >= 0) { + if (IsAsan() && !__asan_is_valid_iov(iov, iovlen)) return efault(); + if (fd < g_fds.n && g_fds.p[fd].kind == kFdZip) { + return weaken(__zipos_read)( + (struct ZiposHandle *)(intptr_t)g_fds.p[fd].handle, iov, iovlen, -1); + } else if (!IsWindows() && !IsMetal()) { + return sys_readv(fd, iov, iovlen); + } else if (fd >= g_fds.n) { + return ebadf(); + } else if (IsMetal()) { + return sys_readv_metal(g_fds.p + fd, iov, iovlen); + } else { + return sys_readv_nt(g_fds.p + fd, iov, iovlen); + } } else { - return sys_readv_nt(g_fds.p + fd, iov, iovlen); + return einval(); } } diff --git a/libc/calls/struct/flock.h b/libc/calls/struct/flock.h index 52319ee3..2a965057 100644 --- a/libc/calls/struct/flock.h +++ b/libc/calls/struct/flock.h @@ -2,12 +2,13 @@ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_FLOCK_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) -struct flock { - short l_type; - short l_whence; - int64_t l_start; - int64_t l_len; - int l_pid; +struct flock { /* cosmopolitan abi */ + int16_t l_type; /* F_RDLCK, F_WRLCK, F_UNLCK */ + int16_t l_whence; /* SEEK_SET, SEEK_CUR, SEEK_END */ + int64_t l_start; /* starting offset */ + int64_t l_len; /* 0 means until end of file */ + int32_t l_pid; /* lock owner */ + int32_t l_sysid; /* remote system id or zero for local */ }; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/sysinfo.c b/libc/calls/sysinfo.c index 108b8491..f061cf1c 100644 --- a/libc/calls/sysinfo.c +++ b/libc/calls/sysinfo.c @@ -21,11 +21,13 @@ #include "libc/calls/internal.h" #include "libc/calls/struct/sysinfo.h" #include "libc/dce.h" +#include "libc/intrin/asan.internal.h" #include "libc/nt/accounting.h" #include "libc/nt/runtime.h" #include "libc/nt/struct/memorystatusex.h" #include "libc/nt/systeminfo.h" #include "libc/str/str.h" +#include "libc/sysv/errfuns.h" /** * Returns amount of system ram, cores, etc. @@ -34,6 +36,11 @@ */ int sysinfo(struct sysinfo *info) { int rc; + if (IsAsan()) { + if (info && !__asan_is_valid(info, sizeof(*info))) { + return efault(); + } + } memset(info, 0, sizeof(*info)); if (!IsWindows()) { rc = sys_sysinfo(info); diff --git a/libc/calls/utimes.c b/libc/calls/utimes.c index 7fe81254..1f4f8edc 100644 --- a/libc/calls/utimes.c +++ b/libc/calls/utimes.c @@ -18,7 +18,9 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/internal.h" #include "libc/dce.h" +#include "libc/intrin/asan.internal.h" #include "libc/sysv/consts/at.h" +#include "libc/sysv/errfuns.h" #include "libc/time/time.h" /** @@ -30,6 +32,11 @@ * @see stat() */ int utimes(const char *path, const struct timeval tv[2]) { + if (IsAsan()) { + if (tv && !__asan_is_valid(tv, sizeof(*tv) * 2)) { + return efault(); + } + } if (!IsWindows()) { /* * we don't modernize utimes() into utimensat() because the diff --git a/libc/calls/wait4.c b/libc/calls/wait4.c index 564a6484..420ef53e 100644 --- a/libc/calls/wait4.c +++ b/libc/calls/wait4.c @@ -20,6 +20,8 @@ #include "libc/calls/internal.h" #include "libc/calls/wait4.h" #include "libc/dce.h" +#include "libc/intrin/asan.internal.h" +#include "libc/sysv/errfuns.h" /** * Waits for status to change on process. @@ -35,6 +37,16 @@ */ int wait4(int pid, int *opt_out_wstatus, int options, struct rusage *opt_out_rusage) { + if (IsAsan()) { + if (opt_out_wstatus && + !__asan_is_valid(opt_out_wstatus, sizeof(*opt_out_wstatus))) { + return efault(); + } + if (opt_out_rusage && + !__asan_is_valid(opt_out_rusage, sizeof(*opt_out_rusage))) { + return efault(); + } + } if (!IsWindows()) { return sys_wait4(pid, opt_out_wstatus, options, opt_out_rusage); } else { diff --git a/libc/calls/writev.c b/libc/calls/writev.c index 53821450..e6d31258 100644 --- a/libc/calls/writev.c +++ b/libc/calls/writev.c @@ -19,6 +19,7 @@ #include "libc/bits/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" +#include "libc/intrin/asan.internal.h" #include "libc/sock/internal.h" #include "libc/sysv/errfuns.h" #include "libc/zipos/zipos.internal.h" @@ -34,18 +35,21 @@ * @return number of bytes actually handed off, or -1 w/ errno */ ssize_t writev(int fd, const struct iovec *iov, int iovlen) { - if (fd < 0) return einval(); - if (iovlen < 0) return einval(); - if (fd < g_fds.n && g_fds.p[fd].kind == kFdZip) { - return weaken(__zipos_write)( - (struct ZiposHandle *)(intptr_t)g_fds.p[fd].handle, iov, iovlen, -1); - } else if (!IsWindows() && !IsMetal()) { - return sys_writev(fd, iov, iovlen); - } else if (fd >= g_fds.n) { - return ebadf(); - } else if (IsMetal()) { - return sys_writev_metal(g_fds.p + fd, iov, iovlen); + if (fd >= 0 && iovlen >= 0) { + if (IsAsan() && !__asan_is_valid_iov(iov, iovlen)) return efault(); + if (fd < g_fds.n && g_fds.p[fd].kind == kFdZip) { + return weaken(__zipos_write)( + (struct ZiposHandle *)(intptr_t)g_fds.p[fd].handle, iov, iovlen, -1); + } else if (!IsWindows() && !IsMetal()) { + return sys_writev(fd, iov, iovlen); + } else if (fd >= g_fds.n) { + return ebadf(); + } else if (IsMetal()) { + return sys_writev_metal(g_fds.p + fd, iov, iovlen); + } else { + return sys_writev_nt(g_fds.p + fd, iov, iovlen); + } } else { - return sys_writev_nt(g_fds.p + fd, iov, iovlen); + return einval(); } } diff --git a/libc/dce.h b/libc/dce.h index 73cde783..6b02b308 100644 --- a/libc/dce.h +++ b/libc/dce.h @@ -57,6 +57,12 @@ #define IsOptimized() 0 #endif +#ifdef __FSANITIZE_ADDRESS__ +#define IsAsan() 1 +#else +#define IsAsan() 0 +#endif + #if defined(__PIE__) || defined(__PIC__) #define IsPositionIndependent() 1 #else diff --git a/libc/dns/dns.h b/libc/dns/dns.h index 5205a42a..48bc50b7 100644 --- a/libc/dns/dns.h +++ b/libc/dns/dns.h @@ -27,6 +27,15 @@ #define EAI_INTR -104 #define EAI_NOTCANCELED -102 +/* AI_* conforms to NT ABI */ +#define AI_PASSIVE 1 +#define AI_CANONNAME 2 +#define AI_NUMERICHOST 4 +#define AI_NUMERICSERV 8 +#define AI_ALL 0x0100 +#define AI_ADDRCONFIG 0x0400 +#define AI_V4MAPPED 0x0800 + #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ diff --git a/libc/dns/getaddrinfo.c b/libc/dns/getaddrinfo.c index 3443877e..76cb26a3 100644 --- a/libc/dns/getaddrinfo.c +++ b/libc/dns/getaddrinfo.c @@ -26,7 +26,6 @@ #include "libc/sock/sock.h" #include "libc/str/str.h" #include "libc/sysv/consts/af.h" -#include "libc/sysv/consts/ai.h" #include "libc/sysv/consts/inaddr.h" #include "libc/sysv/errfuns.h" diff --git a/libc/fmt/kerrornames.S b/libc/fmt/kerrornames.S index 7574a5b9..fa307292 100644 --- a/libc/fmt/kerrornames.S +++ b/libc/fmt/kerrornames.S @@ -21,7 +21,7 @@ .macro .e e .long \e - kErrorNames .long 1f - kErrorNames - .section .rodata.str1.1 + .rodata.str1.1 1: .string "\e" .previous .endm @@ -114,51 +114,5 @@ kErrorNames: .e ENOTRECOVERABLE .e ENONET .e ERESTART - .e ECHRNG - .e EL2NSYNC - .e EL3HLT - .e EL3RST - .e ELNRNG - .e EUNATCH - .e ENOCSI - .e EL2HLT - .e EBADE - .e EBADR - .e EXFULL - .e ENOANO - .e EBADRQC - .e EBADSLT - .e ENOSTR - .e ENODATA - .e ENOSR - .e ENOPKG - .e ENOLINK - .e EADV - .e ESRMNT - .e ECOMM - .e EMULTIHOP - .e EDOTDOT - .e ENOTUNIQ - .e EBADFD - .e EREMCHG - .e ELIBACC - .e ELIBBAD - .e ELIBSCN - .e ELIBMAX - .e ELIBEXEC - .e ESTRPIPE - .e EUCLEAN - .e ENOTNAM - .e ENAVAIL - .e EISNAM - .e EREMOTEIO - .e ENOMEDIUM - .e EMEDIUMTYPE - .e ENOKEY - .e EKEYEXPIRED - .e EKEYREVOKED - .e EKEYREJECTED - .e ERFKILL - .e EHWPOISON .long 0 .endobj kErrorNames,globl,hidden diff --git a/libc/intrin/asan.c b/libc/intrin/asan.c index 8c3fd939..7573af0c 100644 --- a/libc/intrin/asan.c +++ b/libc/intrin/asan.c @@ -21,6 +21,7 @@ #include "libc/bits/likely.h" #include "libc/bits/weaken.h" #include "libc/calls/calls.h" +#include "libc/calls/struct/iovec.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/log/log.h" @@ -116,7 +117,7 @@ struct AsanMorgue { static struct AsanMorgue __asan_morgue; -static uint64_t __asan_bsrl(uint64_t x) { +static inline int __asan_bsrl(uint64_t x) { return __builtin_clzll(x) ^ 63; } @@ -137,7 +138,7 @@ static size_t __asan_strlen(const char *s) { static int __asan_strcmp(const char *l, const char *r) { size_t i = 0; while (l[i] == r[i] && r[i]) ++i; - return (l[i] & 0xff) - (r[i] & 0xff); + return (l[i] & 255) - (r[i] & 255); } static char *__asan_stpcpy(char *d, const char *s) { @@ -168,7 +169,7 @@ static void *__asan_memset(void *p, int c, size_t n) { size_t i; uint64_t x; b = p; - x = 0x0101010101010101 * (c & 0xff); + x = 0x0101010101010101 * (c & 255); switch (n) { case 0: return p; @@ -293,73 +294,105 @@ static void *__asan_memcpy(void *dst, const void *src, size_t n) { return dst; } -static size_t __asan_int2hex(uint64_t x, char b[17], uint8_t k) { - int i; - char *p; - for (p = b; k > 0;) { - *p++ = "0123456789abcdef"[(x >> (k -= 4)) & 15]; - } - *p = '\0'; - return p - b; +static char *__asan_hexcpy(char *p, uint64_t x, uint8_t k) { + while (k) *p++ = "0123456789abcdef"[(x >> (k -= 4)) & 15]; + return p; } -static size_t __asan_uint2str(uint64_t i, char *a) { - size_t j; - j = 0; +static char *__asan_uint2str(char *p, uint64_t i) { + int j = 0; do { - a[j++] = i % 10 + '0'; + p[j++] = i % 10 + '0'; i /= 10; } while (i > 0); - a[j] = '\0'; - reverse(a, j); - return j; + reverse(p, j); + return p + j; } -static size_t __asan_int2str(int64_t i, char *a) { - if (i >= 0) return __asan_uint2str(i, a); - *a++ = '-'; - return 1 + __asan_uint2str(-i, a); +static char *__asan_intcpy(char *p, int64_t i) { + if (i >= 0) return __asan_uint2str(p, i); + *p++ = '-'; + return __asan_uint2str(p, -i); } -void __asan_poison(uintptr_t p, size_t n, int kind) { - int k; - char *s; - if (!n) return; - if (UNLIKELY(p & 7)) { - k = MIN(8 - (p & 7), n); - s = SHADOW(p); - if (*s == 0 || *s > (p & 7)) { - *s = p & 7; - } - n -= k; - p += k; +void __asan_poison(uintptr_t p, size_t n, int t) { + signed char k, *s; + k = p & 7; + s = (signed char *)((p >> 3) + 0x7fff8000); + if (UNLIKELY(k)) { + if (n && (!*s || *s > k) && 8 - k >= n) *s = k; + ++s, n -= MIN(8 - k, n); } - __asan_memset(SHADOW(p), kind, n >> 3); + __asan_memset(s, t, n >> 3); if ((k = n & 7)) { - s = SHADOW(p + n); - if (*s < 0 || (*s > 0 && *s >= k)) { - *s = kind; - } + s += n >> 3; + if (*s < 0 || 0 < *s && *s <= k) *s = t; } } void __asan_unpoison(uintptr_t p, size_t n) { - int k; - char *s; - if (!n) return; - if (UNLIKELY(p & 7)) { - k = MIN(8 - (p & 7), n); - s = SHADOW(p); - *s = 0; - n -= k; - p += k; + signed char k, *s; + k = p & 7; + s = (signed char *)((p >> 3) + 0x7fff8000); + if (UNLIKELY(k)) { + if (n) *s = 0; + ++s, n -= MIN(8 - k, n); } - __asan_memset(SHADOW(p), 0, n >> 3); + __asan_memset(s, 0, n >> 3); if ((k = n & 7)) { - s = SHADOW(p + n); - if (*s && *s < k) { - *s = k; + s += n >> 3; + if (*s && *s < k) *s = k; + } +} + +bool __asan_is_valid(const void *p, size_t n) { + signed char k, *s, *e; + if (n) { + k = (uintptr_t)p & 7; + s = (signed char *)(((uintptr_t)p >> 3) + 0x7fff8000); + if (UNLIKELY(k)) { + if (n && !(!*s || *s >= k + n)) return false; + ++s, n -= MIN(8 - k, n); } + e = s; + k = n & 7; + e += n >> 3; + for (; s + 8 <= e; s += 8) { + if ((uint64_t)(255 & s[0]) << 000 | (uint64_t)(255 & s[1]) << 010 | + (uint64_t)(255 & s[2]) << 020 | (uint64_t)(255 & s[3]) << 030 | + (uint64_t)(255 & s[4]) << 040 | (uint64_t)(255 & s[5]) << 050 | + (uint64_t)(255 & s[6]) << 060 | (uint64_t)(255 & s[7]) << 070) { + return false; + } + } + while (s < e) { + if (*s++) { + return false; + } + } + if (k) { + if (!(!*s || *s >= k)) { + return false; + } + } + } + return true; +} + +bool __asan_is_valid_iov(const struct iovec *iov, int iovlen) { + int i; + size_t size; + if (iovlen >= 0 && + !__builtin_mul_overflow(iovlen, sizeof(struct iovec), &size) && + __asan_is_valid(iov, size)) { + for (i = 0; i < iovlen; ++i) { + if (!__asan_is_valid(iov[i].iov_base, iov[i].iov_len)) { + return false; + } + } + return true; + } else { + return false; } } @@ -376,7 +409,7 @@ static const char *__asan_dscribe_heap_poison(long c) { } } -static const char *__asan_describe_access_poison(char *p) { +static const char *__asan_describe_access_poison(signed char *p) { int c = p[0]; if (1 <= c && c <= 7) c = p[1]; switch (c) { @@ -445,15 +478,10 @@ static ssize_t __asan_write_string(const char *s) { return __asan_write(s, __asan_strlen(s)); } -static wontreturn void __asan_abort(void) { - if (weaken(__die)) weaken(__die)(); - __asan_exit(134); -} - static wontreturn void __asan_die(const char *msg) { __asan_write_string(msg); if (weaken(__die)) weaken(__die)(); - __asan_abort(); + __asan_exit(134); } static char *__asan_report_start(char *p) { @@ -472,9 +500,9 @@ static wontreturn void __asan_report_heap_fault(void *addr, long c) { p = __asan_report_start(buf); p = __asan_stpcpy(p, __asan_dscribe_heap_poison(c)); p = __asan_stpcpy(p, " at 0x"); - p = __asan_mempcpy(p, ibuf, __asan_int2hex((intptr_t)addr, ibuf, 48)); + p = __asan_hexcpy(p, (intptr_t)addr, 48); p = __asan_stpcpy(p, " shadow 0x"); - p = __asan_mempcpy(p, ibuf, __asan_int2hex((intptr_t)SHADOW(addr), ibuf, 48)); + p = __asan_hexcpy(p, (intptr_t)SHADOW(addr), 48); p = __asan_stpcpy(p, "\r\n"); __asan_die(buf); } @@ -485,20 +513,20 @@ static wontreturn void __asan_report_memory_fault(uint8_t *addr, int size, p = __asan_report_start(buf); p = __asan_stpcpy(p, __asan_describe_access_poison(SHADOW(addr))); p = __asan_stpcpy(p, " "); - p = __asan_mempcpy(p, ibuf, __asan_int2str(size, ibuf)); + p = __asan_intcpy(p, size); p = __asan_stpcpy(p, "-byte "); p = __asan_stpcpy(p, kind); p = __asan_stpcpy(p, " at 0x"); - p = __asan_mempcpy(p, ibuf, __asan_int2hex((intptr_t)addr, ibuf, 48)); + p = __asan_hexcpy(p, (uintptr_t)addr, 48); p = __asan_stpcpy(p, " shadow 0x"); - p = __asan_mempcpy(p, ibuf, __asan_int2hex((intptr_t)SHADOW(addr), ibuf, 48)); + p = __asan_hexcpy(p, (uintptr_t)SHADOW(addr), 48); p = __asan_stpcpy(p, "\r\n"); __asan_die(buf); } const void *__asan_morgue_add(void *p) { void *r; - unsigned i, j; + int i, j; for (;;) { i = __asan_morgue.i; j = (i + 1) & (ARRAYLEN(__asan_morgue.p) - 1); @@ -511,8 +539,8 @@ const void *__asan_morgue_add(void *p) { } static void __asan_morgue_flush(void) { + int i; void *p; - unsigned i; for (i = 0; i < ARRAYLEN(__asan_morgue.p); ++i) { p = __asan_morgue.p[i]; if (cmpxchg(__asan_morgue.p + i, p, NULL)) { @@ -532,15 +560,16 @@ static size_t __asan_heap_size(size_t n) { } static void *__asan_allocate(size_t a, size_t n, int underrun, int overrun) { - char *p; size_t c; + char *p, *f; if ((p = weaken(dlmemalign)(a, __asan_heap_size(n)))) { c = weaken(dlmalloc_usable_size)(p); __asan_unpoison((uintptr_t)p, n); __asan_poison((uintptr_t)p - 16, 16, underrun); /* see dlmalloc design */ __asan_poison((uintptr_t)p + n, c - n, overrun); __asan_memset(p, 0xF9, n); - WRITE64BE(p + c - sizeof(n), n); + f = p + c - 8; + WRITE64BE(f, n); } return p; } @@ -548,7 +577,7 @@ static void *__asan_allocate(size_t a, size_t n, int underrun, int overrun) { static size_t __asan_malloc_usable_size(const void *p) { size_t c, n; if ((c = weaken(dlmalloc_usable_size)(p)) >= 8) { - if ((n = READ64BE((char *)p + c - sizeof(n))) <= c) { + if ((n = READ64BE((char *)p + c - 8)) <= c) { return n; } else { __asan_report_heap_fault(p, n); @@ -561,9 +590,9 @@ static size_t __asan_malloc_usable_size(const void *p) { static void __asan_deallocate(char *p, long kind) { size_t c, n; if ((c = weaken(dlmalloc_usable_size)(p)) >= 8) { - if ((n = READ64BE((char *)p + c - sizeof(n))) <= c) { - WRITE64BE((char *)p + c - sizeof(n), kind); - __asan_poison((uintptr_t)p, n, kind); + if ((n = READ64BE(p + c - 8)) <= c) { + WRITE64BE(p + c - 8, kind); + __asan_poison((uintptr_t)p, c - 8, kind); if (weaken(dlfree)) { weaken(dlfree)(__asan_morgue_add(p)); } @@ -588,43 +617,47 @@ static void *__asan_malloc(size_t size) { return __asan_memalign(16, size); } -static void *__asan_calloc(size_t nelem, size_t elsize) { +static void *__asan_calloc(size_t n, size_t m) { char *p; - size_t n; - if (__builtin_mul_overflow(nelem, elsize, &n)) n = -1; + if (__builtin_mul_overflow(n, m, &n)) n = -1; if ((p = __asan_malloc(n))) __asan_memset(p, 0, n); return p; } static void *__asan_realloc(void *p, size_t n) { - char *p2; + char *q, *f; size_t c, m; if (p) { if (n) { - if ((c = weaken(dlmalloc_usable_size)(p)) < 8) + if ((c = weaken(dlmalloc_usable_size)(p)) >= 8) { + f = (char *)p + c - 8; + if ((m = READ64BE(f)) <= c) { + if (n <= m) { /* shrink */ + __asan_poison((uintptr_t)p + n, m - n, kAsanHeapOverrun); + WRITE64BE(f, n); + q = p; + } else if (n <= c - 8) { /* small growth */ + __asan_unpoison((uintptr_t)p + m, n - m); + WRITE64BE(f, n); + q = p; + } else if ((q = __asan_malloc(n))) { /* exponential growth */ + __asan_memcpy(q, p, m); + __asan_deallocate(p, kAsanRelocated); + } + } else { + __asan_report_heap_fault(p, m); + } + } else { __asan_report_heap_fault(p, 0); - if ((m = READ64BE((char *)p + c - sizeof(n))) > c) - __asan_report_heap_fault(p, m); - if (n <= m) { /* shrink */ - __asan_poison((uintptr_t)p + n, m - n, kAsanHeapOverrun); - WRITE64BE((char *)p + c - sizeof(n), n); - p2 = p; - } else if (n <= c - 8) { /* small growth */ - __asan_unpoison((uintptr_t)p + m, n - m); - WRITE64BE((char *)p + c - sizeof(n), n); - p2 = p; - } else if ((p2 = __asan_malloc(n))) { /* exponential growth */ - __asan_memcpy(p2, p, m); - __asan_deallocate(p, kAsanRelocated); } } else { __asan_free(p); - p2 = NULL; + q = NULL; } } else { - p2 = __asan_malloc(n); + q = __asan_malloc(n); } - return p2; + return q; } static void *__asan_valloc(size_t n) { diff --git a/libc/intrin/asan.internal.h b/libc/intrin/asan.internal.h index 6e6bd3f6..8f301e39 100644 --- a/libc/intrin/asan.internal.h +++ b/libc/intrin/asan.internal.h @@ -1,5 +1,6 @@ #ifndef COSMOPOLITAN_LIBC_INTRIN_ASAN_H_ #define COSMOPOLITAN_LIBC_INTRIN_ASAN_H_ +#include "libc/calls/struct/iovec.h" #define kAsanScale 3 #define kAsanMagic 0x7fff8000 @@ -17,10 +18,12 @@ #define kAsanUnscoped -12 #define kAsanUnmapped -13 -#define SHADOW(x) ((char *)(((uintptr_t)(x) >> kAsanScale) + kAsanMagic)) +#define SHADOW(x) ((signed char *)(((uintptr_t)(x) >> kAsanScale) + kAsanMagic)) void __asan_map_shadow(uintptr_t, size_t); void __asan_poison(uintptr_t, size_t, int); void __asan_unpoison(uintptr_t, size_t); +bool __asan_is_valid(const void *, size_t); +bool __asan_is_valid_iov(const struct iovec *, int); #endif /* COSMOPOLITAN_LIBC_INTRIN_ASAN_H_ */ diff --git a/libc/intrin/somanyasan.S b/libc/intrin/somanyasan.S index 5bd1076b..81831418 100644 --- a/libc/intrin/somanyasan.S +++ b/libc/intrin/somanyasan.S @@ -19,6 +19,16 @@ #include "libc/macros.internal.h" .source __FILE__ + .macro .acall fn:req + xor %eax,%eax + mov $1,%r10b + cmpxchg %r10b,__asan_noreentry(%rip) + jnz 2f + call \fn + decb __asan_noreentry(%rip) +2: nop + .endm + .rodata.cst4 __asan_option_detect_stack_use_after_return: .long 0 @@ -32,181 +42,362 @@ __asan_noreentry: .previous __asan_report_load1: - push $1 - jmp OnReportLoad + push %rbp + mov %rsp,%rbp + .profilable + mov $1,%esi + .acall __asan_report_load + pop %rbp + ret .endfn __asan_report_load1,globl + __asan_report_load2: - push $2 - jmp OnReportLoad + push %rbp + mov %rsp,%rbp + .profilable + mov $2,%esi + .acall __asan_report_load + pop %rbp + ret .endfn __asan_report_load2,globl + __asan_report_load4: - push $4 - jmp OnReportLoad + push %rbp + mov %rsp,%rbp + .profilable + mov $4,%esi + .acall __asan_report_load + pop %rbp + ret .endfn __asan_report_load4,globl + __asan_report_load8: - push $8 - jmp OnReportLoad + push %rbp + mov %rsp,%rbp + .profilable + mov $8,%esi + .acall __asan_report_load + pop %rbp + ret .endfn __asan_report_load8,globl + __asan_report_load16: - push $16 - jmp OnReportLoad + push %rbp + mov %rsp,%rbp + .profilable + mov $16,%esi + .acall __asan_report_load + pop %rbp + ret .endfn __asan_report_load16,globl + __asan_report_load32: - push $32 -// 𝑠𝑙𝑖𝑑𝑒 + push %rbp + mov %rsp,%rbp + .profilable + mov $32,%esi + .acall __asan_report_load + pop %rbp + ret .endfn __asan_report_load32,globl -OnReportLoad: - pop %rsi -// 𝑠𝑙𝑖𝑑𝑒 - .endfn OnReportLoad + __asan_report_load_n: - lea __asan_report_load(%rip),%r11 - jmp __asan_report_noreentry + push %rbp + mov %rsp,%rbp + .profilable + .acall __asan_report_load + pop %rbp + ret .endfn __asan_report_load_n,globl __asan_report_store1: - push $1 - jmp ReportStore - .endfn __asan_report_store1,globl -__asan_report_store2: - push $2 - jmp ReportStore - .endfn __asan_report_store2,globl -__asan_report_store4: - push $4 - jmp ReportStore - .endfn __asan_report_store4,globl -__asan_report_store8: - push $8 - jmp ReportStore - .endfn __asan_report_store8,globl -__asan_report_store16: - push $16 - jmp ReportStore - .endfn __asan_report_store16,globl -__asan_report_store32: - push $32 -// 𝑠𝑙𝑖𝑑𝑒 - .endfn __asan_report_store32,globl -ReportStore: - pop %rsi -// 𝑠𝑙𝑖𝑑𝑒 - .endfn ReportStore -__asan_report_store_n: - lea __asan_report_store(%rip),%r11 -// 𝑠𝑙𝑖𝑑𝑒 - .endfn __asan_report_store_n,globl - -__asan_report_noreentry: push %rbp mov %rsp,%rbp - xor %eax,%eax - mov $1,%r10b - cmpxchg %r10b,__asan_noreentry(%rip) - jnz 2f - call *%r11 - decb __asan_noreentry(%rip) -2: pop %rbp + .profilable + mov $1,%esi + .acall __asan_report_store + pop %rbp ret - .endfn __asan_report_noreentry + .endfn __asan_report_store1,globl + +__asan_report_store2: + push %rbp + mov %rsp,%rbp + .profilable + mov $2,%esi + .acall __asan_report_store + pop %rbp + ret + .endfn __asan_report_store2,globl + +__asan_report_store4: + push %rbp + mov %rsp,%rbp + .profilable + mov $4,%esi + .acall __asan_report_store + pop %rbp + ret + .endfn __asan_report_store4,globl + +__asan_report_store8: + push %rbp + mov %rsp,%rbp + .profilable + mov $8,%esi + .acall __asan_report_store + pop %rbp + ret + .endfn __asan_report_store8,globl + +__asan_report_store16: + push %rbp + mov %rsp,%rbp + .profilable + mov $16,%esi + .acall __asan_report_store + pop %rbp + ret + .endfn __asan_report_store16,globl + +__asan_report_store32: + push %rbp + mov %rsp,%rbp + .profilable + mov $32,%esi + .acall __asan_report_store + pop %rbp + ret + .endfn __asan_report_store32,globl + +__asan_report_store_n: + push %rbp + mov %rsp,%rbp + .profilable + .acall __asan_report_store + pop %rbp + ret + .endfn __asan_report_store_n,globl __asan_stack_free_0: - push $0 - jmp OnStackFree + push %rbp + mov %rsp,%rbp + .profilable + mov $0,%edx + call __asan_stack_free + pop %rbp + ret .endfn __asan_stack_free_0,globl + __asan_stack_free_1: - push $1 - jmp OnStackFree + push %rbp + mov %rsp,%rbp + .profilable + mov $1,%edx + call __asan_stack_free + pop %rbp + ret .endfn __asan_stack_free_1,globl + __asan_stack_free_2: - push $2 - jmp OnStackFree + push %rbp + mov %rsp,%rbp + .profilable + mov $2,%edx + call __asan_stack_free + pop %rbp + ret .endfn __asan_stack_free_2,globl + __asan_stack_free_3: - push $3 - jmp OnStackFree + push %rbp + mov %rsp,%rbp + .profilable + mov $3,%edx + call __asan_stack_free + pop %rbp + ret .endfn __asan_stack_free_3,globl + __asan_stack_free_4: - push $4 - jmp OnStackFree + push %rbp + mov %rsp,%rbp + .profilable + mov $4,%edx + call __asan_stack_free + pop %rbp + ret .endfn __asan_stack_free_4,globl + __asan_stack_free_5: - push $5 - jmp OnStackFree + push %rbp + mov %rsp,%rbp + .profilable + mov $5,%edx + call __asan_stack_free + pop %rbp + ret .endfn __asan_stack_free_5,globl + __asan_stack_free_6: - push $6 - jmp OnStackFree + push %rbp + mov %rsp,%rbp + .profilable + mov $6,%edx + call __asan_stack_free + pop %rbp + ret .endfn __asan_stack_free_6,globl + __asan_stack_free_7: - push $7 - jmp OnStackFree + push %rbp + mov %rsp,%rbp + .profilable + mov $7,%edx + call __asan_stack_free + pop %rbp + ret .endfn __asan_stack_free_7,globl + __asan_stack_free_8: - push $8 - jmp OnStackFree + push %rbp + mov %rsp,%rbp + .profilable + mov $8,%edx + call __asan_stack_free + pop %rbp + ret .endfn __asan_stack_free_8,globl + __asan_stack_free_9: - push $9 - jmp OnStackFree + push %rbp + mov %rsp,%rbp + .profilable + mov $9,%edx + call __asan_stack_free + pop %rbp + ret .endfn __asan_stack_free_9,globl + __asan_stack_free_10: - push $10 -// 𝑠𝑙𝑖𝑑𝑒 + push %rbp + mov %rsp,%rbp + .profilable + mov $10,%edx + call __asan_stack_free + pop %rbp + ret .endfn __asan_stack_free_10,globl -OnStackFree: - pop %rdx - jmp __asan_stack_free - .endfn OnStackFree __asan_stack_malloc_0: - push $0 - jmp OnStackMalloc + push %rbp + mov %rsp,%rbp + .profilable + mov $0,%esi + call __asan_stack_malloc + pop %rbp + ret .endfn __asan_stack_malloc_0,globl + __asan_stack_malloc_1: - push $1 - jmp OnStackMalloc + push %rbp + mov %rsp,%rbp + .profilable + mov $1,%esi + call __asan_stack_malloc + pop %rbp + ret .endfn __asan_stack_malloc_1,globl + __asan_stack_malloc_2: - push $2 - jmp OnStackMalloc + push %rbp + mov %rsp,%rbp + .profilable + mov $2,%esi + call __asan_stack_malloc + pop %rbp + ret .endfn __asan_stack_malloc_2,globl + __asan_stack_malloc_3: - push $3 - jmp OnStackMalloc + push %rbp + mov %rsp,%rbp + .profilable + mov $3,%esi + call __asan_stack_malloc + pop %rbp + ret .endfn __asan_stack_malloc_3,globl + __asan_stack_malloc_4: - push $4 - jmp OnStackMalloc + push %rbp + mov %rsp,%rbp + .profilable + mov $4,%esi + call __asan_stack_malloc + pop %rbp + ret .endfn __asan_stack_malloc_4,globl + __asan_stack_malloc_5: - push $5 - jmp OnStackMalloc + push %rbp + mov %rsp,%rbp + .profilable + mov $5,%esi + call __asan_stack_malloc + pop %rbp + ret .endfn __asan_stack_malloc_5,globl + __asan_stack_malloc_6: - push $6 - jmp OnStackMalloc + push %rbp + mov %rsp,%rbp + .profilable + mov $6,%esi + call __asan_stack_malloc + pop %rbp + ret .endfn __asan_stack_malloc_6,globl + __asan_stack_malloc_7: - push $7 - jmp OnStackMalloc + push %rbp + mov %rsp,%rbp + .profilable + mov $7,%esi + call __asan_stack_malloc + pop %rbp + ret .endfn __asan_stack_malloc_7,globl + __asan_stack_malloc_8: - push $8 - jmp OnStackMalloc + push %rbp + mov %rsp,%rbp + .profilable + mov $8,%esi + call __asan_stack_malloc + pop %rbp + ret .endfn __asan_stack_malloc_8,globl + __asan_stack_malloc_9: - push $9 - jmp OnStackMalloc + push %rbp + mov %rsp,%rbp + .profilable + mov $9,%esi + call __asan_stack_malloc + pop %rbp + ret .endfn __asan_stack_malloc_9,globl + __asan_stack_malloc_10: - push $10 -// 𝑠𝑙𝑖𝑑𝑒 + push %rbp + mov %rsp,%rbp + .profilable + mov $10,%esi + call __asan_stack_malloc + pop %rbp + ret .endfn __asan_stack_malloc_10,globl -OnStackMalloc: - pop %rsi - jmp __asan_stack_malloc - .endfn OnStackMalloc __asan_version_mismatch_check_v8: ret @@ -242,26 +433,31 @@ __asan_load1: mov %rsp,%rbp ud2 .endfn __asan_load1,globl + __asan_load2: push %rbp mov %rsp,%rbp ud2 .endfn __asan_load2,globl + __asan_load4: push %rbp mov %rsp,%rbp ud2 .endfn __asan_load4,globl + __asan_load8: push %rbp mov %rsp,%rbp ud2 .endfn __asan_load8,globl + __asan_load16: push %rbp mov %rsp,%rbp ud2 .endfn __asan_load16,globl + __asan_load32: push %rbp mov %rsp,%rbp @@ -273,26 +469,31 @@ __asan_store1: mov %rsp,%rbp ud2 .endfn __asan_store1,globl + __asan_store2: push %rbp mov %rsp,%rbp ud2 .endfn __asan_store2,globl + __asan_store4: push %rbp mov %rsp,%rbp ud2 .endfn __asan_store4,globl + __asan_store8: push %rbp mov %rsp,%rbp ud2 .endfn __asan_store8,globl + __asan_store16: push %rbp mov %rsp,%rbp ud2 .endfn __asan_store16,globl + __asan_store32: push %rbp mov %rsp,%rbp diff --git a/libc/log/log.h b/libc/log/log.h index 170153b4..ba54a42e 100644 --- a/libc/log/log.h +++ b/libc/log/log.h @@ -1,5 +1,6 @@ #ifndef COSMOPOLITAN_LIBC_LOG_LOG_H_ #define COSMOPOLITAN_LIBC_LOG_LOG_H_ +#include "libc/bits/likely.h" #include "libc/calls/struct/sigset.h" #include "libc/calls/struct/winsize.h" #include "libc/stdio/stdio.h" diff --git a/libc/log/oncrash.c b/libc/log/oncrash.c index 3c4bbbcd..803c918b 100644 --- a/libc/log/oncrash.c +++ b/libc/log/oncrash.c @@ -133,7 +133,7 @@ relegated static void ShowGeneralRegisters(int fd, ucontext_t *ctx) { } else { memset(&st, 0, sizeof(st)); } - dprintf(fd, " %s(%zu) %Lf", "ST", k, st); + dprintf(fd, " %s(%zu) %Lg", "ST", k, st); ++k; write(fd, "\r\n", 2); } diff --git a/libc/log/somanyubsan.S b/libc/log/somanyubsan.S index 9e481ef0..98dbb760 100644 --- a/libc/log/somanyubsan.S +++ b/libc/log/somanyubsan.S @@ -34,232 +34,495 @@ __ubsan_get_current_report_data: .endfn __ubsan_get_current_report_data,globl __ubsan_handle_type_mismatch_abort: - jmp __ubsan_handle_type_mismatch + push %rbp + mov %rsp,%rbp + .profilable + call __ubsan_handle_type_mismatch + pop %rbp + ret .endfn __ubsan_handle_type_mismatch_abort,globl __ubsan_handle_float_cast_overflow_abort: - jmp __ubsan_handle_float_cast_overflow + push %rbp + mov %rsp,%rbp + .profilable + call __ubsan_handle_float_cast_overflow + pop %rbp + ret .endfn __ubsan_handle_float_cast_overflow_abort,globl -__ubsan_handle_type_mismatch_v1: __ubsan_handle_type_mismatch_v1_abort: - jmp ___ubsan_handle_type_mismatch_v1 - .endfn __ubsan_handle_type_mismatch_v1,globl + push %rbp + mov %rsp,%rbp + .profilable + call ___ubsan_handle_type_mismatch_v1 + pop %rbp + ret .endfn __ubsan_handle_type_mismatch_v1_abort,globl +__ubsan_handle_type_mismatch_v1: + push %rbp + mov %rsp,%rbp + .profilable + call ___ubsan_handle_type_mismatch_v1 + pop %rbp + ret + .endfn __ubsan_handle_type_mismatch_v1,globl + __ubsan_handle_add_overflow_abort: - nop -// fallthrough - .endfn __ubsan_handle_add_overflow_abort,globl -__ubsan_handle_add_overflow: + push %rbp + mov %rsp,%rbp + .profilable loadstr "add_overflow",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_add_overflow_abort,globl + +__ubsan_handle_add_overflow: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "add_overflow",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_add_overflow,globl __ubsan_handle_alignment_assumption_abort: - nop -// fallthrough - .endfn __ubsan_handle_alignment_assumption_abort,globl -__ubsan_handle_alignment_assumption: + push %rbp + mov %rsp,%rbp + .profilable loadstr "alignment_assumption",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_alignment_assumption_abort,globl + +__ubsan_handle_alignment_assumption: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "alignment_assumption",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_alignment_assumption,globl __ubsan_handle_builtin_unreachable_abort: - nop -// fallthrough - .endfn __ubsan_handle_builtin_unreachable_abort,globl -__ubsan_handle_builtin_unreachable: + push %rbp + mov %rsp,%rbp + .profilable loadstr "builtin_unreachable",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_builtin_unreachable_abort,globl + +__ubsan_handle_builtin_unreachable: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "builtin_unreachable",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_builtin_unreachable,globl __ubsan_handle_cfi_bad_type_abort: - nop -// fallthrough - .endfn __ubsan_handle_cfi_bad_type_abort,globl -__ubsan_handle_cfi_bad_type: + push %rbp + mov %rsp,%rbp + .profilable loadstr "cfi_bad_type",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_cfi_bad_type_abort,globl + +__ubsan_handle_cfi_bad_type: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "cfi_bad_type",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_cfi_bad_type,globl __ubsan_handle_cfi_check_fail_abort: - nop -// fallthrough - .endfn __ubsan_handle_cfi_check_fail_abort,globl -__ubsan_handle_cfi_check_fail: + push %rbp + mov %rsp,%rbp + .profilable loadstr "cfi_check_fail",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_cfi_check_fail_abort,globl + +__ubsan_handle_cfi_check_fail: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "cfi_check_fail",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_cfi_check_fail,globl __ubsan_handle_divrem_overflow_abort: - nop -// fallthrough - .endfn __ubsan_handle_divrem_overflow_abort,globl -__ubsan_handle_divrem_overflow: + push %rbp + mov %rsp,%rbp + .profilable loadstr "divrem_overflow",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_divrem_overflow_abort,globl + +__ubsan_handle_divrem_overflow: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "divrem_overflow",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_divrem_overflow,globl __ubsan_handle_dynamic_type_cache_miss_abort: - nop -// fallthrough - .endfn __ubsan_handle_dynamic_type_cache_miss_abort,globl -__ubsan_handle_dynamic_type_cache_miss: + push %rbp + mov %rsp,%rbp + .profilable loadstr "dynamic_type_cache_miss",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_dynamic_type_cache_miss_abort,globl + +__ubsan_handle_dynamic_type_cache_miss: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "dynamic_type_cache_miss",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_dynamic_type_cache_miss,globl __ubsan_handle_function_type_mismatch_abort: - nop -// fallthrough - .endfn __ubsan_handle_function_type_mismatch_abort,globl -__ubsan_handle_function_type_mismatch: + push %rbp + mov %rsp,%rbp + .profilable loadstr "function_type_mismatch",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_function_type_mismatch_abort,globl + +__ubsan_handle_function_type_mismatch: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "function_type_mismatch",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_function_type_mismatch,globl __ubsan_handle_implicit_conversion_abort: - nop -// fallthrough - .endfn __ubsan_handle_implicit_conversion_abort,globl -__ubsan_handle_implicit_conversion: + push %rbp + mov %rsp,%rbp + .profilable loadstr "implicit_conversion",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_implicit_conversion_abort,globl + +__ubsan_handle_implicit_conversion: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "implicit_conversion",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_implicit_conversion,globl __ubsan_handle_invalid_builtin_abort: - nop -// fallthrough - .endfn __ubsan_handle_invalid_builtin_abort,globl -__ubsan_handle_invalid_builtin: + push %rbp + mov %rsp,%rbp + .profilable loadstr "invalid_builtin",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_invalid_builtin_abort,globl + +__ubsan_handle_invalid_builtin: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "invalid_builtin",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_invalid_builtin,globl __ubsan_handle_load_invalid_value_abort: - nop -// fallthrough + push %rbp + mov %rsp,%rbp + .profilable + loadstr "load_invalid_value (uninitialized? bool∌[01]?)",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_load_invalid_value_abort,globl + __ubsan_handle_load_invalid_value: - loadstr "load_invalid_value (try checking for uninitialized variables)",si - jmp __ubsan_hop + push %rbp + mov %rsp,%rbp + .profilable + loadstr "load_invalid_value (uninitialized? bool∌[01]?)",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_load_invalid_value,globl __ubsan_handle_missing_return_abort: - nop -// fallthrough - .endfn __ubsan_handle_missing_return_abort,globl -__ubsan_handle_missing_return: + push %rbp + mov %rsp,%rbp + .profilable loadstr "missing_return",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_missing_return_abort,globl + +__ubsan_handle_missing_return: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "missing_return",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_missing_return,globl __ubsan_handle_mul_overflow_abort: - nop -// fallthrough - .endfn __ubsan_handle_mul_overflow_abort,globl -__ubsan_handle_mul_overflow: + push %rbp + mov %rsp,%rbp + .profilable loadstr "mul_overflow",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_mul_overflow_abort,globl + +__ubsan_handle_mul_overflow: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "mul_overflow",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_mul_overflow,globl __ubsan_handle_negate_overflow_abort: - nop -// fallthrough - .endfn __ubsan_handle_negate_overflow_abort,globl -__ubsan_handle_negate_overflow: + push %rbp + mov %rsp,%rbp + .profilable loadstr "negate_overflow",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_negate_overflow_abort,globl + +__ubsan_handle_negate_overflow: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "negate_overflow",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_negate_overflow,globl __ubsan_handle_nonnull_arg_abort: - nop -// fallthrough - .endfn __ubsan_handle_nonnull_arg_abort,globl -__ubsan_handle_nonnull_arg: + push %rbp + mov %rsp,%rbp + .profilable loadstr "nonnull_arg",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_nonnull_arg_abort,globl + +__ubsan_handle_nonnull_arg: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "nonnull_arg",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_nonnull_arg,globl __ubsan_handle_nonnull_return_v1_abort: - nop -// fallthrough - .endfn __ubsan_handle_nonnull_return_v1_abort,globl -__ubsan_handle_nonnull_return_v1: + push %rbp + mov %rsp,%rbp + .profilable loadstr "nonnull_return_v1",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_nonnull_return_v1_abort,globl + +__ubsan_handle_nonnull_return_v1: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "nonnull_return_v1",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_nonnull_return_v1,globl -__ubsan_hop: - jmp __ubsan_abort - .endfn __ubsan_hop - __ubsan_handle_nullability_arg_abort: - nop -// fallthrough - .endfn __ubsan_handle_nullability_arg_abort,globl -__ubsan_handle_nullability_arg: + push %rbp + mov %rsp,%rbp + .profilable loadstr "nullability_arg",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_nullability_arg_abort,globl + +__ubsan_handle_nullability_arg: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "nullability_arg",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_nullability_arg,globl __ubsan_handle_nullability_return_v1_abort: - nop -// fallthrough - .endfn __ubsan_handle_nullability_return_v1_abort,globl -__ubsan_handle_nullability_return_v1: + push %rbp + mov %rsp,%rbp + .profilable loadstr "nullability_return_v1",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_nullability_return_v1_abort,globl + +__ubsan_handle_nullability_return_v1: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "nullability_return_v1",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_nullability_return_v1,globl __ubsan_handle_pointer_overflow_abort: - nop -// fallthrough - .endfn __ubsan_handle_pointer_overflow_abort,globl -__ubsan_handle_pointer_overflow: + push %rbp + mov %rsp,%rbp + .profilable loadstr "pointer_overflow",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_pointer_overflow_abort,globl + +__ubsan_handle_pointer_overflow: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "pointer_overflow",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_pointer_overflow,globl __ubsan_handle_shift_out_of_bounds_abort: - nop -// fallthrough + push %rbp + mov %rsp,%rbp + .profilable + call __ubsan_handle_shift_out_of_bounds + pop %rbp + ret .endfn __ubsan_handle_shift_out_of_bounds_abort,globl -__ubsan_handle_shift_out_of_bounds: - loadstr "shift_out_of_bounds",si - jmp __ubsan_hop - .endfn __ubsan_handle_shift_out_of_bounds,globl __ubsan_handle_sub_overflow_abort: - nop -// fallthrough - .endfn __ubsan_handle_sub_overflow_abort,globl -__ubsan_handle_sub_overflow: + push %rbp + mov %rsp,%rbp + .profilable loadstr "sub_overflow",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_sub_overflow_abort,globl + +__ubsan_handle_sub_overflow: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "sub_overflow",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_sub_overflow,globl __ubsan_handle_vla_bound_not_positive_abort: - nop -// fallthrough - .endfn __ubsan_handle_vla_bound_not_positive_abort,globl -__ubsan_handle_vla_bound_not_positive: + push %rbp + mov %rsp,%rbp + .profilable loadstr "vla_bound_not_positive",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_vla_bound_not_positive_abort,globl + +__ubsan_handle_vla_bound_not_positive: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "vla_bound_not_positive",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_vla_bound_not_positive,globl __ubsan_handle_nonnull_return_abort: - nop -// fallthrough - .endfn __ubsan_handle_nonnull_return_abort,globl -__ubsan_handle_nonnull_return: + push %rbp + mov %rsp,%rbp + .profilable loadstr "nonnull_return",si - jmp __ubsan_hop + call __ubsan_abort + pop %rbp + ret + .endfn __ubsan_handle_nonnull_return_abort,globl + +__ubsan_handle_nonnull_return: + push %rbp + mov %rsp,%rbp + .profilable + loadstr "nonnull_return",si + call __ubsan_abort + pop %rbp + ret .endfn __ubsan_handle_nonnull_return,globl __ubsan_handle_out_of_bounds_abort: - jmp __ubsan_handle_out_of_bounds + push %rbp + mov %rsp,%rbp + .profilable + call __ubsan_handle_out_of_bounds + pop %rbp + ret .endfn __ubsan_handle_out_of_bounds_abort,globl - -.previous diff --git a/libc/log/ubsan.c b/libc/log/ubsan.c index b47e7ea9..ee64cd9e 100644 --- a/libc/log/ubsan.c +++ b/libc/log/ubsan.c @@ -16,6 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/alg/reverse.internal.h" #include "libc/bits/pushpop.h" #include "libc/calls/calls.h" #include "libc/fmt/fmt.h" @@ -43,6 +44,89 @@ upcast of\0\ cast to virtual base of\0\ \0"; +static int __ubsan_bits(struct UbsanTypeDescriptor *t) { + return 1 << (t->info >> 1); +} + +static bool __ubsan_signed(struct UbsanTypeDescriptor *t) { + return t->info & 1; +} + +static bool __ubsan_negative(struct UbsanTypeDescriptor *t, uintptr_t x) { + return __ubsan_signed(t) && (intptr_t)x < 0; +} + +static size_t __ubsan_strlen(const char *s) { + size_t n = 0; + while (*s++) ++n; + return n; +} + +static char *__ubsan_stpcpy(char *d, const char *s) { + size_t i; + for (i = 0;; ++i) { + if (!(d[i] = s[i])) { + return d + i; + } + } +} + +static char *__ubsan_poscpy(char *p, uintptr_t i) { + int j = 0; + do { + p[j++] = i % 10 + '0'; + i /= 10; + } while (i > 0); + reverse(p, j); + return p + j; +} + +static char *__ubsan_intcpy(char *p, intptr_t i) { + if (i >= 0) return __ubsan_poscpy(p, i); + *p++ = '-'; + return __ubsan_poscpy(p, -i); +} + +static char *__ubsan_hexcpy(char *p, uintptr_t x, int k) { + while (k) *p++ = "0123456789abcdef"[(x >> (k -= 4)) & 15]; + return p; +} + +static char *__ubsan_itpcpy(char *p, struct UbsanTypeDescriptor *t, + uintptr_t x) { + if (__ubsan_signed(t)) { + return __ubsan_intcpy(p, x); + } else { + return __ubsan_poscpy(p, x); + } +} + +static const char *__ubsan_dubnul(const char *s, unsigned i) { + size_t n; + while (i--) { + if ((n = __ubsan_strlen(s))) { + s += n + 1; + } else { + return NULL; + } + } + return s; +} + +static uintptr_t __ubsan_extend(struct UbsanTypeDescriptor *t, uintptr_t x) { + int w; + w = __ubsan_bits(t); + if (w < sizeof(x) * CHAR_BIT) { + x <<= sizeof(x) * CHAR_BIT - w; + if (__ubsan_signed(t)) { + x = (intptr_t)x >> w; + } else { + x >>= w; + } + } + return x; +} + void __ubsan_abort(const struct UbsanSourceLocation *loc, const char *description) { static bool once; @@ -53,43 +137,73 @@ void __ubsan_abort(const struct UbsanSourceLocation *loc, } if (IsDebuggerPresent(false)) DebugBreak(); __start_fatal(loc->file, loc->line); - fprintf(stderr, "%s\r\n", description); + write(2, description, strlen(description)); + write(2, "\r\n", 2); __die(); - unreachable; +} + +void __ubsan_handle_shift_out_of_bounds(struct UbsanShiftOutOfBoundsInfo *info, + uintptr_t lhs, uintptr_t rhs) { + char *p; + const char *s; + lhs = __ubsan_extend(info->lhs_type, lhs); + rhs = __ubsan_extend(info->rhs_type, rhs); + if (__ubsan_negative(info->rhs_type, rhs)) { + s = "shift exponent is negative"; + } else if (rhs >= __ubsan_bits(info->lhs_type)) { + s = "shift exponent too large for type"; + } else if (__ubsan_negative(info->lhs_type, lhs)) { + s = "left shift of negative value"; + } else if (__ubsan_signed(info->lhs_type)) { + s = "signed left shift changed sign bit or overflowed"; + } else { + s = "wut shift out of bounds"; + } + p = __ubsan_buf; + p = __ubsan_stpcpy(p, s), *p++ = ' '; + p = __ubsan_itpcpy(p, info->lhs_type, lhs), *p++ = ' '; + p = __ubsan_stpcpy(p, info->lhs_type->name), *p++ = ' '; + p = __ubsan_itpcpy(p, info->rhs_type, rhs), *p++ = ' '; + p = __ubsan_stpcpy(p, info->rhs_type->name); + __ubsan_abort(&info->location, __ubsan_buf); } void __ubsan_handle_out_of_bounds(struct UbsanOutOfBoundsInfo *info, uintptr_t index) { - snprintf(__ubsan_buf, sizeof(__ubsan_buf), - "%s index %,lu into %s out of bounds", info->index_type->name, index, - info->array_type->name); + char *p; + p = __ubsan_buf; + p = __ubsan_stpcpy(p, info->index_type->name); + p = __ubsan_stpcpy(p, " index "); + p = __ubsan_itpcpy(p, info->index_type, index); + p = __ubsan_stpcpy(p, " into "); + p = __ubsan_stpcpy(p, info->array_type->name); + p = __ubsan_stpcpy(p, " out of bounds"); __ubsan_abort(&info->location, __ubsan_buf); - unreachable; } -void __ubsan_handle_type_mismatch(struct UbsanTypeMismatchInfo *type_mismatch, +void __ubsan_handle_type_mismatch(struct UbsanTypeMismatchInfo *info, uintptr_t pointer) { - struct UbsanSourceLocation *loc = &type_mismatch->location; - const char *description; - const char *kind = IndexDoubleNulString(kUbsanTypeCheckKinds, - type_mismatch->type_check_kind); - if (pointer == 0) { - description = "null pointer access"; - } else if (type_mismatch->alignment != 0 && - (pointer & (type_mismatch->alignment - 1))) { - description = __ubsan_buf; - snprintf(__ubsan_buf, sizeof(__ubsan_buf), "%s %s %s @%p %s %d", - "unaligned", kind, type_mismatch->type->name, pointer, "align", - type_mismatch->alignment); + char *p; + const char *kind; + if (!pointer) __ubsan_abort(&info->location, "null pointer access"); + p = __ubsan_buf; + kind = __ubsan_dubnul(kUbsanTypeCheckKinds, info->type_check_kind); + if (info->alignment && (pointer & (info->alignment - 1))) { + p = __ubsan_stpcpy(p, "unaligned "); + p = __ubsan_stpcpy(p, kind), *p++ = ' '; + p = __ubsan_stpcpy(p, info->type->name), *p++ = ' ', *p++ = '@'; + p = __ubsan_itpcpy(p, info->type, pointer); + p = __ubsan_stpcpy(p, " align "); + p = __ubsan_intcpy(p, info->alignment); } else { - description = __ubsan_buf; - snprintf(__ubsan_buf, sizeof(__ubsan_buf), "%s\r\n\t%s %s %p %s %s", - "insufficient size", kind, "address", pointer, - "with insufficient space for object of type", - type_mismatch->type->name); + p = __ubsan_stpcpy(p, "insufficient size\r\n\t"); + p = __ubsan_stpcpy(p, kind); + p = __ubsan_stpcpy(p, " address 0x"); + p = __ubsan_hexcpy(p, pointer, sizeof(pointer) * CHAR_BIT); + p = __ubsan_stpcpy(p, " with insufficient space for object of type "); + p = __ubsan_stpcpy(p, info->type->name); } - __ubsan_abort(loc, description); - unreachable; + __ubsan_abort(&info->location, __ubsan_buf); } void ___ubsan_handle_type_mismatch_v1( @@ -100,7 +214,6 @@ void ___ubsan_handle_type_mismatch_v1( mm.alignment = 1u << type_mismatch->log_alignment; mm.type_check_kind = type_mismatch->type_check_kind; __ubsan_handle_type_mismatch(&mm, pointer); - unreachable; } void __ubsan_handle_float_cast_overflow(void *data_raw, void *from_raw) { @@ -116,5 +229,4 @@ void __ubsan_handle_float_cast_overflow(void *data_raw, void *from_raw) { }; __ubsan_abort(((void)data, &kUnknownLocation), "float cast overflow"); #endif - unreachable; } diff --git a/libc/log/ubsan.internal.h b/libc/log/ubsan.internal.h index f3cc3499..f9dc4fd4 100644 --- a/libc/log/ubsan.internal.h +++ b/libc/log/ubsan.internal.h @@ -1,11 +1,15 @@ #ifndef COSMOPOLITAN_LIBC_UBSAN_H_ #define COSMOPOLITAN_LIBC_UBSAN_H_ -#if !(__ASSEMBLER__ + __LINKER__ + 0) - /*───────────────────────────────────────────────────────────────────────────│─╗ │ cosmopolitan § runtime » behavior enforcement ─╬─│┼ ╚────────────────────────────────────────────────────────────────────────────│*/ +#define kUbsanKindInt 0 +#define kUbsanKindFloat 1 +#define kUbsanKindUnknown 0xffff + +#if !(__ASSEMBLER__ + __LINKER__ + 0) + struct UbsanSourceLocation { const char *file; uint32_t line; @@ -13,8 +17,8 @@ struct UbsanSourceLocation { }; struct UbsanTypeDescriptor { - uint16_t kind; - uint16_t info; + uint16_t kind; /* int,float,... */ + uint16_t info; /* if int bit 0 if signed, remaining bits are log2(sizeof*8) */ char name[]; }; @@ -91,7 +95,7 @@ struct UbsanOutOfBoundsData { struct UbsanTypeDescriptor *index_type; }; -struct UbsanShiftOutOfBoundsData { +struct UbsanShiftOutOfBoundsInfo { struct UbsanSourceLocation location; struct UbsanTypeDescriptor *lhs_type; struct UbsanTypeDescriptor *rhs_type; diff --git a/libc/macros.internal.h b/libc/macros.internal.h index 5c1939f0..5bbff6e9 100644 --- a/libc/macros.internal.h +++ b/libc/macros.internal.h @@ -26,8 +26,6 @@ #define TYPE_BIT(type) (sizeof(type) * CHAR_BIT) #define TYPE_SIGNED(type) (((type)-1) < 0) #define TYPE_INTEGRAL(type) (((type)0.5) != 0.5) -#define INT_STRLEN_MAXIMUM(type) \ - ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type)) #define ARRAYLEN(A) \ ((sizeof(A) / sizeof(*(A))) / ((unsigned)!(sizeof(A) % sizeof(*(A))))) diff --git a/libc/nt/enum/lockfile.h b/libc/nt/enum/lockfile.h new file mode 100644 index 00000000..dae4f214 --- /dev/null +++ b/libc/nt/enum/lockfile.h @@ -0,0 +1,7 @@ +#ifndef COSMOPOLITAN_LIBC_NT_ENUM_LOCKFILE_H_ +#define COSMOPOLITAN_LIBC_NT_ENUM_LOCKFILE_H_ + +#define kNtLockfileFailImmediately 1 +#define kNtLockfileExclusiveLock 2 + +#endif /* COSMOPOLITAN_LIBC_NT_ENUM_LOCKFILE_H_ */ diff --git a/libc/runtime/msync.c b/libc/runtime/msync.c index fde0b2b9..adcd9a0e 100644 --- a/libc/runtime/msync.c +++ b/libc/runtime/msync.c @@ -29,6 +29,7 @@ * Without this, there's no guarantee memory is written back to disk. In * practice, what that means is just Windows NT. * + * @param addr needs to be 4096-byte page aligned * @param flags needs MS_ASYNC or MS_SYNC and can have MS_INVALIDATE * @return 0 on success or -1 w/ errno */ diff --git a/libc/str/getzipcdir.c b/libc/str/getzipcdir.c index 18d1d956..1ba8d781 100644 --- a/libc/str/getzipcdir.c +++ b/libc/str/getzipcdir.c @@ -21,9 +21,9 @@ /** * Locates End Of Central Directory record in ZIP file. * - * The ZIP spec says this header can be anywhere in the last 64kb. - * We search it backwards for the ZIP-64 "PK♠♠" magic number. If that's - * not found, then we search again for the original "PK♣♠" magnum. The + * The ZIP spec says this header can be anywhere in the last 64kb. We + * search it backwards for the ZIP-64 "PK♠•" magic number. If that's not + * found, then we search again for the original "PK♣♠" magnum. The * caller needs to check the first four bytes of the returned value to * determine whether to use ZIP_CDIR_xxx() or ZIP_CDIR64_xxx() macros. * @@ -31,23 +31,25 @@ * @param n is byte size of file * @return pointer to EOCD64 or EOCD, or NULL if not found */ -uint8_t *GetZipCdir(const uint8_t *p, size_t n) { +void *GetZipCdir(const uint8_t *p, size_t n) { size_t i, j; - if (n >= kZipCdirHdrMinSize) { - i = n - kZipCdirHdrMinSize; - do { - if (READ32LE(p + i) == kZipCdir64HdrMagic && IsZipCdir64(p, n, i)) { - return (/*unconst*/ uint8_t *)(p + i); - } else if (READ32LE(p + i) == kZipCdirHdrMagic && IsZipCdir32(p, n, i)) { - j = i; - do { - if (READ32LE(p + j) == kZipCdir64HdrMagic && IsZipCdir64(p, n, j)) { - return (/*unconst*/ uint8_t *)(p + j); - } - } while (j-- && i - j < 64 * 1024); - return (/*unconst*/ uint8_t *)(p + i); - } - } while (i--); - } + i = n - 4; + do { + if (READ32LE(p + i) == kZipCdir64LocatorMagic && + i + kZipCdir64LocatorSize <= n && + IsZipCdir64(p, n, ZIP_LOCATE64_OFFSET(p + i))) { + return (void *)(p + ZIP_LOCATE64_OFFSET(p + i)); + } else if (READ32LE(p + i) == kZipCdirHdrMagic && IsZipCdir32(p, n, i)) { + j = i; + do { + if (READ32LE(p + j) == kZipCdir64LocatorMagic && + j + kZipCdir64LocatorSize <= n && + IsZipCdir64(p, n, ZIP_LOCATE64_OFFSET(p + j))) { + return (void *)(p + ZIP_LOCATE64_OFFSET(p + j)); + } + } while (j-- && i - j < 64 * 1024); + return (void *)(p + i); + } + } while (i--); return NULL; } diff --git a/libc/str/getzipcdircomment.c b/libc/str/getzipcdircomment.c index cefd8ab8..b738b4e0 100644 --- a/libc/str/getzipcdircomment.c +++ b/libc/str/getzipcdircomment.c @@ -22,7 +22,7 @@ * Returns comment of zip central directory. */ void *GetZipCdirComment(const uint8_t *eocd) { - if (READ32LE(eocd) == kZipCdir64HdrMagic) { + if (READ32LE(eocd) == kZipCdir64HdrMagic && ZIP_CDIR64_COMMENTSIZE(eocd)) { return ZIP_CDIR64_COMMENT(eocd); } else { return ZIP_CDIR_COMMENT(eocd); diff --git a/libc/str/getzipcdircommentsize.c b/libc/str/getzipcdircommentsize.c index 6741fada..78165b24 100644 --- a/libc/str/getzipcdircommentsize.c +++ b/libc/str/getzipcdircommentsize.c @@ -22,7 +22,7 @@ * Returns comment of zip central directory. */ uint64_t GetZipCdirCommentSize(const uint8_t *eocd) { - if (READ32LE(eocd) == kZipCdir64HdrMagic) { + if (READ32LE(eocd) == kZipCdir64HdrMagic && ZIP_CDIR64_COMMENTSIZE(eocd)) { return ZIP_CDIR64_COMMENTSIZE(eocd); } else { return ZIP_CDIR_COMMENTSIZE(eocd); diff --git a/libc/str/iswlower.c b/libc/str/iswlower.c index 79adef12..4e7769aa 100644 --- a/libc/str/iswlower.c +++ b/libc/str/iswlower.c @@ -714,8 +714,7 @@ int iswlower(wint_t c) { case u'ᶑ': // LATIN SMALL D W/ HOOK AND TAIL (0x1d91) case u'ᶒ': // LATIN SMALL E W/ RETROFLEX HOOK (0x1d92) case u'ᶓ': // LATIN SMALL OPEN E W/ RETROFLEX HOOK (0x1d93) - case u'ᶔ': // LATIN SMALL REVERSED OPEN E W/ RETROFLEX HOOK - // (0x1d94) + case u'ᶔ': // LATIN SMALL REVERSED OPEN E W/ RETROFLEX HOOK (0x1d94) case u'ᶕ': // LATIN SMALL SCHWA W/ RETROFLEX HOOK (0x1d95) case u'ᶖ': // LATIN SMALL I W/ RETROFLEX HOOK (0x1d96) case u'ᶗ': // LATIN SMALL OPEN O W/ RETROFLEX HOOK (0x1d97) @@ -1219,8 +1218,7 @@ int iswlower(wint_t c) { case u'ꝡ': // LATIN SMALL VY (0xa761) case u'ꝣ': // LATIN SMALL VISIGOTHIC Z (0xa763) case u'ꝥ': // LATIN SMALL THORN W/ STROKE (0xa765) - case u'ꝧ': // LATIN SMALL THORN W/ STROKE THROUGH DESCENDER - // (0xa767) + case u'ꝧ': // LATIN SMALL THORN W/ STROKE THROUGH DESCENDER (0xa767) case u'ꝩ': // LATIN SMALL VEND (0xa769) case u'ꝫ': // LATIN SMALL ET (0xa76b) case u'ꝭ': // LATIN SMALL IS (0xa76d) diff --git a/libc/str/iszipcdir64.c b/libc/str/iszipcdir64.c index ca18dcee..04444233 100644 --- a/libc/str/iszipcdir64.c +++ b/libc/str/iszipcdir64.c @@ -23,11 +23,16 @@ * Returns true if zip64 end of central directory header seems legit. */ bool IsZipCdir64(const uint8_t *p, size_t n, size_t i) { - if (i > n || n - i < kZipCdir64HdrMinSize) return false; + if (i + kZipCdir64HdrMinSize > n) return false; if (READ32LE(p + i) != kZipCdir64HdrMagic) return false; - if (i + ZIP_CDIR64_HDRSIZE(p + i) > n) return false; - if (ZIP_CDIR64_DISK(p + i) != ZIP_CDIR64_STARTINGDISK(p + i)) return false; - if (ZIP_CDIR64_RECORDSONDISK(p + i) != ZIP_CDIR64_RECORDS(p + i)) { + if (i + ZIP_CDIR64_HDRSIZE(p + i) + kZipCdir64LocatorSize > n) { + return false; + } + if (ZIP_LOCATE64_MAGIC(p + i + ZIP_CDIR64_HDRSIZE(p + i)) != + kZipCdir64LocatorMagic) { + return false; + } + if (ZIP_LOCATE64_OFFSET(p + i + ZIP_CDIR64_HDRSIZE(p + i)) != i) { return false; } if (ZIP_CDIR64_RECORDS(p + i) * kZipCfileHdrMinSize > diff --git a/libc/str/memchr.c b/libc/str/memchr.c index 1c917fb7..c764a9d0 100644 --- a/libc/str/memchr.c +++ b/libc/str/memchr.c @@ -29,19 +29,22 @@ */ void *memchr(const void *m, int c, size_t n) { uint64_t v, w; - const unsigned char *p, *pe; + const char *p, *pe; c &= 255; v = 0x0101010101010101 * c; - for (p = (const unsigned char *)m, pe = p + n; p + 8 <= pe; p += 8) { - w = (uint64_t)p[7] << 070 | (uint64_t)p[6] << 060 | (uint64_t)p[5] << 050 | - (uint64_t)p[4] << 040 | (uint64_t)p[3] << 030 | (uint64_t)p[2] << 020 | - (uint64_t)p[1] << 010 | (uint64_t)p[0] << 000; + for (p = m, pe = p + n; p + 8 <= pe; p += 8) { + w = (uint64_t)(255 & p[7]) << 070 | (uint64_t)(255 & p[6]) << 060 | + (uint64_t)(255 & p[5]) << 050 | (uint64_t)(255 & p[4]) << 040 | + (uint64_t)(255 & p[3]) << 030 | (uint64_t)(255 & p[2]) << 020 | + (uint64_t)(255 & p[1]) << 010 | (uint64_t)(255 & p[0]) << 000; if ((w = ~(w ^ v) & ((w ^ v) - 0x0101010101010101) & 0x8080808080808080)) { return p + ((unsigned)__builtin_ctzll(w) >> 3); } } for (; p < pe; ++p) { - if (*p == c) return p; + if ((*p & 255) == c) { + return p; + } } return NULL; } diff --git a/libc/str/strchr.c b/libc/str/strchr.c index ff418706..77ee980a 100644 --- a/libc/str/strchr.c +++ b/libc/str/strchr.c @@ -17,14 +17,16 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/bits/bits.h" #include "libc/str/str.h" -noasan static inline const char *strchr_x64(const char *p, uint64_t c) { +static noasan inline const char *strchr_x64(const char *p, uint64_t c) { unsigned a, b; uint64_t w, x, y; for (c *= 0x0101010101010101;; p += 8) { - w = READ64LE(p); + w = (uint64_t)(255 & p[7]) << 070 | (uint64_t)(255 & p[6]) << 060 | + (uint64_t)(255 & p[5]) << 050 | (uint64_t)(255 & p[4]) << 040 | + (uint64_t)(255 & p[3]) << 030 | (uint64_t)(255 & p[2]) << 020 | + (uint64_t)(255 & p[1]) << 010 | (uint64_t)(255 & p[0]) << 000; if ((x = ~(w ^ c) & ((w ^ c) - 0x0101010101010101) & 0x8080808080808080) | (y = ~w & (w - 0x0101010101010101) & 0x8080808080808080)) { if (x) { @@ -57,8 +59,8 @@ noasan static inline const char *strchr_x64(const char *p, uint64_t c) { */ char *strchr(const char *s, int c) { char *r; - for (c &= 0xff; (uintptr_t)s & 7; ++s) { - if ((*s & 0xff) == c) return s; + for (c &= 255; (uintptr_t)s & 7; ++s) { + if ((*s & 255) == c) return s; if (!*s) return NULL; } r = strchr_x64(s, c); diff --git a/libc/str/strxfrm.c b/libc/str/strxfrm.c index 57cda307..1f71ac3f 100644 --- a/libc/str/strxfrm.c +++ b/libc/str/strxfrm.c @@ -25,7 +25,6 @@ │ OTHER DEALINGS IN THE SOFTWARE. │ │ │ ╚─────────────────────────────────────────────────────────────────────────────*/ - #include "libc/assert.h" #include "libc/str/str.h" diff --git a/libc/sysv/calls/__sys_fcntl.s b/libc/sysv/calls/__sys_fcntl.s new file mode 100644 index 00000000..672d1118 --- /dev/null +++ b/libc/sysv/calls/__sys_fcntl.s @@ -0,0 +1,2 @@ +.include "o/libc/sysv/macros.internal.inc" +.scall __sys_fcntl,0x05c05c05c205c048,globl,hidden diff --git a/libc/sysv/calls/sys_fcntl.s b/libc/sysv/calls/sys_fcntl.s deleted file mode 100644 index a33374cd..00000000 --- a/libc/sysv/calls/sys_fcntl.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall sys_fcntl,0x05c05c05c205c048,globl,hidden diff --git a/libc/sysv/consts.sh b/libc/sysv/consts.sh index a9e0675b..140445c5 100755 --- a/libc/sysv/consts.sh +++ b/libc/sysv/consts.sh @@ -22,7 +22,7 @@ dir=libc/sysv/consts # The Fifth Bell System, Community Edition # » catalogue of carnage # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD Windows Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon errno ENOSYS 38 78 78 78 78 1 # system call unavailable; bsd consensus; kNtErrorInvalidFunction syscon errno EPERM 1 1 1 1 1 12 # operation not permitted; unix consensus; kNtErrorInvalidAccess (should be kNtErrorNotOwner but is that mutex only??); raised by accept(2), acct(2), add_key(2), adjtimex(2), arch_prctl(2), bdflush(2), bpf(2), capget(2), chmod(2), chown(2), chroot(2), clock_getres(2), clone(2), copy_file_range(2), create_module(2), delete_module(2), epoll_ctl(2), execve(2), fallocate(2), fanotify_init(2), fcntl(2), futex(2), get_robust_list(2), getdomainname(2), getgroups(2), gethostname(2), getpriority(2), getrlimit(2), getsid(2), gettimeofday(2), idle(2), init_module(2), io_submit(2), ioctl_console(2), ioctl_ficlonerange(2), ioctl_fideduperange(2), ioctl_ns(2), ioctl_tty(2), ioperm(2), iopl(2), ioprio_set(2), kcmp(2), kexec_load(2), keyctl(2), kill(2), link(2), lookup_dcookie(2), madvise(2), mbind(2), membarrier(2), migrate_pages(2), mkdir(2), mknod(2), mlock(2), mmap(2), mount(2), move_pages(2), msgctl(2), nice(2), open(2), open_by_handle_at(2), pciconfig_read(2), perf_event_open(2), pidfd_getfd(2), pidfd_send_signal(2), pivot_root(2), prctl(2), process_vm_readv(2), ptrace(2), quotactl(2), reboot(2), rename(2), request_key(2), rmdir(2), rt_sigqueueinfo(2), sched_setaffinity(2), sched_setattr(2), sched_setparam(2), sched_setscheduler(2), semctl(2), seteuid(2), setfsgid(2), setfsuid(2), setgid(2), setns(2), setpgid(2), setresuid(2), setreuid(2), setsid(2), setuid(2), setup(2), setxattr(2), shmctl(2), shmget(2), sigaltstack(2), spu_create(2), stime(2), swapon(2), symlink(2), syslog(2), timer_create(2), timerfd_create(2), tkill(2), truncate(2), umount(2), unlink(2), unshare(2), utime(2), utimensat(2), vhangup(2), vm86(2), write(2), unix(7), ip(7) syscon errno ENOENT 2 2 2 2 2 2 # no such file or directory; unix consensus; kNtErrorFileNotFound; raised by access(2), acct(2), alloc_hugepages(2), bind(2), bpf(2), chdir(2), chmod(2), chown(2), chroot(2), clock_getres(2), delete_module(2), epoll_ctl(2), execve(2), execveat(2), fanotify_mark(2), getdents(2), inotify_add_watch(2), ioctl_fat(2), kcmp(2), keyctl(2), link(2), mkdir(2), mknod(2), mount(2), msgget(2), open(2), open_by_handle_at(2), perf_event_open(2), query_module(2), quotactl(2), readdir(2), readlink(2), rename(2), rmdir(2), semget(2), shmget(2), spu_create(2), stat(2), statfs(2), statx(2), swapon(2), symlink(2), truncate(2), umount(2), unlink(2), utime(2), utimensat(2), unix(7), ip(7) @@ -106,59 +106,20 @@ syscon errno EBADMSG 74 94 89 92 88 0 # raised by ioctl_getfsmap syscon errno ECANCELED 125 89 85 88 87 0 # raised by timerfd_create(2) syscon errno EOWNERDEAD 130 105 96 94 97 0 # raised by pthread_cond_timedwait(3), pthread_mutex_consistent(3), pthread_mutex_getprioceiling(3), pthread_mutex_lock(3), pthread_mutex_timedlock(3), pthread_mutexattr_getrobust(3), pthread_mutexattr_setrobust(3) syscon errno ENOTRECOVERABLE 131 104 95 93 98 0 # raised by pthread_cond_timedwait(3), pthread_mutex_consistent(3), pthread_mutex_getprioceiling(3), pthread_mutex_lock(3), pthread_mutex_timedlock(3), pthread_mutexattr_getrobust(3), pthread_mutexattr_setrobust(3) -syscon errno ENONET 64 0 0 0 0 0 # bsd consensus; raised by accept(2) -syscon errno ERESTART 85 0 0 0 -3 0 # bsd consensus; should only be seen in ptrace() -syscon junkerr ECHRNG 44 0 0 0 0 0 # bsd consensus -syscon junkerr EL2NSYNC 45 0 0 0 0 0 # bsd consensus -syscon junkerr EL3HLT 46 0 0 0 0 0 # bsd consensus -syscon junkerr EL3RST 47 0 0 0 0 0 # bsd consensus -syscon junkerr ELNRNG 48 0 0 0 0 0 # bsd consensus -syscon junkerr EUNATCH 49 0 0 0 0 0 # bsd consensus -syscon junkerr ENOCSI 50 0 0 0 0 0 # bsd consensus -syscon junkerr EL2HLT 51 0 0 0 0 0 # bsd consensus -syscon junkerr EBADE 52 0 0 0 0 0 # bsd consensus -syscon junkerr EBADR 53 0 0 0 0 0 # bsd consensus -syscon junkerr EXFULL 54 0 0 0 0 0 # bsd consensus -syscon junkerr ENOANO 55 0 0 0 0 0 # bsd consensus -syscon junkerr EBADRQC 56 0 0 0 0 0 # bsd consensus -syscon junkerr EBADSLT 57 0 0 0 0 0 # bsd consensus -syscon junkerr ENOSTR 60 99 0 0 91 0 # -syscon junkerr ENODATA 61 96 0 0 89 0 # raised by getxattr(2), removexattr(2), setxattr(2) -syscon junkerr ENOSR 63 98 0 0 90 0 # -syscon junkerr ENOPKG 65 0 0 0 0 0 # bsd consensus, ip(7) -syscon junkerr ENOLINK 67 97 91 0 95 0 # -syscon junkerr EADV 68 0 0 0 0 0 # bsd consensus -syscon junkerr ESRMNT 69 0 0 0 0 0 # bsd consensus -syscon junkerr ECOMM 70 0 0 0 0 0 # bsd consensus -syscon junkerr EMULTIHOP 72 95 90 0 94 0 # -syscon junkerr EDOTDOT 73 0 0 0 0 0 # bsd consensus -syscon junkerr ENOTUNIQ 76 0 0 0 0 0 # bsd consensus -syscon junkerr EREMCHG 78 0 0 0 0 0 # bsd consensus -syscon junkerr ELIBACC 79 0 0 0 0 0 # bsd consensus -syscon junkerr ELIBBAD 80 0 0 0 0 0 # bsd consensus -syscon junkerr ELIBSCN 81 0 0 0 0 0 # bsd consensus -syscon junkerr ELIBMAX 82 0 0 0 0 0 # bsd consensus -syscon junkerr ELIBEXEC 83 0 0 0 0 0 # bsd consensus -syscon junkerr ESTRPIPE 86 0 0 0 0 0 # bsd consensus -syscon junkerr EUCLEAN 117 0 0 0 0 0 # bsd consensus -syscon junkerr ENOTNAM 118 0 0 0 0 0 # bsd consensus -syscon junkerr ENAVAIL 119 0 0 0 0 0 # bsd consensus -syscon junkerr EISNAM 120 0 0 0 0 0 # bsd consensus -syscon junkerr EREMOTEIO 121 0 0 0 0 0 # bsd consensus -syscon junkerr ENOMEDIUM 123 0 0 85 85 0 # -syscon junkerr EMEDIUMTYPE 124 0 0 86 86 0 # -syscon junkerr ENOKEY 126 0 0 0 0 0 # bsd consensus -syscon junkerr EKEYEXPIRED 127 0 0 0 0 0 # bsd consensus -syscon junkerr EKEYREVOKED 128 0 0 0 0 0 # bsd consensus -syscon junkerr EKEYREJECTED 129 0 0 0 0 0 # bsd consensus -syscon junkerr ERFKILL 132 0 0 0 0 0 # bsd consensus -syscon junkerr EHWPOISON 133 0 0 0 0 0 # bsd consensus -syscon junkerr EBADFD 77 9 9 9 9 6 # file descriptor in bad state; cf. EBADF; fudged on non-Linux -syscon compat EWOULDBLOCK 11 35 35 35 35 10035 # same as EWOULDBLOCK +syscon errno ENONET 64 0 0 0 0 0 # unilateral; raised by accept(2) +syscon errno ERESTART 85 -1 -1 -1 -3 0 # should only be seen in ptrace() +syscon errno ENOSR 63 98 0 90 90 0 # out of streams resources; something like EAGAIN; it's in POSIX; maybe some commercial UNIX returns it with openat, putmsg, putpmsg, posix_openpt, ioctl, open +syscon errno ENOSTR 60 99 0 0 91 0 # not a stream; returned by getmsg, putmsg, putpmsg, getpmsg +syscon errno ENODATA 61 96 0 0 89 0 # no data available; barely in posix; returned by ioctl +syscon errno EMULTIHOP 72 95 90 0 94 0 # barely in posix +syscon errno ENOLINK 67 97 91 0 95 0 # barely in posix +syscon errno ENOMEDIUM 123 0 0 85 0 0 # not posix; not documented +syscon errno EMEDIUMTYPE 124 0 0 86 0 0 # not posix; not documented +syscon compat EWOULDBLOCK 11 35 35 35 35 10035 # same as EAGAIN on every platform we've seen # signals # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon sig SIGHUP 1 1 1 1 1 1 # terminal hangup or daemon reload; resumable; auto-broadcasted to process group; unix consensus & faked on nt syscon sig SIGINT 2 2 2 2 2 2 # terminal ctrl-c keystroke; resumable; auto-broadcasted to process group; unix consensus & faked on nt; X3.159-1988 syscon sig SIGQUIT 3 3 3 3 3 3 # terminal ctrl-\ keystroke; resumable; unix consensus & faked on nt @@ -205,36 +166,37 @@ syscon open O_RDONLY 0 0 0 0 0 0xA0000000 # unix consensus & kNtGe syscon open O_WRONLY 1 1 1 1 1 0x40000000 # unix consensus & kNtGenericWrite syscon open O_RDWR 2 2 2 2 2 0xE0000000 # unix consensus & kNtGenericRead|kNtGenericWrite|kNtGenericExecute syscon open O_ACCMODE 3 3 3 3 3 0xE0000000 # O_RDONLY|O_WRONLY|O_RDWR -syscon open O_APPEND 0x0400 8 8 8 8 0x00000004 # bsd consensus & kNtFileAppendData; won't pose issues w/ mknod(S_IFIFO) -syscon open O_CREAT 0x40 0x0200 0x0200 0x0200 0x0200 0x00000040 # bsd consensus & NT faked as Linux -syscon open O_EXCL 0x80 0x0800 0x0800 0x0800 0x0800 0x00000080 # bsd consensus & NT faked as Linux -syscon open O_TRUNC 0x0200 0x0400 0x0400 0x0400 0x0400 0x00000200 # bsd consensus & NT faked as Linux -syscon open O_DIRECTORY 0x010000 0x100000 0x020000 0x020000 0x200000 0x02000000 # kNtFileFlagBackupSemantics -syscon open O_DIRECT 0x4000 0 0x010000 0 0x80000 0x00200000 # kNtFileFlagNoBuffering>>8 -syscon open O_CLOEXEC 0x080000 0x01000000 0x100000 0x010000 0x400000 0x00080000 # NT faked as Linux -syscon open O_TMPFILE 0x410000 0 0 0 0 0x04000100 # Linux 3.11+ (c. 2013) & kNtFileAttributeTemporary|kNtFileFlagDeleteOnClose +syscon open O_APPEND 0x00000400 8 8 8 8 0x00000004 # bsd consensus & kNtFileAppendData; won't pose issues w/ mknod(S_IFIFO) +syscon open O_CREAT 0x00000040 0x00000200 0x00000200 0x00000200 0x00000200 0x00000040 # bsd consensus & NT faked as Linux +syscon open O_EXCL 0x00000080 0x00000800 0x00000800 0x00000800 0x00000800 0x00000080 # bsd consensus & NT faked as Linux +syscon open O_TRUNC 0x00000200 0x00000400 0x00000400 0x00000400 0x00000400 0x00000200 # bsd consensus & NT faked as Linux +syscon open O_DIRECTORY 0x00010000 0x00100000 0x00020000 0x00020000 0x00200000 0x02000000 # kNtFileFlagBackupSemantics +syscon open O_DIRECT 0x00004000 0 0x00010000 0 0x00080000 0x00200000 # kNtFileFlagNoBuffering>>8 +syscon open O_CLOEXEC 0x00080000 0x01000000 0x00100000 0x00010000 0x00400000 0x00080000 # NT faked as Linux +syscon open O_TMPFILE 0x00410000 0 0 0 0 0x04000100 # Linux 3.11+ (c. 2013) & kNtFileAttributeTemporary|kNtFileFlagDeleteOnClose syscon open O_SPARSE 0 0 0 0 0 0x00040000 # we invented it -syscon open O_NDELAY 0x0800 4 4 4 4 0 # bsd consensus & kNtFileFlagWriteThrough>>8 → 0x00800000 (???) -syscon open O_NONBLOCK 0x0800 4 4 4 4 0x00000800 # bsd consensus & faked on nt to be same as linux -syscon open O_ASYNC 0x2000 0x40 0x40 0x40 0x40 0 # bsd consensus -syscon open O_NOFOLLOW 0x020000 0x0100 0x0100 0x0100 0x0100 0 # bsd consensus -syscon open O_SYNC 0x101000 0x80 0x80 0x80 0x80 0 # bsd consensus -syscon open O_NOCTTY 0x0100 0x020000 0x8000 0x8000 0x8000 0 # used for remote viewing (default behavior on freebsd) -syscon open O_DSYNC 0x1000 0x400000 0 0x80 0x10000 0 -syscon open O_RSYNC 0x101000 0 0 0x80 0x20000 0 -syscon open O_NOATIME 0x040000 0 0 0 0 0 -syscon open O_PATH 0x200000 0 0 0 0 0 -syscon open O_EXEC 0 0 0x040000 0 0x4000000 0 -syscon open O_TTY_INIT 0 0 0x080000 0 0 0 +syscon open O_NDELAY 0x00000800 0x00000004 0x00000004 0x00000004 0x00000004 0x00000800 # bsd consensus & kNtFileFlagWriteThrough>>8 → 0x00800000 (???) +syscon open O_NONBLOCK 0x00000800 0x00000004 0x00000004 0x00000004 0x00000004 0x00000800 # bsd consensus & faked on nt to be same as linux +syscon open O_ASYNC 0x00002000 0x00000040 0x00000040 0x00000040 0x00000040 0 # bsd consensus +syscon open O_NOFOLLOW 0x00020000 0x00000100 0x00000100 0x00000100 0x00000100 0 # bsd consensus +syscon open O_SYNC 0x00101000 0x00000080 0x00000080 0x00000080 0x00000080 0 # bsd consensus +syscon open O_NOCTTY 0x00000100 0x00020000 0x00008000 0x00008000 0x00008000 0 # used for remote viewing (default behavior on freebsd) +syscon open O_NOATIME 0x00040000 0 0 0 0 0 # optimize away access time update +syscon open O_EXEC 0 0 0x00040000 0 0x04000000 0 # it's specified by posix what does it mean +syscon open O_DSYNC 0x00001000 0x00400000 0 0x00000080 0x00010000 0 +syscon open O_RSYNC 0x00101000 0 0 0x00000080 0x00020000 0 +syscon open O_PATH 0x00200000 0 0 0 0 0 +syscon open O_TTY_INIT 0 0 0x00080000 0 0 0 syscon compat O_LARGEFILE 0 0 0 0 0 0 # mmap() flags # the revolutionary praxis of malloc() # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon compat MAP_FILE 0 0 0 0 0 0 # consensus syscon mmap MAP_SHARED 1 1 1 1 1 1 # forced consensus & faked nt syscon mmap MAP_PRIVATE 2 2 2 2 2 2 # forced consensus & faked nt +syscon mmap MAP_TYPE 15 15 15 15 15 15 # mask for type of mapping syscon mmap MAP_FIXED 0x10 0x10 0x10 0x10 0x10 0x10 # unix consensus; openbsd appears to forbid; faked nt syscon mmap MAP_ANONYMOUS 0x20 0x1000 0x1000 0x1000 0x1000 0x20 # bsd consensus; faked nt syscon mmap MAP_GROWSDOWN 0x0100 0 0x0400 0x4000 0x4000 0x100000 # mandatory for OpenBSD stacks; MAP_STACK on Free/OpenBSD; MEM_TOP_DOWN on NT @@ -246,7 +208,7 @@ syscon mmap MAP_HUGE_SHIFT 26 0 0 0 0 0 syscon mmap MAP_LOCKED 0x2000 0 0 0 0 0 syscon mmap MAP_NONBLOCK 0x10000 0 0 0 0 0 syscon mmap MAP_POPULATE 0x8000 0 0 0 0 0 # can avoid madvise(MADV_WILLNEED) on private file mapping -syscon mmap MAP_TYPE 15 0 0 0 0 0 # what is it +syscon mmap MAP_CONCEAL 0 0 0 0x8000 0 0 # omit from dumps syscon compat MAP_STACK 0x0100 0 0x0400 0x4000 0x2000 0x100000 # use MAP_GROWSDOWN syscon compat MAP_NOCORE 0 0 0x20000 0x8000 0x8000 0 # use MAP_CONCEAL syscon compat MAP_ANON 0x20 0x1000 0x1000 0x1000 0x1000 0x20 # bsd consensus; faked nt @@ -257,7 +219,7 @@ syscon compat MAP_32BIT 0x40 0 0x080000 0 0 0 # iffy # madvise() flags # beneath the iceberg memory management # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon madv MADV_NORMAL 0 0 0 0 0 0x00000080 # consensus & kNtFileAttributeNormal syscon compat POSIX_FADV_NORMAL 0 0 0 0 0 0x00000080 # consensus & kNtFileAttributeNormal syscon compat POSIX_MADV_NORMAL 0 0 0 0 0 0x00000080 # consensus & kNtFileAttributeNormal @@ -280,7 +242,7 @@ syscon madv MADV_HUGEPAGE 14 0 0 0 0 0 # TODO(jart): why would we syscon madv MADV_NOHUGEPAGE 15 0 0 0 0 0 # TODO(jart): why would we need it? syscon madv MADV_DODUMP 17 0 0 0 0 0 # TODO(jart): what is it? syscon madv MADV_DOFORK 11 0 0 0 0 0 # TODO(jart): what is it? -syscon madv MADV_DONTDUMP 16 0 0 0 0 0 # TODO(jart): what is it? +syscon madv MADV_DONTDUMP 16 0 0 0 0 0 # see MAP_CONCEAL in OpenBSD; TODO(jart): what is it? syscon madv MADV_DONTFORK 10 0 0 0 0 0 # TODO(jart): what is it? syscon madv MADV_HWPOISON 100 0 0 0 0 0 # TODO(jart): what is it? syscon madv MADV_REMOVE 9 0 0 0 0 0 # TODO(jart): what is it? @@ -289,7 +251,7 @@ syscon fadv POSIX_FADV_NOREUSE 5 0 5 0 5 0 # wut # mmap(), mprotect(), etc. # digital restrictions management for the people # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon mprot PROT_NONE 0 0 0 0 0 0 # mmap, mprotect, unix consensus (nt needs special business logic here) syscon mprot PROT_READ 1 1 1 1 1 1 # mmap, mprotect, unix consensus syscon mprot PROT_WRITE 2 2 2 2 2 2 # mmap, mprotect, unix consensus @@ -300,13 +262,21 @@ syscon mprot PROT_GROWSUP 0x02000000 0 0 0 0 0 # intended for mpro # mremap() flags # the revolutionary praxis of realloc() # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon mremap MREMAP_MAYMOVE 1 1 1 1 1 1 # faked non-linux (b/c linux only) syscon mremap MREMAP_FIXED 2 2 2 2 2 2 # faked non-linux (b/c linux only) +# sigprocmask() flags +# +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary +syscon misc SIG_BLOCK 0 1 1 1 1 0 # bsd consensus; faked nt +syscon misc SIG_UNBLOCK 1 2 2 2 2 1 # bsd consensus; faked nt +syscon misc SIG_SETMASK 2 3 3 3 3 2 # bsd consensus; faked nt +syscon misc SIG_ATOMIC_MIN -2147483648 -2147483648 -9223372036854775808 -2147483648 -2147483648 0 + # splice() flags # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon splice SPLICE_F_MOVE 1 0 0 0 0 0 # can be safely ignored by polyfill; it's a hint syscon splice SPLICE_F_NONBLOCK 2 0 0 0 0 0 # can be safely ignored by polyfill, since linux says it doesn't apply to underlying FDs syscon splice SPLICE_F_MORE 4 0 0 0 0 0 # can be safely ignored by polyfill; it's a hint @@ -314,7 +284,7 @@ syscon splice SPLICE_F_GIFT 8 0 0 0 0 0 # can probably be ignored # access() flags # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon access F_OK 0 0 0 0 0 0 # consensus syscon access X_OK 1 1 1 1 1 0xa0000000 # unix consensus and kNtGenericExecute | kNtGenericRead syscon access W_OK 2 2 2 2 2 0x40000000 # unix consensus and kNtGenericWrite @@ -322,29 +292,30 @@ syscon access R_OK 4 4 4 4 4 0x80000000 # unix consensus and kNtG # flock() flags # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon lock LOCK_SH 1 1 1 1 1 0 # shared [unix consensus] -syscon lock LOCK_EX 2 2 2 2 2 2 # exclusive [consensus!] -syscon lock LOCK_NB 4 4 4 4 4 1 # non-blocking [unix consensus] +syscon lock LOCK_EX 2 2 2 2 2 2 # exclusive [consensus!] a.k.a. kNtLockfileExclusiveLock +syscon lock LOCK_NB 4 4 4 4 4 1 # non-blocking [unix consensus] a.k.a. kNtLockfileFailImmediately syscon lock LOCK_UN 8 8 8 8 8 8 # unlock [unix consensus & faked NT] # waitpid() / wait4() options # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon waitpid WNOHANG 1 1 1 1 1 0 # helps you reap zombies; unix consensus syscon waitpid WUNTRACED 2 2 2 2 2 0 # unix consensus syscon waitpid WCONTINUED 8 0x10 4 8 16 0 # waitid() options +# no dice on openbsd >:\ # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon waitid WEXITED 4 4 0x10 0 32 0 syscon waitid WSTOPPED 2 8 2 0 2 0 syscon waitid WNOWAIT 0x01000000 0x20 8 0 0x10000 0 # stat::st_mode constants # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon stat S_IFREG 0100000 0100000 0100000 0100000 0100000 0100000 # regular file (unix consensus; faked nt) syscon stat S_IFBLK 0060000 0060000 0060000 0060000 0060000 0060000 # block device (unix consensus; faked nt) syscon stat S_IFCHR 0020000 0020000 0020000 0020000 0020000 0020000 # character device (unix consensus; faked nt) @@ -374,7 +345,7 @@ syscon stat S_IRWXO 0000007 0000007 0000007 0000007 0000007 000000 # fcntl() # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon fcntl2 F_DUPFD 0 0 0 0 0 0 # consensus syscon fcntl2 F_GETFD 1 1 1 1 1 1 # unix consensus & faked nt @@ -393,19 +364,22 @@ syscon fcntl2 F_SETFL 4 4 4 4 4 4 # unix consensus & faked nt syscon fcntl2 F_SETOWN 8 6 6 6 6 0 # bsd consensus syscon fcntl2 F_GETOWN 9 5 5 5 5 0 # bsd consensus -syscon fcntl F_ULOCK 0 0 0 0 0 0 # consensus -syscon fcntl F_RDLCK 0 1 1 1 1 0 # bsd consensus +# fcntl() POSIX Advisory Locks +# +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary +syscon fcntl F_SETLK 6 8 12 8 8 6 # polyfilled nt +syscon compat F_SETLK64 6 8 12 8 8 6 # polyfilled nt +syscon fcntl F_SETLKW 7 9 13 9 9 7 +syscon compat F_SETLKW64 7 9 13 9 9 7 +syscon fcntl F_GETLK 5 7 11 7 7 5 # polyfilled nt +syscon compat F_GETLK64 5 7 11 7 7 5 # polyfilled nt +syscon fcntl F_RDLCK 0 1 1 1 1 0 # polyfilled nt; bsd consensus +syscon fcntl F_WRLCK 1 3 3 3 3 1 # polyfilled nt; bsd consensus +syscon fcntl F_UNLCK 2 2 2 2 2 2 # polyfilled nt; unix consensus + syscon fcntl F_LOCK 1 1 1 1 1 0 # unix consensus -syscon fcntl F_WRLCK 1 3 3 3 3 0 # bsd consensus syscon fcntl F_TLOCK 2 2 2 2 2 0 # unix consensus -syscon fcntl F_UNLCK 2 2 2 2 2 0 # unix consensus syscon fcntl F_TEST 3 3 3 3 3 0 # unix consensus -syscon fcntl F_GETLK 5 7 11 7 7 0 -syscon fcntl F_SETLK 6 8 12 8 8 0 -syscon fcntl F_SETLKW 7 9 13 9 9 0 -syscon fcntl F_GETLK64 5 0 0 0 0 0 -syscon fcntl F_SETLK64 6 0 0 0 0 0 -syscon fcntl F_SETLKW64 7 0 0 0 0 0 syscon fcntl F_SETSIG 10 0 0 0 0 0 syscon fcntl F_GETSIG 11 0 0 0 0 0 syscon fcntl F_SETOWN_EX 15 0 0 0 0 0 @@ -418,10 +392,19 @@ syscon fcntl F_GETLEASE 0x0401 0 0 0 0 0 syscon fcntl F_NOTIFY 0x0402 0 0 0 0 0 syscon fcntl F_SETPIPE_SZ 0x0407 0 0 0 0 0 syscon fcntl F_GETPIPE_SZ 0x0408 0 0 0 0 0 +syscon fcntl F_ULOCK 0 0 0 0 0 0 # TODO: specified by posix but not kernels? + +syscon ioctl FIONBIO 0x5421 0x8004667e 0x8004667e 0x8004667e 0x8004667e 0x8004667e # BSD-The New Technology consensus; FIONBIO is traditional O_NONBLOCK; see F_SETFL for re-imagined api +syscon ioctl FIOASYNC 0x5452 0x8004667d 0x8004667d 0x8004667d 0x8004667d 0x8004667d # BSD-The New Technology consensus +syscon ioctl FIONREAD 0x541b 0x4004667f 0x4004667f 0x4004667f 0x4004667f 0x4004667f # BSD-The New Technology consensus; bytes waiting in FD's input buffer +#syscon ioctl FIONWRITE 0x0 0x0 0x40046677 0x0 0x0 -1 # [FreeBSD Generalization] bytes queued in FD's output buffer (same as TIOCOUTQ for TTY FDs; see also SO_SNDBUF) +#syscon ioctl FIONSPACE 0x0 0x0 0x40046676 0x0 0x0 -1 # [FreeBSD Generalization] capacity of FD's output buffer, e.g. equivalent to TIOCGSERIAL w/ UART +syscon ioctl TIOCINQ 0x541b 0x4004667f 0x4004667f 0x4004667f 0x4004667f 0x4004667f # [Linuxism] same as FIONREAD +#syscon ioctl TIOCOUTQ 0x5411 0x40047473 0x40047473 0x40047473 0x40047473 -1 # bytes queued in TTY's output buffer # openat(), fstatat(), linkat(), etc. magnums # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon at AT_FDCWD -100 -2 -100 -100 -100 -100 # faked nt syscon at AT_SYMLINK_FOLLOW 0x0400 0x40 0x0400 4 0x400 0 syscon at AT_SYMLINK_NOFOLLOW 0x0100 0x20 0x0200 2 0x200 0 # TODO(jart): What should NT do? @@ -434,13 +417,13 @@ syscon at AT_EMPTY_PATH 0x1000 0 0 0 0 0 # linux 2.6.39+; see unl # # Unsupported flags are encoded as 0. # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon memfd MFD_CLOEXEC 1 0 0 0 0 0 syscon memfd MFD_ALLOW_SEALING 2 0 0 0 0 0 # utimensat() special values # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon utime UTIME_NOW 0x3fffffff 0x3fffffff -1 -2 0x3fffffff -2 # timespec::tv_sec may be this; polyfilled xnu/nt syscon utime UTIME_OMIT 0x3ffffffe 0x3ffffffe -2 -1 0x3ffffffe -1 # timespec::tv_nsec may be this; polyfilled xnu/nt @@ -448,7 +431,7 @@ syscon utime UTIME_OMIT 0x3ffffffe 0x3ffffffe -2 -1 0x3ffffffe -1 # # # Unsupported values are encoded as 0. # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon auxv AT_EXECFD 2 0 2 0 2 0 # file descriptor of program syscon auxv AT_PHDR 3 0 3 0 3 0 # address of program headers of executable syscon auxv AT_PHENT 4 0 4 0 4 0 @@ -481,7 +464,7 @@ syscon auxv AT_NO_AUTOMOUNT 0x0800 0 0 0 0 0 # # Unsupported values are encoded as 127. # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon rlimit RLIMIT_CPU 0 0 0 0 0 127 # max cpu time in seconds; see SIGXCPU; unix consensus syscon rlimit RLIMIT_FSIZE 1 1 1 1 1 127 # max file size in bytes; unix consensus syscon rlimit RLIMIT_DATA 2 2 2 2 2 127 # max mmap() / brk() / sbrk() size in bytes; unix consensus @@ -501,7 +484,7 @@ syscon compat RLIMIT_VMEM 9 5 10 127 10 127 # same as RLIMIT_AS # resource limit special values # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon rlim RLIM_NLIMITS 16 9 15 9 12 0 # no clue why we need it syscon rlim RLIM_INFINITY 0xffffffffffffffff 0x7fffffffffffffff 0x7fffffffffffffff 0x7fffffffffffffff 0x7fffffffffffffff 0 syscon rlim RLIM_SAVED_CUR 0xffffffffffffffff 0x7fffffffffffffff 0x7fffffffffffffff 0x7fffffffffffffff 0x7fffffffffffffff 0 @@ -509,7 +492,7 @@ syscon rlim RLIM_SAVED_MAX 0xffffffffffffffff 0x7fffffffffffffff 0x7fffffffff # sigaction() codes # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon sigact SA_NOCLDSTOP 1 8 8 8 8 1 # lets you set SIGCHLD handler that's only notified on exit/termination and not notified on SIGSTOP/SIGTSTP/SIGTTIN/SIGTTOU/SIGCONT lool; bsd consensus syscon sigact SA_NOCLDWAIT 2 32 32 32 32 2 # changes SIGCHLD so the zombie is gone and you can't call wait(2) anymore; similar to SIGCHLD+SIG_IGN but may still deliver the SIGCHLD; bsd consensus syscon sigact SA_SIGINFO 4 64 64 64 64 4 # asks kernel to provide ucontext_t argument, which has mutable cpu/fpu state of signalled process; and it is polyfilled by cosmopolitan; bsd consensus @@ -522,10 +505,10 @@ syscon compat SA_ONESHOT 0x80000000 4 4 4 4 0x80000000 # same as SA # siginfo::si_code values # -# Windows NT is polyfilled as Linux. +# The New Technology NT is polyfilled as Linux. # Unsupported values are encoded as 0x80000000. # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon sicode SI_USER 0 0x010001 0x010001 0 0 0 # sent by kill(2); openbsd defines si_code<=0 as originating from user syscon sicode SI_QUEUE -1 0x010002 0x010002 -2 -1 -1 # sent by sigqueue(2) syscon sicode SI_TIMER -2 0x010003 0x010003 -3 -2 -2 # sent by setitimer(2) or clock_settime(2) @@ -575,12 +558,12 @@ syscon sicode POLL_HUP 6 6 6 6 6 6 # SIGIO; device disconnected; # sigalstack() values # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon ss SIGSTKSZ 0x2000 0x020000 0x8800 0x7000 0x7000 0x2000 # clock_{gettime,settime} timers # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon clock CLOCK_REALTIME 0 0 0 0 0 0 # consensus syscon clock CLOCK_MONOTONIC 1 1 4 3 3 1 # XNU/NT faked; could move backwards if NTP introduces negative leap second syscon clock CLOCK_PROCESS_CPUTIME_ID 2 -1 15 2 0x40000000 -1 @@ -595,7 +578,7 @@ syscon clock CLOCK_TAI 11 -1 -1 -1 -1 -1 # bsd consensus # poll() # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon poll POLLIN 1 1 1 1 1 0x300 # unix consensus syscon poll POLLPRI 2 2 2 2 2 0x0400 # unix consensus syscon poll POLLOUT 4 4 4 4 4 0x10 # unix consensus @@ -610,7 +593,7 @@ syscon poll POLLRDHUP 0x2000 0x10 0x10 0x10 0x10 2 # bsd consensu # epoll # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon epoll EPOLL_CLOEXEC 0x080000 0x01000000 0x100000 0x010000 0x010000 0x80000 # O_CLOEXEC syscon epoll EPOLL_CTL_ADD 1 1 1 1 1 1 # forced consensus, linux only natively, polyfilled elsewhere syscon epoll EPOLL_CTL_DEL 2 2 2 2 2 2 # forced consensus, linux only natively, polyfilled elsewhere @@ -636,7 +619,7 @@ syscon epoll EPOLLET 0x80000000 0x80000000 0x80000000 0x80000000 0x80000 # * 0 we define as EINVAL # * -1 we define as no-op # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon so SO_REUSEPORT 15 0x0200 0x0200 0x0200 0x0200 4 # bsd consensus (NT calls it SO_REUSEADDR) syscon so SO_REUSEADDR 2 4 4 4 4 0 # bsd consensus (default behavior on NT) syscon so SO_KEEPALIVE 9 8 8 8 8 8 # bsd consensus @@ -732,7 +715,7 @@ syscon sol SOL_X25 262 0 0 0 0 0 # @see https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt # @see https://www.iana.org/assignments/tcp-parameters/tcp-parameters.txt # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon tcp TCP_NODELAY 1 1 1 1 1 1 # strong consensus for disabling nagle's algorithm; so be sure to disable it by turning this on syscon tcp TCP_CORK 3 4 4 16 0 0 # nagle's algorithm strikes again; TCP_NOPUSH on BSD; be sure to turn it off; protip: mmap+writev vs. write+sendfile; see also /proc/sys/net/ipv4/tcp_autocorking; netbsd is 4 but not implemented syscon tcp TCP_MAXSEG 2 2 2 2 2 0 # reduces tcp segment size; see also tcp offloading @@ -763,7 +746,7 @@ syscon tcp TCP_REPAIR_OPTIONS 22 0 0 0 0 0 # what is it syscon tcp TCP_REPAIR_QUEUE 20 0 0 0 0 0 # what is it syscon tcp TCP_THIN_LINEAR_TIMEOUTS 16 0 0 0 0 0 # what is it -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon ip IP_DEFAULT_MULTICAST_LOOP 1 1 1 1 1 1 # consensus syscon ip IP_DEFAULT_MULTICAST_TTL 1 1 1 1 1 1 # consensus syscon ip IP_PMTUDISC_DONT 0 0 0 0 0 0 # consensus @@ -816,7 +799,7 @@ syscon ip INET_ADDRSTRLEN 0x10 0x10 0x10 0x10 0x10 22 # unix cons # ptrace() codes # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon ptrace PTRACE_TRACEME 0 0 0 0 -1 -1 # unix consensus a.k.a. PT_TRACE_ME syscon ptrace PTRACE_PEEKTEXT 1 1 1 1 -1 -1 # unix consensus a.k.a. PT_READ_I syscon ptrace PTRACE_PEEKDATA 2 2 2 2 -1 -1 # unix consensus a.k.a. PT_READ_D @@ -897,11 +880,6 @@ syscon iproto IPPROTO_BEETPH 94 0 0 0 0 0 syscon iproto IPPROTO_COMP 108 0 0 0 0 0 syscon iproto IPPROTO_DCCP 33 0 0 0 0 0 -syscon misc EXTA 14 0x4b00 0x4b00 0x4b00 0x4b00 0 # bsd consensus -syscon misc EXTB 15 0x9600 0x9600 0x9600 0x9600 0 # bsd consensus -syscon misc ERA 0x02002c 45 45 0 0 0 -syscon misc EMPTY 0 0 0 0 0 0 # consensus - syscon pr PR_SET_PTRACER_ANY -1 0 0 0 0 0 syscon pr PR_ENDIAN_BIG 0 0 0 0 0 0 # consensus syscon pr PR_FP_EXC_DISABLED 0 0 0 0 0 0 # consensus @@ -1005,209 +983,6 @@ syscon pr PR_FP_EXC_RES 0x080000 0 0 0 0 0 syscon pr PR_FP_EXC_INV 0x100000 0 0 0 0 0 syscon pr PR_SET_PTRACER 0x59616d61 0 0 0 0 0 -syscon log LOG_EMERG 0 0 0 0 0 0 # consensus -syscon log LOG_KERN 0 0 0 0 0 0 # consensus -syscon log LOG_ALERT 1 1 1 1 1 1 # unix consensus -syscon log LOG_PID 1 1 1 1 1 1 # unix consensus -syscon log LOG_CONS 2 2 2 2 2 2 # unix consensus -syscon log LOG_CRIT 2 2 2 2 2 2 # unix consensus -syscon log LOG_ERR 3 3 3 3 3 3 # unix consensus -syscon log LOG_ODELAY 4 4 4 4 4 4 # unix consensus -syscon log LOG_WARNING 4 4 4 4 4 4 # unix consensus -syscon log LOG_NOTICE 5 5 5 5 5 5 # unix consensus -syscon log LOG_INFO 6 6 6 6 6 6 # unix consensus -syscon log LOG_DEBUG 7 7 7 7 7 7 # unix consensus -syscon log LOG_PRIMASK 7 7 7 7 7 7 # unix consensus -syscon log LOG_NDELAY 8 8 8 8 8 8 # unix consensus -syscon log LOG_USER 8 8 8 8 8 8 # unix consensus -syscon log LOG_MAIL 0x10 0x10 0x10 0x10 0x10 0x10 # unix consensus -syscon log LOG_NOWAIT 0x10 0x10 0x10 0x10 0x10 0x10 # unix consensus -syscon log LOG_DAEMON 24 24 24 24 24 24 # unix consensus -syscon log LOG_NFACILITIES 24 25 24 24 24 24 -syscon log LOG_AUTH 0x20 0x20 0x20 0x20 0x20 0x20 # unix consensus -syscon log LOG_PERROR 0x20 0x20 0x20 0x20 0x20 0x20 # unix consensus -syscon log LOG_SYSLOG 40 40 40 40 40 40 # unix consensus -syscon log LOG_LPR 48 48 48 48 48 48 # unix consensus -syscon log LOG_NEWS 56 56 56 56 56 56 # unix consensus -syscon log LOG_UUCP 0x40 0x40 0x40 0x40 0x40 40 # unix consensus -syscon log LOG_CRON 72 72 72 72 72 72 # unix consensus -syscon log LOG_SELECT 76 0 0 0 0 0 -syscon log LOG_SENSE 77 0 0 0 0 0 -syscon log LOG_LOCAL0 0x80 0x80 0x80 0x80 0x80 0x80 # unix consensus -syscon log LOG_LOCAL1 136 136 136 136 136 136 # unix consensus -syscon log LOG_LOCAL2 144 144 144 144 144 144 # unix consensus -syscon log LOG_LOCAL3 152 152 152 152 152 152 # unix consensus -syscon log LOG_LOCAL4 160 160 160 160 160 160 # unix consensus -syscon log LOG_LOCAL5 168 168 168 168 168 168 # unix consensus -syscon log LOG_LOCAL6 176 176 176 176 176 176 # unix consensus -syscon log LOG_LOCAL7 184 184 184 184 184 184 # unix consensus -syscon log LOG_FACMASK 0x03f8 0x03f8 0x03f8 0x03f8 0x03f8 0x03f8 # unix consensus - -syscon sg SG_DXFER_TO_FROM_DEV -4 0 0 0 0 0 -syscon sg SG_DXFER_FROM_DEV -3 0 0 0 0 0 -syscon sg SG_DXFER_TO_DEV -2 0 0 0 0 0 -syscon sg SG_DXFER_NONE -1 0 0 0 0 0 -syscon sg SG_DEF_COMMAND_Q 0 0 0 0 0 0 # consensus -syscon sg SG_DEF_FORCE_LOW_DMA 0 0 0 0 0 0 # consensus -syscon sg SG_DEF_FORCE_PACK_ID 0 0 0 0 0 0 # consensus -syscon sg SG_DEF_KEEP_ORPHAN 0 0 0 0 0 0 # consensus -syscon sg SG_DEF_UNDERRUN_FLAG 0 0 0 0 0 0 # consensus -syscon sg SG_INFO_INDIRECT_IO 0 0 0 0 0 0 # consensus -syscon sg SG_INFO_OK 0 0 0 0 0 0 # consensus -syscon sg SG_SCSI_RESET_NOTHING 0 0 0 0 0 0 # consensus -syscon sg SG_DEFAULT_RETRIES 1 0 0 0 0 0 -syscon sg SG_FLAG_DIRECT_IO 1 0 0 0 0 0 -syscon sg SG_INFO_CHECK 1 0 0 0 0 0 -syscon sg SG_INFO_OK_MASK 1 0 0 0 0 0 -syscon sg SG_SCSI_RESET_DEVICE 1 0 0 0 0 0 -syscon sg SG_FLAG_LUN_INHIBIT 2 0 0 0 0 0 -syscon sg SG_INFO_DIRECT_IO 2 0 0 0 0 0 -syscon sg SG_SCSI_RESET_BUS 2 0 0 0 0 0 -syscon sg SG_SCSI_RESET_HOST 3 0 0 0 0 0 -syscon sg SG_INFO_MIXED_IO 4 0 0 0 0 0 -syscon sg SG_INFO_DIRECT_IO_MASK 6 0 0 0 0 0 -syscon misc VOLUME_OVERFLOW 13 0 0 0 0 0 -syscon sg SG_MAX_QUEUE 0x10 0 0 0 0 0 -syscon sg SG_MAX_SENSE 0x10 0 0 0 0 0 -syscon sg SG_DEFAULT_TIMEOUT 0x1770 0 0 0 0 0 -syscon sg SG_SET_TIMEOUT 0x2201 0 0 0 0 0 -syscon sg SG_GET_TIMEOUT 0x2202 0 0 0 0 0 -syscon sg SG_EMULATED_HOST 0x2203 0 0 0 0 0 -syscon sg SG_SET_TRANSFORM 0x2204 0 0 0 0 0 -syscon sg SG_GET_TRANSFORM 0x2205 0 0 0 0 0 -syscon sg SG_GET_COMMAND_Q 0x2270 0 0 0 0 0 -syscon sg SG_SET_COMMAND_Q 0x2271 0 0 0 0 0 -syscon sg SG_GET_RESERVED_SIZE 0x2272 0 0 0 0 0 -syscon sg SG_SET_RESERVED_SIZE 0x2275 0 0 0 0 0 -syscon sg SG_GET_SCSI_ID 0x2276 0 0 0 0 0 -syscon sg SG_SET_FORCE_LOW_DMA 0x2279 0 0 0 0 0 -syscon sg SG_GET_LOW_DMA 0x227a 0 0 0 0 0 -syscon sg SG_SET_FORCE_PACK_ID 0x227b 0 0 0 0 0 -syscon sg SG_GET_PACK_ID 0x227c 0 0 0 0 0 -syscon sg SG_GET_NUM_WAITING 0x227d 0 0 0 0 0 -syscon sg SG_SET_DEBUG 0x227e 0 0 0 0 0 -syscon sg SG_GET_SG_TABLESIZE 0x227f 0 0 0 0 0 -syscon sg SG_GET_VERSION_NUM 0x2282 0 0 0 0 0 -syscon sg SG_NEXT_CMD_LEN 0x2283 0 0 0 0 0 -syscon sg SG_SCSI_RESET 0x2284 0 0 0 0 0 -syscon sg SG_IO 0x2285 0 0 0 0 0 -syscon sg SG_GET_REQUEST_TABLE 0x2286 0 0 0 0 0 -syscon sg SG_SET_KEEP_ORPHAN 0x2287 0 0 0 0 0 -syscon sg SG_GET_KEEP_ORPHAN 0x2288 0 0 0 0 0 -syscon sg SG_BIG_BUFF 0x8000 0 0 0 0 0 -syscon sg SG_DEF_RESERVED_SIZE 0x8000 0 0 0 0 0 -syscon sg SG_SCATTER_SZ 0x8000 0 0 0 0 0 -syscon sg SG_FLAG_NO_DXFER 0x010000 0 0 0 0 0 - -syscon posix _POSIX_ARG_MAX 0x1000 0x1000 0x1000 0x1000 0x1000 0 # unix consensus -syscon posix _POSIX_CHILD_MAX 25 25 25 25 25 0 # unix consensus -syscon posix _POSIX_HOST_NAME_MAX 255 255 255 255 255 0 # unix consensus -syscon posix _POSIX_LINK_MAX 8 8 8 8 8 0 # unix consensus -syscon posix _POSIX_LOGIN_NAME_MAX 9 9 9 9 9 0 # unix consensus -syscon posix _POSIX_MAX_CANON 255 255 255 255 255 0 # unix consensus -syscon posix _POSIX_MAX_INPUT 255 255 255 255 255 0 # unix consensus -syscon posix _POSIX_NAME_MAX 14 14 14 14 14 14 # forced consensus -syscon posix _POSIX_NGROUPS_MAX 8 8 8 8 8 0 # unix consensus -syscon posix _POSIX_OPEN_MAX 20 20 20 20 20 20 # forced consensus -syscon posix _POSIX_PATH_MAX 255 255 255 255 255 255 # forced consensus -syscon posix _POSIX_PIPE_BUF 0x0200 0x0200 0x0200 0x0200 0x0200 0 # unix consensus -syscon posix _POSIX_RE_DUP_MAX 255 255 255 255 255 0 # unix consensus -syscon posix _POSIX_SEM_NSEMS_MAX 0x0100 0x0100 0x0100 0x0100 0x0100 0 # unix consensus -syscon posix _POSIX_SEM_VALUE_MAX 0x7fff 0x7fff 0x7fff 0x7fff 0x7fff 0 # unix consensus -syscon posix _POSIX_SSIZE_MAX 0x7fff 0x7fff 0x7fff 0x7fff 0x7fff 0 # unix consensus -syscon posix _POSIX_STREAM_MAX 8 8 8 8 8 0 # unix consensus -syscon posix _POSIX_SYMLINK_MAX 255 255 255 255 255 0 # unix consensus -syscon posix _POSIX_SYMLOOP_MAX 8 8 8 8 8 0 # unix consensus -syscon posix _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 4 4 4 4 0 # unix consensus -syscon posix _POSIX_THREAD_KEYS_MAX 0x80 0x80 0x80 0x80 0x80 0 # unix consensus -syscon posix _POSIX_TTY_NAME_MAX 9 9 9 9 9 0 # unix consensus -syscon posix _POSIX_TZNAME_MAX 6 6 6 6 6 0 # unix consensus -syscon posix _POSIX_CLOCK_SELECTION 0x031069 -1 -1 -1 -1 0 # bsd consensus -syscon posix _POSIX_FSYNC 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus -syscon posix _POSIX_MAPPED_FILES 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus -syscon posix _POSIX_MEMORY_PROTECTION 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus -syscon posix _POSIX_READER_WRITER_LOCKS 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus -syscon posix _POSIX_THREADS 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus -syscon posix _POSIX_THREAD_ATTR_STACKADDR 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus -syscon posix _POSIX_THREAD_ATTR_STACKSIZE 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus -syscon posix _POSIX_ADVISORY_INFO 0x031069 -1 0x030db0 -1 -1 0 -syscon posix _POSIX_ASYNCHRONOUS_IO 0x031069 -1 0x030db0 -1 -1 0 -syscon posix _POSIX_BARRIERS 0x031069 -1 0x030db0 0x030db0 0x030db0 0 -syscon posix _POSIX_JOB_CONTROL 1 0x030db0 1 1 1 0 -syscon posix _POSIX_MEMLOCK 0x031069 -1 -1 0x030db0 0x030db0 0 -syscon posix _POSIX_MEMLOCK_RANGE 0x031069 -1 0x030db0 0x030db0 0x030db0 0 -syscon posix _POSIX_MESSAGE_PASSING 0x031069 -1 0x030db0 -1 -1 0 -syscon posix _POSIX_NO_TRUNC 1 0x030db0 1 1 1 0 -syscon posix _POSIX_RAW_SOCKETS 0x031069 -1 0x030db0 0x030db0 0x030db0 0 -syscon posix _POSIX_REALTIME_SIGNALS 0x031069 -1 0x030db0 -1 -1 0 -syscon posix _POSIX_REGEXP 1 0x030db0 1 1 1 0 -syscon posix _POSIX_SEMAPHORES 0x031069 -1 0x030db0 0x030db0 0x030db0 0 -syscon posix _POSIX_SHARED_MEMORY_OBJECTS 0x031069 -1 0x030db0 0x031069 0x031069 0 -syscon posix _POSIX_SHELL 1 0x030db0 1 1 1 0 -syscon posix _POSIX_SPAWN 0x031069 -1 0x030db0 0x030db0 0x030db0 0 -syscon posix _POSIX_SPIN_LOCKS 0x031069 -1 0x030db0 0x030db0 0x030db0 0 -syscon posix _POSIX_THREAD_PRIORITY_SCHEDULING 0x031069 -1 0x030db0 -1 -1 0 -syscon posix _POSIX_THREAD_PROCESS_SHARED 0x031069 0x030db0 0x030db0 -1 -1 0 -syscon posix _POSIX_THREAD_SAFE_FUNCTIONS 0x031069 0x030db0 -1 0x030db0 0x030db0 0 -syscon posix _POSIX_THREAD_THREADS_MAX 0x40 0x40 0x40 4 4 0 -syscon posix _POSIX_TIMEOUTS 0x031069 -1 0x030db0 0x030db0 0x030db0 0 -syscon posix _POSIX_TIMERS 0x031069 -1 0x030db0 -1 -1 0 -syscon posix _POSIX_VERSION 0x031069 0x030db0 0x030db0 0x031069 0x031069 0 -syscon posix _POSIX_VDISABLE 0 255 255 255 255 0 # bsd consensus -syscon posix _POSIX_AIO_LISTIO_MAX 2 2 2 0 0 0 -syscon posix _POSIX_AIO_MAX 1 1 1 0 0 0 -syscon posix _POSIX_CHOWN_RESTRICTED 0 0x030db0 1 1 1 0 -syscon posix _POSIX_CLOCKRES_MIN 0x01312d00 0 0x01312d00 0x01312d00 0x01312d00 0 -syscon posix _POSIX_CPUTIME 0 -1 0x030db0 0x031069 0x031069 0 -syscon posix _POSIX_DELAYTIMER_MAX 0x20 0x20 0x20 0 0 0 -syscon posix _POSIX_MONOTONIC_CLOCK 0 -1 0x030db0 0x030db0 0x030db0 0 -syscon posix _POSIX_MQ_OPEN_MAX 8 8 8 0 0 0 -syscon posix _POSIX_MQ_PRIO_MAX 0x20 0x20 0x20 0 0 0 -syscon posix _POSIX_RTSIG_MAX 8 8 8 0 0 0 -syscon posix _POSIX_SAVED_IDS 1 0x030db0 0 1 1 0 -syscon posix _POSIX_SIGQUEUE_MAX 0x20 0x20 0x20 0 0 0 -syscon posix _POSIX_THREAD_CPUTIME 0 -1 0x030db0 0x031069 0x031069 0 -syscon posix _POSIX_TIMER_MAX 0x20 0x20 0x20 0 0 0 -syscon posix _POSIX_IPV6 0x031069 0x030db0 0 0 0 0 -syscon posix _POSIX_SS_REPL_MAX 0 4 4 0 0 0 -syscon posix _POSIX_TRACE_EVENT_NAME_MAX 0 30 30 0 0 0 -syscon posix _POSIX_TRACE_NAME_MAX 0 8 8 0 0 0 -syscon posix _POSIX_TRACE_SYS_MAX 0 8 8 0 0 0 -syscon posix _POSIX_TRACE_USER_EVENT_MAX 0 0x20 0x20 0 0 0 -syscon posix _POSIX_V6_LP64_OFF64 1 1 0 0 0 0 -syscon posix _POSIX_V7_LP64_OFF64 1 1 0 0 0 0 - -syscon icmp6 ICMP6_DST_UNREACH_NOROUTE 0 0 0 0 0 0 # consensus -syscon icmp6 ICMP6_PARAMPROB_HEADER 0 0 0 0 0 0 # consensus -syscon icmp6 ICMP6_TIME_EXCEED_TRANSIT 0 0 0 0 0 0 # consensus -syscon icmp6 ICMP6_DST_UNREACH_ADMIN 1 1 1 1 1 1 # consensus -syscon icmp6 ICMP6_PARAMPROB_NEXTHEADER 1 1 1 1 1 1 # consensus -syscon icmp6 ICMP6_TIME_EXCEED_REASSEMBLY 1 1 1 1 1 1 # consensus -syscon icmp6 ICMP6_DST_UNREACH 1 1 1 1 1 0 # unix consensus -syscon icmp6 ICMP6_FILTER 1 18 18 18 18 0 # bsd consensus -syscon icmp6 ICMP6_DST_UNREACH_BEYONDSCOPE 2 2 2 2 2 2 # consensus -syscon icmp6 ICMP6_PARAMPROB_OPTION 2 2 2 2 2 2 # consensus -syscon icmp6 ICMP6_PACKET_TOO_BIG 2 2 2 2 2 0 # unix consensus -syscon icmp6 ICMP6_DST_UNREACH_ADDR 3 3 3 3 3 3 # consensus -syscon icmp6 ICMP6_TIME_EXCEEDED 3 3 3 3 3 0 # unix consensus -syscon icmp6 ICMP6_DST_UNREACH_NOPORT 4 4 4 4 4 4 # consensus -syscon icmp6 ICMP6_PARAM_PROB 4 4 4 4 4 0 # unix consensus -syscon icmp6 ICMP6_RR_FLAGS_PREVDONE 8 8 8 8 8 0 # unix consensus -syscon icmp6 ICMP6_RR_FLAGS_SPECSITE 0x10 0x10 0x10 0x10 0x10 0 # unix consensus -syscon icmp6 ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10 0x40 0x40 0x40 0x40 0 # bsd consensus -syscon icmp6 ICMP6_RR_FLAGS_FORCEAPPLY 0x20 0x20 0x20 0x20 0x20 0 # unix consensus -syscon icmp6 ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20 0x80 0x80 0x80 0x80 0 # bsd consensus -syscon icmp6 ICMP6_RR_FLAGS_REQRESULT 0x40 0x40 0x40 0x40 0x40 0 # unix consensus -syscon icmp6 ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40 0x40 0x40 0x40 0x40 0 # unix consensus -syscon icmp6 ICMP6_INFOMSG_MASK 0x80 0x80 0x80 0x80 0x80 0x80 # consensus -syscon icmp6 ICMP6_ECHO_REQUEST 0x80 0x80 0x80 0x80 0x80 0 # unix consensus -syscon icmp6 ICMP6_RR_FLAGS_TEST 0x80 0x80 0x80 0x80 0x80 0 # unix consensus -syscon icmp6 ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80 0x80 0x80 0x80 0x80 0 # unix consensus -syscon icmp6 ICMP6_ECHO_REPLY 129 129 129 129 129 0 # unix consensus -syscon icmp6 ICMP6_ROUTER_RENUMBERING 138 138 138 138 138 0 # unix consensus -syscon icmp6 ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100 0x0100 0x0100 0x0100 0x0100 0 # unix consensus -syscon icmp6 ICMP6_RR_RESULT_FLAGS_OOB 0x0200 0x0200 0x0200 0x0200 0x0200 0 # unix consensus - syscon sio SIOCADDMULTI 0x8931 0x80206931 0x80206931 0x80206931 0x80206931 0 # bsd consensus syscon sio SIOCATMARK 0x8905 0x40047307 0x40047307 0x40047307 0x40047307 0 # bsd consensus syscon sio SIOCDELMULTI 0x8932 0x80206932 0x80206932 0x80206932 0x80206932 0 # bsd consensus @@ -1360,104 +1135,6 @@ syscon pf PF_VSOCK 40 0 0 0 0 0 syscon pf PF_WANPIPE 25 0 0 0 0 0 syscon pf PF_X25 9 0 0 0 0 0 -syscon ipv6 IPV6_PMTUDISC_DONT 0 0 0 0 0 0 # consensus -syscon ipv6 IPV6_RTHDR_LOOSE 0 0 0 0 0 0 # consensus -syscon ipv6 IPV6_RTHDR_TYPE_0 0 0 0 0 0 0 # consensus -syscon ipv6 IPV6_CHECKSUM 7 26 26 26 26 26 # bsd consensus -syscon ipv6 IPV6_JOIN_GROUP 20 12 12 12 12 12 # bsd consensus -syscon ipv6 IPV6_LEAVE_GROUP 21 13 13 13 13 13 # bsd consensus -syscon ipv6 IPV6_MULTICAST_HOPS 18 10 10 10 10 10 # bsd consensus -syscon ipv6 IPV6_MULTICAST_IF 17 9 9 9 9 9 # bsd consensus -syscon ipv6 IPV6_MULTICAST_LOOP 19 11 11 11 11 11 # bsd consensus -syscon ipv6 IPV6_UNICAST_HOPS 0x10 4 4 4 4 4 # bsd consensus -syscon ipv6 IPV6_V6ONLY 26 27 27 27 27 27 # bsd consensus -syscon ipv6 IPV6_RECVTCLASS 66 35 57 57 57 40 -syscon ipv6 IPV6_TCLASS 67 36 61 61 61 39 -syscon ipv6 IPV6_DONTFRAG 62 0 62 62 62 14 -syscon ipv6 IPV6_HOPLIMIT 52 0 47 47 47 21 -syscon ipv6 IPV6_HOPOPTS 54 0 49 49 49 1 -syscon ipv6 IPV6_PKTINFO 50 0 46 46 46 19 -syscon ipv6 IPV6_RECVRTHDR 56 0 38 38 38 38 -syscon ipv6 IPV6_RTHDR 57 0 51 51 51 0x20 -syscon ipv6 IPV6_DSTOPTS 59 0 50 50 50 0 -syscon ipv6 IPV6_IPSEC_POLICY 34 28 28 0 0 0 -syscon ipv6 IPV6_NEXTHOP 9 0 48 48 48 0 -syscon ipv6 IPV6_PATHMTU 61 0 44 44 44 0 -syscon ipv6 IPV6_RECVDSTOPTS 58 0 40 40 40 0 -syscon ipv6 IPV6_RECVHOPLIMIT 51 0 37 37 37 0 -syscon ipv6 IPV6_RECVHOPOPTS 53 0 39 39 39 0 -syscon ipv6 IPV6_RECVPATHMTU 60 0 43 43 43 0 -syscon ipv6 IPV6_RECVPKTINFO 49 0 36 36 36 0 -syscon ipv6 IPV6_RTHDRDSTOPTS 55 0 35 35 35 0 -syscon ipv6 IPV6_RTHDR_STRICT 1 1 1 0 0 0 -syscon ipv6 IPV6_ADD_MEMBERSHIP 20 0 0 0 0 12 # bsd consensus -syscon ipv6 IPV6_DROP_MEMBERSHIP 21 0 0 0 0 13 # bsd consensus -syscon ipv6 IPV6_HDRINCL 36 0 0 0 0 2 # bsd consensus -syscon ipv6 IPV6_MTU 24 0 0 0 0 72 # bsd consensus -syscon ipv6 IPV6_MTU_DISCOVER 23 0 0 0 0 71 # bsd consensus -syscon ipv6 IPV6_RECVERR 25 0 0 0 0 75 # bsd consensus -syscon ipv6 IPV6_2292DSTOPTS 4 23 0 0 0 0 -syscon ipv6 IPV6_2292HOPLIMIT 8 20 0 0 0 0 -syscon ipv6 IPV6_2292HOPOPTS 3 22 0 0 0 0 -syscon ipv6 IPV6_2292PKTINFO 2 19 0 0 0 0 -syscon ipv6 IPV6_2292PKTOPTIONS 6 25 0 0 0 0 -syscon ipv6 IPV6_2292RTHDR 5 24 0 0 0 0 -syscon ipv6 IPV6_AUTOFLOWLABEL 0 0 59 59 59 0 -syscon ipv6 IPV6_ADDRFORM 1 0 0 0 0 0 -syscon ipv6 IPV6_AUTHHDR 10 0 0 0 0 0 -syscon ipv6 IPV6_JOIN_ANYCAST 27 0 0 0 0 0 -syscon ipv6 IPV6_LEAVE_ANYCAST 28 0 0 0 0 0 -syscon ipv6 IPV6_PMTUDISC_DO 2 0 0 0 0 0 -syscon ipv6 IPV6_PMTUDISC_INTERFACE 4 0 0 0 0 0 -syscon ipv6 IPV6_PMTUDISC_OMIT 5 0 0 0 0 0 -syscon ipv6 IPV6_PMTUDISC_PROBE 3 0 0 0 0 0 -syscon ipv6 IPV6_PMTUDISC_WANT 1 0 0 0 0 0 -syscon ipv6 IPV6_ROUTER_ALERT 22 0 0 0 0 0 -syscon ipv6 IPV6_RXDSTOPTS 59 0 0 0 0 0 -syscon ipv6 IPV6_RXHOPOPTS 54 0 0 0 0 0 -syscon ipv6 IPV6_XFRM_POLICY 35 0 0 0 0 0 -syscon ipv6 IPV6_MINHOPCOUNT 0 0 0 65 65 0 -syscon ipv6 IPV6_ORIGDSTADDR 0 0 72 0 0 0 -syscon ipv6 IPV6_RECVORIGDSTADDR 0 0 72 0 0 0 -syscon ipv6 INET6_ADDRSTRLEN 46 46 46 46 46 65 # unix consensus - -syscon fan FAN_CLASS_NOTIF 0 0 0 0 0 0 # consensus -syscon fan FAN_ACCESS 1 0 0 0 0 0 -syscon fan FAN_ACCESS_PERM 0x020000 0 0 0 0 0 -syscon fan FAN_ALLOW 1 0 0 0 0 0 -syscon fan FAN_ALL_CLASS_BITS 12 0 0 0 0 0 -syscon fan FAN_ALL_EVENTS 59 0 0 0 0 0 -syscon fan FAN_ALL_INIT_FLAGS 63 0 0 0 0 0 -syscon fan FAN_ALL_MARK_FLAGS 255 0 0 0 0 0 -syscon fan FAN_ALL_OUTGOING_EVENTS 0x03403b 0 0 0 0 0 -syscon fan FAN_ALL_PERM_EVENTS 0x030000 0 0 0 0 0 -syscon fan FAN_CLASS_CONTENT 4 0 0 0 0 0 -syscon fan FAN_CLASS_PRE_CONTENT 8 0 0 0 0 0 -syscon fan FAN_CLOEXEC 1 0 0 0 0 0 -syscon fan FAN_CLOSE 24 0 0 0 0 0 -syscon fan FAN_CLOSE_NOWRITE 0x10 0 0 0 0 0 -syscon fan FAN_CLOSE_WRITE 8 0 0 0 0 0 -syscon fan FAN_DENY 2 0 0 0 0 0 -syscon fan FAN_EVENT_METADATA_LEN 24 0 0 0 0 0 -syscon fan FAN_EVENT_ON_CHILD 0x08000000 0 0 0 0 0 -syscon fan FAN_MARK_ADD 1 0 0 0 0 0 -syscon fan FAN_MARK_DONT_FOLLOW 4 0 0 0 0 0 -syscon fan FAN_MARK_FLUSH 0x80 0 0 0 0 0 -syscon fan FAN_MARK_IGNORED_MASK 0x20 0 0 0 0 0 -syscon fan FAN_MARK_IGNORED_SURV_MODIFY 0x40 0 0 0 0 0 -syscon fan FAN_MARK_MOUNT 0x10 0 0 0 0 0 -syscon fan FAN_MARK_ONLYDIR 8 0 0 0 0 0 -syscon fan FAN_MARK_REMOVE 2 0 0 0 0 0 -syscon fan FAN_MODIFY 2 0 0 0 0 0 -syscon fan FAN_NOFD -1 0 0 0 0 0 -syscon fan FAN_NONBLOCK 2 0 0 0 0 0 -syscon fan FAN_ONDIR 0x40000000 0 0 0 0 0 -syscon fan FAN_OPEN 0x20 0 0 0 0 0 -syscon fan FAN_OPEN_PERM 0x010000 0 0 0 0 0 -syscon fan FAN_Q_OVERFLOW 0x4000 0 0 0 0 0 -syscon fan FAN_UNLIMITED_MARKS 0x20 0 0 0 0 0 -syscon fan FAN_UNLIMITED_QUEUE 0x10 0 0 0 0 0 - syscon exit EXIT_SUCCESS 0 0 0 0 0 0 # consensus syscon exit EXIT_FAILURE 1 1 1 1 1 1 # consensus @@ -1467,7 +1144,7 @@ syscon exit EXIT_FAILURE 1 1 1 1 1 1 # consensus # - Dating back to 1980 in 4.0BSD; # - That won't be standardized. # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon ex EX_OK 0 0 0 0 0 0 # consensus syscon ex EX_USAGE 64 64 64 64 64 64 # unix consensus & force NT syscon ex EX_DATAERR 65 65 65 65 65 65 # unix consensus & force NT @@ -1489,7 +1166,7 @@ syscon ex EX__MAX 78 78 78 78 78 78 # unix consensus & force NT # getdents() constants # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon dt DT_UNKNOWN 0 0 0 0 0 0 # consensus syscon dt DT_FIFO 1 1 1 1 1 1 # unix consensus & faked nt syscon dt DT_CHR 2 2 2 2 2 2 # unix consensus & faked nt @@ -1501,14 +1178,30 @@ syscon dt DT_SOCK 12 12 12 12 12 12 # unix consensus & faked nt # msync() flags # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon ms MS_SYNC 4 16 0 2 4 4 # faked nt syscon ms MS_ASYNC 1 1 1 1 1 1 # consensus (faked nt) syscon ms MS_INVALIDATE 2 2 2 4 2 0 +# statvfs() flags +# +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary +syscon statvfs ST_NOSUID 2 2 2 2 2 0 # unix consensus +syscon statvfs ST_RDONLY 1 1 1 1 1 0 # unix consensus +syscon statvfs ST_APPEND 0x0100 0 0 0 0 0 +syscon statvfs ST_IMMUTABLE 0x0200 0 0 0 0 0 +syscon statvfs ST_MANDLOCK 0x40 0 0 0 0 0 +syscon statvfs ST_NOATIME 0x0400 0 0 0 0 0 +syscon statvfs ST_NODEV 4 0 0 0 0 0 +syscon statvfs ST_NODIRATIME 0x0800 0 0 0 0 0 +syscon statvfs ST_NOEXEC 8 0 0 0 0 0 +syscon statvfs ST_RELATIME 0x1000 0 0 0 0 0 +syscon statvfs ST_SYNCHRONOUS 0x10 0 0 0 0 0 +syscon statvfs ST_WRITE 0x80 0 0 0 0 0 + # mount flags # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon mount MS_ACTIVE 0x40000000 0 0 0 0 0 syscon mount MS_BIND 0x1000 0 0 0 0 0 syscon mount MS_DIRSYNC 0x80 0 0 0 0 0 @@ -1539,7 +1232,9 @@ syscon mount MS_SYNCHRONOUS 0x10 0 0 0 0 0 syscon mount MS_UNBINDABLE 0x020000 0 0 0 0 0 syscon mount MS_MGC_MSK 0xffff0000 0 0 0 0 0 -# TODO(jart): MSG_ZEROCOPY +# send() / recv() flags +# +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon msg MSG_OOB 1 1 1 1 1 1 # consensus syscon msg MSG_PEEK 2 2 2 2 2 2 # consensus syscon msg MSG_DONTROUTE 4 4 4 4 4 4 # consensus @@ -1566,33 +1261,240 @@ syscon msg MSG_RST 0x1000 0 0 0 0 0 syscon msg MSG_STAT 11 0 0 0 0 0 syscon msg MSG_SYN 0x0400 0 0 0 0 0 -syscon in IN_LOOPBACKNET 127 127 127 127 127 0 # unix consensus -syscon in IN_ACCESS 1 0 0 0 0 0 -syscon in IN_ALL_EVENTS 0x0fff 0 0 0 0 0 -syscon in IN_ATTRIB 4 0 0 0 0 0 -syscon in IN_CLOEXEC 0x080000 0 0 0 0 0 -syscon in IN_CLOSE 24 0 0 0 0 0 -syscon in IN_CLOSE_NOWRITE 0x10 0 0 0 0 0 -syscon in IN_CLOSE_WRITE 8 0 0 0 0 0 -syscon in IN_CREATE 0x0100 0 0 0 0 0 -syscon in IN_DELETE 0x0200 0 0 0 0 0 -syscon in IN_DELETE_SELF 0x0400 0 0 0 0 0 -syscon in IN_DONT_FOLLOW 0x02000000 0 0 0 0 0 -syscon in IN_EXCL_UNLINK 0x04000000 0 0 0 0 0 -syscon in IN_IGNORED 0x8000 0 0 0 0 0 -syscon in IN_ISDIR 0x40000000 0 0 0 0 0 -syscon in IN_MASK_ADD 0x20000000 0 0 0 0 0 -syscon in IN_MODIFY 2 0 0 0 0 0 -syscon in IN_MOVE 192 0 0 0 0 0 -syscon in IN_MOVED_FROM 0x40 0 0 0 0 0 -syscon in IN_MOVED_TO 0x80 0 0 0 0 0 -syscon in IN_MOVE_SELF 0x0800 0 0 0 0 0 -syscon in IN_NONBLOCK 0x0800 0 0 0 0 0 -syscon in IN_ONESHOT 0x80000000 0 0 0 0 0 -syscon in IN_ONLYDIR 0x01000000 0 0 0 0 0 -syscon in IN_OPEN 0x20 0 0 0 0 0 -syscon in IN_Q_OVERFLOW 0x4000 0 0 0 0 0 -syscon in IN_UNMOUNT 0x2000 0 0 0 0 0 +# getpriority() / setpriority() magnums (a.k.a. nice) +# +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary +syscon prio PRIO_PROCESS 0 0 0 0 0 0 # consensus / poly nt +syscon prio PRIO_PGRP 1 1 1 1 1 1 # unix consensus / poly nt +syscon prio PRIO_USER 2 2 2 2 2 2 # unix consensus / poly nt +syscon prio PRIO_MIN -20 -20 -20 -20 -20 -20 # unix consensus / poly nt +syscon prio PRIO_MAX 20 20 20 20 20 20 # unix consensus / poly nt +syscon prio NZERO 20 20 20 20 20 20 # unix consensus / polyfilled nt + +# Teletypewriter Control, e.g. +# +# TCSETS → About 70,800 results (0.31 seconds) +# = TCSETNOW → About 47,700 results (0.31 seconds) +# ≈ TCSETA → About 12,600 results (0.32 seconds) +# = TIOCSETA → About 3,110 results (0.41 seconds) +# +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary +syscon termios TCGETS 0x5401 0x40487413 0x402c7413 0x402c7413 0x402c7413 0 # Gets console settings; tcgetattr(tty, argp) → ioctl(tty, TCGETS, struct termios *argp); polyfilled NT +syscon compat TIOCGETA 0x5401 0x40487413 0x402c7413 0x402c7413 0x402c7413 0 # Gets console settings; = tcgetattr(tty, struct termios *argp) +#syscon compat TCGETA 0x5405 0 0 0 0 0 # Gets console settings; ≈ ioctl(fd, TCGETA, struct termio *argp) +syscon termios TCSANOW 0 0 0 0 0 0 # Sets console settings; tcsetattr(fd, TCSANOW, argp); polyfilled NT +syscon termios TCSETS 0x5402 0x80487414 0x802c7414 0x802c7414 0x802c7414 0x5402 # Sets console settings; = ioctl(tty, TCSETS, const struct termios *argp); polyfilled NT +syscon compat TIOCSETA 0x5402 0x80487414 0x802c7414 0x802c7414 0x802c7414 0x5402 # Sets console settings; = ioctl(tty, TIOCSETA, const struct termios *argp); polyfilled NT +#syscon compat TCSETA 0x5402 0x80487414 0x802c7414 0x802c7414 0x802c7414 0x5402 # Sets console settings; ≈ ioctl(tty, TCSETA, const struct termio *argp); polyfilled NT +syscon termios TCSADRAIN 1 1 1 1 1 1 # Drains output & sets console settings; tcsetawttr(fd, TCSADRAIN, argp); polyfilled NT +syscon termios TCSETSW 0x5403 0x80487415 0x802c7415 0x802c7415 0x802c7415 0x5403 # Drains output & sets console settings; = ioctl(tty, TCSETSW, const struct termios *argp); polyfilled NT +syscon compat TIOCSETAW 0x5403 0x80487415 0x802c7415 0x802c7415 0x802c7415 0x5403 # Drains output & sets console settings; = ioctl(tty, TIOCSETAW, const struct termios *argp); polyfilled NT +#syscon compat TCSETAW 0x5403 0x80487415 0x802c7415 0x802c7415 0x802c7415 0x5403 # Drains output & sets console settings; ≈ ioctl(tty, TCSETAW, const struct termio *argp); polyfilled NT +syscon termios TCSAFLUSH 2 2 2 2 2 2 # Drops input & drains output & sets console settings; tcsetafttr(fd, TCSAFLUSH, argp); polyfilled NT +syscon termios TCSETSF 0x5404 0x80487416 0x802c7416 0x802c7416 0x802c7416 0x5404 # Drops input & drains output & sets console settings; = ioctl(tty, TCSETSF, const struct termios *argp); polyfilled NT +syscon compat TIOCSETAF 0x5404 0x80487416 0x802c7416 0x802c7416 0x802c7416 0x5402 # Drops input & drains output & sets console settings; = ioctl(tty, TIOCSETAF, const struct termios *argp); polyfilled NT +#syscon compat TCSETAF 0x5404 0x80487416 0x802c7416 0x802c7416 0x802c7416 0x5402 # Drops input & drains output & sets console settings; ≈ ioctl(tty, TCSETAF, const struct termio *argp); polyfilled NT +syscon termios TIOCGWINSZ 0x5413 1074295912 1074295912 1074295912 1074295912 0x5413 # ioctl(tty, TIOCGWINSZ, struct winsize *argp); polyfilled NT +syscon termios TIOCSWINSZ 0x5414 0x80087467 0x80087467 0x80087467 0x80087467 0x5414 # ioctl(tty, TIOCSWINSZ, const struct winsize *argp) (faked NT) +syscon termios TIOCOUTQ 0x5411 0x40047473 0x40047473 0x40047473 0x40047473 0 # get # bytes queued in TTY's output buffer ioctl(tty, TIOCSWINSZ, const struct winsize *argp) +syscon termios TIOCCBRK 0x5428 0x2000747a 0x2000747a 0x2000747a 0x2000747a 0 # boop +syscon termios TIOCCONS 0x541d 0x80047462 0x80047462 0x80047462 0x80047462 0 # boop +syscon termios TIOCGETD 0x5424 0x4004741a 0x4004741a 0x4004741a 0x4004741a 0 # boop +syscon termios TIOCGPGRP 0x540f 0x40047477 0x40047477 0x40047477 0x40047477 0 # boop +syscon termios TIOCNOTTY 0x5422 0x20007471 0x20007471 0x20007471 0x20007471 0 # boop +syscon termios TIOCNXCL 0x540d 0x2000740e 0x2000740e 0x2000740e 0x2000740e 0 # boop +syscon termios TIOCSBRK 0x5427 0x2000747b 0x2000747b 0x2000747b 0x2000747b 0 # boop +syscon termios TIOCSCTTY 0x540e 0x20007461 0x20007461 0x20007461 0x20007461 0 # boop +syscon termios TIOCSETD 0x5423 0x8004741b 0x8004741b 0x8004741b 0x8004741b 0 # boop +syscon termios TIOCSIG 0x40045436 0x2000745f 0x2004745f 0x8004745f 0x8004745f 0 # boop +syscon termios TIOCSPGRP 0x5410 0x80047476 0x80047476 0x80047476 0x80047476 0 # boop +syscon termios TIOCSTI 0x5412 0x80017472 0x80017472 0 0 0 # boop +syscon termios TIOCGPTN 0x80045430 0 0x4004740f 0 0 0 # boop +syscon termios TIOCGSID 0x5429 0 0x40047463 0x40047463 0x40047463 0 # boop +syscon termios TABLDISC 0 0x3 0 0x3 0x3 0 # boop +syscon termios SLIPDISC 0 0x4 0x4 0x4 0x4 0 # boop +syscon termios PPPDISC 0 0x5 0x5 0x5 0x5 0 # boop +syscon termios TIOCDRAIN 0 0x2000745e 0x2000745e 0x2000745e 0x2000745e 0 # boop +syscon termios TIOCSTAT 0 0x20007465 0x20007465 0x20007465 0x20007465 0 # boop +syscon termios TIOCSTART 0 0x2000746e 0x2000746e 0x2000746e 0x2000746e 0 # boop +syscon termios TIOCCDTR 0 0x20007478 0x20007478 0x20007478 0x20007478 0 # boop +syscon termios TIOCSDTR 0 0x20007479 0x20007479 0x20007479 0x20007479 0 # boop +syscon termios TIOCFLUSH 0 0x80047410 0x80047410 0x80047410 0x80047410 0 # boop +syscon termios TIOCEXT 0 0x80047460 0x80047460 0x80047460 0x80047460 0 # boop +syscon termios TIOCGDRAINWAIT 0 0x40047456 0x40047456 0 0 0 # boop +syscon termios TIOCTIMESTAMP 0 0x40107459 0x40107459 0 0 0 # boop +syscon termios TIOCSDRAINWAIT 0 0x80047457 0x80047457 0 0 0 # boop +syscon termios TIOCREMOTE 0 0x80047469 0 0x80047469 0x80047469 0 # boop +syscon termios TTYDISC 0 0 0 0 0 0 # boop +syscon termios TIOCFLAG_SOFTCAR 0 0 0 0x1 0x1 0 # boop +syscon termios TIOCFLAG_PPS 0 0 0 0x10 0x10 0 # boop +syscon termios TIOCFLAG_CLOCAL 0 0 0 0x2 0x2 0 # boop +syscon termios TIOCCHKVERAUTH 0 0 0 0x2000741e 0x2000741e 0 # boop +syscon termios TIOCGFLAGS 0 0 0 0x4004745d 0x4004745d 0 # boop +syscon termios TIOCGTSTAMP 0 0 0 0x4010745b 0x4010745b 0 # boop +syscon termios STRIPDISC 0 0 0 0x6 0x6 0 # boop +syscon termios NMEADISC 0 0 0 0x7 0x7 0 # boop +syscon termios TIOCUCNTL_CBRK 0 0 0 0x7a 0x7a 0 # boop +syscon termios TIOCFLAG_MDMBUF 0 0 0 0x8 0x8 0 # boop +syscon termios TIOCSETVERAUTH 0 0 0 0x8004741c 0x8004741c 0 # boop +syscon termios TIOCSFLAGS 0 0 0 0x8004745c 0x8004745c 0 # boop +syscon termios TIOCSTSTAMP 0 0 0 0x8008745a 0x8008745a 0 # boop +syscon termios ENDRUNDISC 0 0 0 0x9 0x9 0 # boop +syscon termios TIOCPTMASTER 0 0 0x2000741c 0 0 0 # boop +syscon termios NETGRAPHDISC 0 0 0x6 0 0 0 # boop +syscon termios H4DISC 0 0 0x7 0 0 0 # boop +syscon termios ISIG 0b0000000000000001 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000000000001 # termios.c_lflag|=ISIG makes Ctrl-C, Ctrl-\, etc. generate signals +syscon termios ICANON 0b0000000000000010 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000000000010 # termios.c_lflag&=~ICANON disables 1960's version of gnu readline (see also VMIN) +syscon termios XCASE 0b0000000000000100 0 0 16777216 0 0b0000000000000100 # termios.c_lflag +syscon termios ECHO 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 # termios.c_lflag&=~ECHO is for passwords and raw mode +syscon termios ECHOE 0b0000000000010000 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000010000 # termios.c_lflag +syscon termios ECHOK 0b0000000000100000 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000100000 # termios.c_lflag +syscon termios ECHONL 0b0000000001000000 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000001000000 # termios.c_lflag +syscon termios NOFLSH 0b0000000010000000 2147483648 2147483648 2147483648 2147483648 0b0000000010000000 # termios.c_lflag|=NOFLSH means don't flush on INT/QUIT/SUSP +syscon termios TOSTOP 0b0000000100000000 4194304 4194304 4194304 4194304 0b0000000100000000 # termios.c_lflag|=TOSTOP raises SIGTTOU to process group if background job tries to write to controlling terminal +syscon termios ECHOCTL 0b0000001000000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000001000000000 # termios.c_lflag|=ECHOCTL prints ^𝑥 codes for monotonic motion +syscon termios ECHOPRT 0b0000010000000000 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000010000000000 # termios.c_lflag|=ECHOPRT includes the parity bit +syscon termios ECHOKE 0b0000100000000000 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000100000000000 # termios.c_lflag +syscon termios FLUSHO 0b0001000000000000 8388608 8388608 8388608 8388608 0b0001000000000000 # termios.c_lflag +syscon termios PENDIN 0b0100000000000000 536870912 536870912 536870912 536870912 0b0100000000000000 # termios.c_lflag +syscon termios IEXTEN 0b1000000000000000 0b0000010000000000 0b0000010000000000 0b0000010000000000 0b0000010000000000 0b1000000000000000 # termios.c_lflag&=~IEXTEN disables platform input processing magic +syscon termios EXTPROC 65536 0b0000100000000000 0b0000100000000000 0b0000100000000000 0b0000100000000000 65536 # termios.c_lflag +syscon termios IGNBRK 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 # termios.c_iflag it's complicated, uart only? UNIXCONSENSUS +syscon termios BRKINT 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000010 # termios.c_iflag it's complicated, uart only? UNIXCONSENSUS +syscon termios IGNPAR 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000000100 # termios.c_iflag|=IGNPAR ignores parity and framing errors; see PARMRK UNIXCONSENSUS +syscon termios PARMRK 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 # termios.c_iflag|=PARMRK passes-through parity bit UNIXCONSENSUS +syscon termios INPCK 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000010000 # termios.c_iflag|=INPCK enables parity checking UNIXCONSENSUS +syscon termios ISTRIP 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000000000100000 # termios.c_iflag|=ISTRIP automates read(1)&0x7f UNIXCONSENSUS +syscon termios INLCR 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 # termios.c_iflag|=INLCR maps \n → \r input UNIXCONSENSUS +syscon termios IGNCR 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 # termios.c_iflag|=IGNCR maps \r → ∅ input UNIXCONSENSUS +syscon termios ICRNL 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 # termios.c_iflag|=ICRNL maps \r → \n input UNIXCONSENSUS +syscon termios IUCLC 0b0000001000000000 0 0 0b0001000000000000 0 0b0000001000000000 # termios.c_iflag|=IUCLC maps A-Z → a-z input +syscon termios IXON 0b0000010000000000 0b0000001000000000 0b0000001000000000 0b0000001000000000 0b0000001000000000 0b0000010000000000 # termios.c_iflag|=IXON enables flow rida +syscon termios IXANY 0b0000100000000000 0b0000100000000000 0b0000100000000000 0b0000100000000000 0b0000100000000000 0b0000100000000000 # termios.c_iflag|=IXANY tying will un-stuck teletype UNIXCONSENSUS +syscon termios IXOFF 0b0001000000000000 0b0000010000000000 0b0000010000000000 0b0000010000000000 0b0000010000000000 0b0001000000000000 # termios.c_iflag|=IXOFF disables annoying display freeze keys +syscon termios IMAXBEL 0b0010000000000000 0b0010000000000000 0b0010000000000000 0b0010000000000000 0b0010000000000000 0b0010000000000000 # termios.c_iflag|=IMAXBEL rings when queue full UNIXCONSENSUS +syscon termios IUTF8 0b0100000000000000 0b0100000000000000 0 0 0 0b0100000000000000 # termios.c_iflag|=IUTF8 helps w/ rubout on UTF-8 input +syscon termios OPOST 0b0000000000000001 0b000000000000000001 0b000000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 # termios.c_oflag&=~OPOST disables output processing magic +syscon termios OLCUC 0b0000000000000010 0 0 0b0000000000100000 0 0b0000000000000010 # termios.c_oflag|=OLCUC maps a-z → A-Z output +syscon termios ONLCR 0b0000000000000100 0b000000000000000010 0b000000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000100 # termios.c_oflag|=ONLCR maps \n → \r\n output +syscon termios OCRNL 0b0000000000001000 0b000000000000010000 0b000000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000001000 # termios.c_oflag|=OCRNL maps \r → \n output +syscon termios ONOCR 0b0000000000010000 0b000000000000100000 0b000000000000100000 0b0000000001000000 0b0000000001000000 0b0000000000010000 # termios.c_oflag|=ONOCR maps \r → ∅ output iff column 0 +syscon termios ONLRET 0b0000000000100000 0b000000000001000000 0b000000000001000000 0b0000000010000000 0b0000000010000000 0b0000000000100000 # termios.c_oflag|=ONLRET maps \r → ∅ output +syscon termios OFILL 0b0000000001000000 0b000000000010000000 0 0 0 0b0000000001000000 # termios.c_oflag +syscon termios OFDEL 0b0000000010000000 0b100000000000000000 0 0 0 0b0000000010000000 # termios.c_oflag +syscon termios NLDLY 0b0000000100000000 0b000000001100000000 0b000000001100000000 0 0 0b0000000100000000 # (termios.c_oflag & NLDLY) ∈ {NL0,NL1,NL2,NL3} +syscon termios NL0 0b0000000000000000 0b000000000000000000 0b000000000000000000 0 0b000000000000000000 0b0000000000000000 # (termios.c_oflag & NLDLY) == NL0 +syscon termios NL1 0b0000000100000000 0b000000000100000000 0b000000000100000000 0 0b000000000100000000 0b0000000100000000 # (termios.c_oflag & NLDLY) == NL1 +syscon termios NL2 0 0b000000001000000000 0b000000001000000000 0 0b000000001000000000 0 # (termios.c_oflag & NLDLY) == NL2 +syscon termios NL3 0 0b000000001100000000 0b000000001100000000 0 0b000000001100000000 0 # (termios.c_oflag & NLDLY) == NL3 +syscon termios CRDLY 0b0000011000000000 0b000011000000000000 0b000011000000000000 0 0 0b0000011000000000 # (termios.c_oflag & CRDLY) ∈ {CR0,CR1,CR2,CR3} +syscon termios CR0 0b0000000000000000 0b000000000000000000 0b000000000000000000 0 0b000000000000000000 0b0000000000000000 # (termios.c_oflag & CRDLY) == CR0 +syscon termios CR1 0b0000001000000000 0b000001000000000000 0b000001000000000000 0 0b000001000000000000 0b0000001000000000 # (termios.c_oflag & CRDLY) == CR1 +syscon termios CR2 0b0000010000000000 0b000010000000000000 0b000010000000000000 0 0b000000010000000000 0b0000010000000000 # (termios.c_oflag & CRDLY) == CR2 +syscon termios CR3 0b0000011000000000 0b000011000000000000 0b000011000000000000 0 0b000000011000000000 0b0000011000000000 # (termios.c_oflag & CRDLY) == CR3 +syscon termios TABDLY 0b0001100000000000 0b000000110000000100 0b000000000000000100 0 0 0b0001100000000000 # (termios.c_oflag & TABDLY) ∈ {TAB0,TAB1,TAB2,TAB3,XTABS} +syscon termios TAB0 0b0000000000000000 0b000000000000000000 0b000000000000000000 0 0b000000000000000000 0b0000000000000000 # (termios.c_oflag & TABDLY) == TAB0 +syscon termios TAB1 0b0000100000000000 0b000000010000000000 0b000000010000000000 0 0b000000010000000000 0b0000100000000000 # (termios.c_oflag & TABDLY) == TAB1 +syscon termios TAB2 0b0001000000000000 0b000000100000000000 0b000000100000000000 0 0b000000100000000000 0b0001000000000000 # (termios.c_oflag & TABDLY) == TAB2 +syscon termios TAB3 0b0001100000000000 0b000000000000000100 0b000000000000000100 0 0b000000000000000100 0b0001100000000000 # (termios.c_oflag & TABDLY) == TAB3 +syscon termios XTABS 0b0001100000000000 0b000000110000000000 0b000000110000000000 0 0b000000110000000000 0b0001100000000000 # (termios.c_oflag & TABDLY) == XTABS +syscon termios BSDLY 0b0010000000000000 0b001000000000000000 0b001000000000000000 0 0 0b0010000000000000 # termios.c_oflag +syscon termios BS0 0b0000000000000000 0b000000000000000000 0b000000000000000000 0 0 0b0000000000000000 # termios.c_oflag +syscon termios BS1 0b0010000000000000 0b001000000000000000 0b001000000000000000 0 0 0b0010000000000000 # termios.c_oflag +syscon termios VTDLY 0b0100000000000000 0b010000000000000000 0b010000000000000000 0 0 0b0100000000000000 # termios.c_oflag +syscon termios VT0 0b0000000000000000 0b000000000000000000 0b000000000000000000 0 0 0b0000000000000000 # termios.c_oflag +syscon termios VT1 0b0100000000000000 0b010000000000000000 0b010000000000000000 0 0 0b0100000000000000 # termios.c_oflag +syscon termios FFDLY 0b1000000000000000 0b000100000000000000 0b000100000000000000 0 0 0b1000000000000000 # termios.c_oflag +syscon termios FF0 0b0000000000000000 0b000000000000000000 0b000000000000000000 0 0 0b0000000000000000 # termios.c_oflag +syscon termios FF1 0b1000000000000000 0b000100000000000000 0b000100000000000000 0 0 0b1000000000000000 # termios.c_oflag +syscon termios CS6 0b0000000000010000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000000010000 # termios.c_cflag flag for 6-bit characters +syscon termios CS7 0b0000000000100000 0b0000001000000000 0b0000001000000000 0b0000001000000000 0b0000001000000000 0b0000000000100000 # termios.c_cflag flag for 7-bit characters +syscon termios CS8 0b0000000000110000 0b0000001100000000 0b0000001100000000 0b0000001100000000 0b0000001100000000 0b0000000000110000 # termios.c_cflag flag for 8-bit characters +syscon termios CSIZE 0b0000000000110000 0b0000001100000000 0b0000001100000000 0b0000001100000000 0b0000001100000000 0b0000000000110000 # mask for CS𝑥 flags +syscon termios NCCS 32 32 32 32 20 32 # ARRAYLEN(termios.c_cc); faked xnu/freebsd/openbsd (originally 20) and faked nt +syscon termios VINTR 0 8 8 8 8 0 # termios.c_cc[VINTR]=𝑥 +syscon termios VQUIT 1 9 9 9 9 0 # termios.c_cc[VQUIT]=𝑥 +syscon termios VERASE 2 3 3 3 3 0 # termios.c_cc[VERASE]=𝑥 +syscon termios VKILL 3 5 5 5 5 0 # termios.c_cc[VKILL]=𝑥 +syscon termios VEOF 4 0 0 0 0 0 # termios.c_cc[VEOF]=𝑥 +syscon termios VTIME 5 17 17 17 17 0 # termios.c_cc[VTIME]=𝑥 sets non-canonical read timeout to 𝑥×𝟷𝟶𝟶ms which is needed when entering escape sequences manually with the escape key +syscon termios VMIN 6 16 16 16 16 0 # termios.c_cc[VMIN]=𝑥 in non-canonical mode can be set to 0 for non-blocking reads, 1 for single character raw mode reads, or higher to buffer +syscon termios VSWTC 7 0 0 0 0 0 # termios.c_cc[VSWTC]=𝑥 +syscon termios VSTART 8 12 12 12 12 0 # termios.c_cc[VSTART]=𝑥 +syscon termios VSTOP 9 13 13 13 13 0 # termios.c_cc[VSTOP]=𝑥 +syscon termios VSUSP 10 10 10 10 10 0 # termios.c_cc[VSUSP]=𝑥 defines suspend, i.e. Ctrl-Z (a.k.a. →, ^Z, SUB, 26, 032, 0x1A, ord('Z')^0b01000000); unix consensus +syscon termios VEOL 11 1 1 1 1 0 # termios.c_cc[VEOL]=𝑥 +syscon termios VEOL2 16 2 2 2 2 0 # termios.c_cc[VEOL2]=𝑥 +syscon termios VREPRINT 12 6 6 6 6 0 # termios.c_cc[VREPRINT]=𝑥 +syscon termios VDISCARD 13 15 15 15 15 0 # termios.c_cc[VDISCARD]=𝑥 +syscon termios VWERASE 14 4 4 4 4 0 # termios.c_cc[VWERASE]=𝑥 +syscon termios VLNEXT 15 14 14 14 14 0 # termios.c_cc[VLNEXT]=𝑥 +syscon termios TIOCSERGETLSR 0x5459 0 0 0 0 0 # +syscon termios TIOCSERGETMULTI 0x545a 0 0 0 0 0 # +syscon termios TIOCSERSETMULTI 0x545b 0 0 0 0 0 # +syscon termios TIOCSER_TEMT 1 0 0 0 0 0 # +syscon termios VERIFY 47 0 0 0 0 0 +syscon termios PARENB 0x0100 0x1000 0x1000 0x1000 0x1000 0 # +syscon termios PARODD 0x0200 0x2000 0x2000 0x2000 0x2000 0 # +syscon termios CIBAUD 0x100f0000 0 0 0 0 0 +syscon termios CLOCAL 0x0800 0x8000 0x8000 0x8000 0x8000 0 # +syscon termios CMSPAR 0x40000000 0 0 0 0 0 +syscon termios BUSY 4 0 0 0 0 0 +syscon termios CANBSIZ 255 0 0 0 0 0 +syscon termios CBAUD 0x100f 0 0 0 0 0 +syscon termios CBAUDEX 0x1000 0 0 0 0 0 +syscon termios CBRK 0 255 255 255 255 0 # +syscon termios CEOL 0 255 255 255 255 0 # +syscon termios EXTA 14 0x4b00 0x4b00 0x4b00 0x4b00 0 # bsd consensus +syscon termios EXTB 15 0x9600 0x9600 0x9600 0x9600 0 # bsd consensus +syscon termios ERA 0x02002c 45 45 0 0 0 +syscon termios EMPTY 0 0 0 0 0 0 # consensus +syscon termios TCFLSH 0x540b 0 0 0 0 0 +syscon termios TCIFLUSH 0 1 1 1 1 0 # bsd consensus +syscon termios TCIOFF 2 3 3 3 3 0 # bsd consensus +syscon termios TCIOFLUSH 2 3 3 3 3 0 # bsd consensus +syscon termios TCION 3 4 4 4 4 0 # bsd consensus +syscon termios TCOFLUSH 1 2 2 2 2 0 # bsd consensus +syscon termios TCOOFF 0 1 1 1 1 0 # bsd consensus +syscon termios TCOON 1 2 2 2 2 0 # bsd consensus + +# Pseudoteletypewriter Control +# +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary +syscon pty TIOCPKT 0x5420 0x80047470 0x80047470 0x80047470 0x80047470 -1 # boop +syscon pty TIOCPKT_DATA 0 0 0 0 0 0 # consensus +syscon pty TIOCPKT_FLUSHREAD 1 1 1 1 1 1 # unix consensus +syscon pty TIOCPKT_FLUSHWRITE 2 2 2 2 2 2 # unix consensus +syscon pty TIOCPKT_STOP 4 4 4 4 4 4 # unix consensus +syscon pty TIOCPKT_START 8 8 8 8 8 8 # unix consensus +syscon pty TIOCPKT_NOSTOP 16 16 16 16 16 16 # unix consensus +syscon pty TIOCPKT_DOSTOP 32 32 32 32 32 32 # unix consensus +syscon pty TIOCPKT_IOCTL 64 64 64 64 64 64 # unix consensus +syscon pty TIOCSPTLCK 0x40045431 0 0 0 0 -1 # boop +syscon pty PTMGET 0 0 0 0x40287401 0x40287401 -1 # for /dev/ptm + +# Modem Control +# +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary +syscon modem TIOCMGET 0x5415 0x4004746a 0x4004746a 0x4004746a 0x4004746a -1 # get status of modem bits; ioctl(fd, TIOCMGET, int *argp) +syscon modem TIOCMSET 0x5418 0x8004746d 0x8004746d 0x8004746d 0x8004746d -1 # set status of modem bits; ioctl(fd, TIOCMSET, const int *argp) +syscon modem TIOCMBIC 0x5417 0x8004746b 0x8004746b 0x8004746b 0x8004746b -1 # clear indicated modem bits; ioctl(fd, TIOCMBIC, int *argp) +syscon modem TIOCMBIS 0x5416 0x8004746c 0x8004746c 0x8004746c 0x8004746c -1 # set indicated modem bits; ioctl(fd, TIOCMBIS, int *argp) +syscon modem TIOCM_LE 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 # consensus +syscon modem TIOCM_DTR 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000010 # consensus +syscon modem TIOCM_RTS 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000000100 # consensus +syscon modem TIOCM_ST 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 # consensus +syscon modem TIOCM_SR 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000010000 # consensus +syscon modem TIOCM_CTS 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000000000100000 # consensus +syscon modem TIOCM_CAR 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 # consensus +syscon modem TIOCM_CD 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 # boop +syscon modem TIOCM_RI 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 # boop +syscon modem TIOCM_RNG 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 # boop +syscon modem TIOCM_DSR 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 # consensus +syscon modem TIOCM_DCD 0 0 0x40 0 0 -1 # wut +syscon modem TIOCMODG 0 0x40047403 0 0x4004746a 0x4004746a -1 # wut +syscon modem TIOCMODS 0 0x80047404 0 0x8004746d 0x8004746d -1 # wut +syscon modem TIOCMSDTRWAIT 0 0x8004745b 0x8004745b 0 0 -1 # wut syscon iff IFF_BROADCAST 2 2 2 2 2 2 # consensus syscon iff IFF_LOOPBACK 8 8 8 8 8 4 # unix consensus @@ -1610,97 +1512,6 @@ syscon iff IFF_MASTER 0x0400 0 0 0 0 0 syscon iff IFF_PORTSEL 0x2000 0 0 0 0 0 syscon iff IFF_SLAVE 0x0800 0 0 0 0 0 -syscon nd ND_RA_FLAG_MANAGED 0x80 0x80 0x80 0x80 0x80 0x80 # consensus -syscon nd ND_RA_FLAG_OTHER 0x40 0x40 0x40 0x40 0x40 0x40 # consensus -syscon nd ND_NA_FLAG_OVERRIDE 0x20 0x20 0x20 0x20 0x20 0x20000000 # unix consensus -syscon nd ND_NA_FLAG_ROUTER 0x80 0x80 0x80 0x80 0x80 0x80000000 # unix consensus -syscon nd ND_NA_FLAG_SOLICITED 0x40 0x40 0x40 0x40 0x40 0x40000000 # unix consensus -syscon nd ND_NEIGHBOR_ADVERT 136 136 136 136 136 0 # unix consensus -syscon nd ND_NEIGHBOR_SOLICIT 135 135 135 135 135 0 # unix consensus -syscon nd ND_REDIRECT 137 137 137 137 137 0 # unix consensus -syscon nd ND_ROUTER_ADVERT 134 134 134 134 134 0 # unix consensus -syscon nd ND_ROUTER_SOLICIT 133 133 133 133 133 0 # unix consensus -syscon nd ND_RA_FLAG_HOME_AGENT 0x20 0 0 0 0 0x20 # bsd consensus - -syscon misc TCFLSH 0x540b 0 0 0 0 0 -syscon misc TCIFLUSH 0 1 1 1 1 0 # bsd consensus -syscon misc TCIOFF 2 3 3 3 3 0 # bsd consensus -syscon misc TCIOFLUSH 2 3 3 3 3 0 # bsd consensus -syscon misc TCION 3 4 4 4 4 0 # bsd consensus -syscon misc TCOFLUSH 1 2 2 2 2 0 # bsd consensus -syscon misc TCOOFF 0 1 1 1 1 0 # bsd consensus -syscon misc TCOON 1 2 2 2 2 0 # bsd consensus - -syscon misc TYPE_DISK 0 0 0 0 0 0 # consensus -syscon misc TYPE_A 1 1 1 1 1 0 # unix consensus -syscon misc TYPE_E 2 2 2 2 2 0 # unix consensus -syscon misc TYPE_I 3 3 3 3 3 0 # unix consensus -syscon misc TYPE_L 4 4 4 4 4 0 # unix consensus -syscon misc TYPE_ENCLOSURE 13 0 0 0 0 0 -syscon misc TYPE_MEDIUM_CHANGER 8 0 0 0 0 0 -syscon misc TYPE_MOD 7 0 0 0 0 0 -syscon misc TYPE_NO_LUN 127 0 0 0 0 0 -syscon misc TYPE_PROCESSOR 3 0 0 0 0 0 -syscon misc TYPE_ROM 5 0 0 0 0 0 -syscon misc TYPE_SCANNER 6 0 0 0 0 0 -syscon misc TYPE_TAPE 1 0 0 0 0 0 -syscon misc TYPE_WORM 4 0 0 0 0 0 - -syscon misc _POSIX2_BC_BASE_MAX 99 99 99 99 99 0 # unix consensus -syscon misc _POSIX2_BC_DIM_MAX 0x0800 0x0800 0x0800 0x0800 0x0800 0 # unix consensus -syscon misc _POSIX2_BC_SCALE_MAX 99 99 99 99 99 0 # unix consensus -syscon misc _POSIX2_BC_STRING_MAX 0x03e8 0x03e8 0x03e8 0x03e8 0x03e8 0 # unix consensus -syscon misc _POSIX2_CHARCLASS_NAME_MAX 14 14 14 14 14 0 # unix consensus -syscon misc _POSIX2_COLL_WEIGHTS_MAX 2 2 2 2 2 0 # unix consensus -syscon misc _POSIX2_EXPR_NEST_MAX 0x20 0x20 0x20 0x20 0x20 0 # unix consensus -syscon misc _POSIX2_LINE_MAX 0x0800 0x0800 0x0800 0x0800 0x0800 0 # unix consensus -syscon misc _POSIX2_RE_DUP_MAX 255 255 255 255 255 0 # unix consensus -syscon misc _POSIX2_C_BIND 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus -syscon misc _POSIX2_VERSION 0x031069 0x030db0 0x030a2c 0x031069 0x031069 0 - -syscon misc PTHREAD_MUTEX_STALLED 0 0 0 0 0 0 # consensus -syscon misc PTHREAD_PRIO_NONE 0 0 0 0 0 0 # consensus -syscon misc PTHREAD_PRIO_INHERIT 0 1 1 1 1 0 # bsd consensus -syscon misc PTHREAD_PRIO_PROTECT 0 2 2 2 2 0 # bsd consensus -syscon misc PTHREAD_DESTRUCTOR_ITERATIONS 4 4 4 4 4 0 # unix consensus -syscon misc PTHREAD_PROCESS_SHARED 1 1 1 1 1 0 # unix consensus -syscon misc PTHREAD_CREATE_DETACHED 1 2 1 1 1 0 -syscon misc PTHREAD_KEYS_MAX 0x0400 0x0200 0x0100 0x0100 0x0100 0 -syscon misc PTHREAD_STACK_MIN 0x4000 0x2000 0x0800 0x1000 0x1000 0 -syscon misc PTHREAD_BARRIER_SERIAL_THREAD -1 0 -1 -1 -1 0 -syscon misc PTHREAD_CANCEL_ASYNCHRONOUS 1 0 2 2 2 0 -syscon misc PTHREAD_CANCEL_DISABLE 1 0 1 1 1 0 -syscon misc PTHREAD_INHERIT_SCHED 0 1 4 4 4 0 -syscon misc PTHREAD_SCOPE_SYSTEM 0 1 2 2 2 0 -syscon misc PTHREAD_EXPLICIT_SCHED 1 2 0 0 0 0 -syscon misc PTHREAD_MUTEX_DEFAULT 0 0 1 4 4 0 -syscon misc PTHREAD_MUTEX_ERRORCHECK 0 1 0 1 1 0 -syscon misc PTHREAD_MUTEX_RECURSIVE 0 2 0 2 2 0 -syscon misc PTHREAD_SCOPE_PROCESS 1 2 0 0 0 0 -syscon misc PTHREAD_CANCEL_DEFERRED 0 2 0 0 0 0 -syscon misc PTHREAD_CANCEL_ENABLE 0 1 0 0 0 0 -syscon misc PTHREAD_CREATE_JOINABLE 0 1 0 0 0 0 -syscon misc PTHREAD_MUTEX_NORMAL 0 0 0 3 3 0 -syscon misc PTHREAD_MUTEX_ROBUST 0 0 1 0 0 0 -syscon misc PTHREAD_PROCESS_PRIVATE 0 2 0 0 0 0 - -syscon misc N_TTY 0 0 0 0 0 0 # consensus -syscon misc N_6PACK 7 0 0 0 0 0 -syscon misc N_AX25 5 0 0 0 0 0 -syscon misc N_HCI 15 0 0 0 0 0 -syscon misc N_HDLC 13 0 0 0 0 0 -syscon misc N_IRDA 11 0 0 0 0 0 -syscon misc N_MASC 8 0 0 0 0 0 -syscon misc N_MOUSE 2 0 0 0 0 0 -syscon misc N_PPP 3 0 0 0 0 0 -syscon misc N_PROFIBUS_FDL 10 0 0 0 0 0 -syscon misc N_R3964 9 0 0 0 0 0 -syscon misc N_SLIP 1 0 0 0 0 0 -syscon misc N_SMSBLOCK 12 0 0 0 0 0 -syscon misc N_STRIP 4 0 0 0 0 0 -syscon misc N_SYNC_PPP 14 0 0 0 0 0 -syscon misc N_X25 6 0 0 0 0 0 - syscon sock SOCK_STREAM 1 1 1 1 1 1 # consensus syscon sock SOCK_DGRAM 2 2 2 2 2 2 # consensus syscon sock SOCK_RAW 3 3 3 3 3 3 # consensus @@ -1723,32 +1534,6 @@ syscon prsnlty ADDR_NO_RANDOMIZE 0x0040000 0 0 0 0 0 # linux only syscon prsnlty SHORT_INODE 0x1000000 0 0 0 0 0 # linux only syscon prsnlty UNAME26 0x0020000 0 0 0 0 0 # linux only -syscon misc INADDR_ANY 0 0 0 0 0 0 # consensus -syscon misc INADDR_BROADCAST 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff # consensus -syscon misc INADDR_NONE 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff # consensus -syscon misc INADDR_ALLHOSTS_GROUP 0xe0000001 0xe0000001 0xe0000001 0xe0000001 0xe0000001 0 # unix consensus -syscon misc INADDR_LOOPBACK 0x7f000001 0x7f000001 0x7f000001 0x7f000001 0x7f000001 0x7f000001 # consensus -syscon misc INADDR_MAX_LOCAL_GROUP 0xe00000ff 0xe00000ff 0xe00000ff 0xe00000ff 0xe00000ff 0 # unix consensus -syscon misc INADDR_UNSPEC_GROUP 0xe0000000 0xe0000000 0xe0000000 0xe0000000 0xe0000000 0 # unix consensus -syscon misc INADDR_ALLRTRS_GROUP 0xe0000002 0xe0000002 0xe0000002 0 0 0 - -syscon misc BLKTYPE 52 52 52 52 52 0 # unix consensus -syscon misc BLKBSZGET 0x80081270 0 0 0 0 0 -syscon misc BLKBSZSET 0x40081271 0 0 0 0 0 -syscon misc BLKFLSBUF 0x1261 0 0 0 0 0 -syscon misc BLKFRAGET 0x1265 0 0 0 0 0 -syscon misc BLKFRASET 0x1264 0 0 0 0 0 -syscon misc BLKGETSIZE 0x1260 0 0 0 0 0 -syscon misc BLKGETSIZE64 0x80081272 0 0 0 0 0 -syscon misc BLKRAGET 0x1263 0 0 0 0 0 -syscon misc BLKRASET 0x1262 0 0 0 0 0 -syscon misc BLKROGET 0x125e 0 0 0 0 0 -syscon misc BLKROSET 0x125d 0 0 0 0 0 -syscon misc BLKRRPART 0x125f 0 0 0 0 0 -syscon misc BLKSECTGET 0x1267 0 0 0 0 0 -syscon misc BLKSECTSET 0x1266 0 0 0 0 0 -syscon misc BLKSSZGET 0x1268 0 0 0 0 0 - syscon misc TH_FIN 1 1 1 1 1 1 # consensus syscon misc TH_SYN 2 2 2 2 2 2 # consensus syscon misc TH_RST 4 4 4 4 4 4 # consensus @@ -1788,108 +1573,6 @@ syscon misc TCPOPT_SACK_PERMITTED 4 4 4 4 4 0 # unix consensus syscon misc TCPOPT_TIMESTAMP 8 8 8 8 8 0 # unix consensus syscon misc TCPOPT_WINDOW 3 3 3 3 3 0 # unix consensus -syscon misc ETH_P_CUST 0x6006 0 0 0 0 0 -syscon misc ETH_P_DDCMP 6 0 0 0 0 0 -syscon misc ETH_P_DEC 0x6000 0 0 0 0 0 -syscon misc ETH_P_DIAG 0x6005 0 0 0 0 0 -syscon misc ETH_P_DNA_DL 0x6001 0 0 0 0 0 -syscon misc ETH_P_DNA_RC 0x6002 0 0 0 0 0 -syscon misc ETH_P_DNA_RT 0x6003 0 0 0 0 0 -syscon misc ETH_P_IEEE802154 246 0 0 0 0 0 -syscon misc ETH_P_LAT 0x6004 0 0 0 0 0 -syscon misc ETH_P_LOCALTALK 9 0 0 0 0 0 -syscon misc ETH_P_PPP_MP 8 0 0 0 0 0 -syscon misc ETH_P_RARP 0x8035 0 0 0 0 0 -syscon misc ETH_P_SCA 0x6007 0 0 0 0 0 -syscon misc ETH_P_WAN_PPP 7 0 0 0 0 0 - -syscon misc ST_NOSUID 2 2 2 2 2 0 # unix consensus -syscon misc ST_RDONLY 1 1 1 1 1 0 # unix consensus -syscon misc ST_APPEND 0x0100 0 0 0 0 0 -syscon misc ST_IMMUTABLE 0x0200 0 0 0 0 0 -syscon misc ST_MANDLOCK 0x40 0 0 0 0 0 -syscon misc ST_NOATIME 0x0400 0 0 0 0 0 -syscon misc ST_NODEV 4 0 0 0 0 0 -syscon misc ST_NODIRATIME 0x0800 0 0 0 0 0 -syscon misc ST_NOEXEC 8 0 0 0 0 0 -syscon misc ST_RELATIME 0x1000 0 0 0 0 0 -syscon misc ST_SYNCHRONOUS 0x10 0 0 0 0 0 -syscon misc ST_WRITE 0x80 0 0 0 0 0 - -syscon misc SCSI_IOCTL_BENCHMARK_COMMAND 3 0 0 0 0 0 -syscon misc SCSI_IOCTL_DOORLOCK 0x5380 0 0 0 0 0 -syscon misc SCSI_IOCTL_DOORUNLOCK 0x5381 0 0 0 0 0 -syscon misc SCSI_IOCTL_GET_BUS_NUMBER 0x5386 0 0 0 0 0 -syscon misc SCSI_IOCTL_GET_IDLUN 0x5382 0 0 0 0 0 -syscon misc SCSI_IOCTL_PROBE_HOST 0x5385 0 0 0 0 0 -syscon misc SCSI_IOCTL_SEND_COMMAND 1 0 0 0 0 0 -syscon misc SCSI_IOCTL_START_UNIT 5 0 0 0 0 0 -syscon misc SCSI_IOCTL_STOP_UNIT 6 0 0 0 0 0 -syscon misc SCSI_IOCTL_SYNC 4 0 0 0 0 0 -syscon misc SCSI_IOCTL_TAGGED_DISABLE 0x5384 0 0 0 0 0 -syscon misc SCSI_IOCTL_TAGGED_ENABLE 0x5383 0 0 0 0 0 -syscon misc SCSI_IOCTL_TEST_UNIT_READY 2 0 0 0 0 0 -syscon misc BUS_DEVICE_RESET 12 0 0 0 0 0 # SIGBUS; - -syscon misc READ_10 40 0 0 0 0 0 -syscon misc READ_12 168 0 0 0 0 0 -syscon misc READ_6 8 0 0 0 0 0 -syscon misc READ_BLOCK_LIMITS 5 0 0 0 0 0 -syscon misc READ_BUFFER 60 0 0 0 0 0 -syscon misc READ_CAPACITY 37 0 0 0 0 0 -syscon misc READ_DEFECT_DATA 55 0 0 0 0 0 -syscon misc READ_ELEMENT_STATUS 184 0 0 0 0 0 -syscon misc READ_LONG 62 0 0 0 0 0 -syscon misc READ_POSITION 52 0 0 0 0 0 -syscon misc READ_REVERSE 15 0 0 0 0 0 -syscon misc READ_TOC 67 0 0 0 0 0 - -# getpriority() / setpriority() magnums (a.k.a. nice) -# -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary -syscon prio PRIO_PROCESS 0 0 0 0 0 0 # consensus / poly nt -syscon prio PRIO_PGRP 1 1 1 1 1 1 # unix consensus / poly nt -syscon prio PRIO_USER 2 2 2 2 2 2 # unix consensus / poly nt -syscon prio PRIO_MIN -20 -20 -20 -20 -20 -20 # unix consensus / poly nt -syscon prio PRIO_MAX 20 20 20 20 20 20 # unix consensus / poly nt -syscon prio NZERO 20 20 20 20 20 20 # unix consensus / polyfilled nt - -# getaddrinfo() flags -# -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary -syscon gai AI_PASSIVE 1 1 1 1 1 1 # consensus -syscon gai AI_CANONNAME 2 2 2 2 2 2 # consensus -syscon gai AI_NUMERICHOST 4 4 4 4 4 4 # consensus -syscon gai AI_ADDRCONFIG 0x20 0x0400 0x0400 0x40 0x40 0x0400 -syscon gai AI_NUMERICSERV 0x0400 0x1000 8 0x10 0x10 8 -syscon gai AI_ALL 0x10 0x0100 0x0100 0 0 0x0100 -syscon gai AI_V4MAPPED 8 0x0800 0x0800 0 0 0x0800 - -syscon misc BLK_BYTECOUNT 2 2 2 2 2 0 # unix consensus -syscon misc BLK_EOF 0x40 0x40 0x40 0x40 0x40 0 # unix consensus -syscon misc BLK_EOR 0x80 0x80 0x80 0x80 0x80 0 # unix consensus -syscon misc BLK_ERRORS 0x20 0x20 0x20 0x20 0x20 0 # unix consensus -syscon misc BLK_RESTART 0x10 0x10 0x10 0x10 0x10 0 # unix consensus - -syscon misc MODE_B 2 2 2 2 2 0 # unix consensus -syscon misc MODE_C 3 3 3 3 3 0 # unix consensus -syscon misc MODE_S 1 1 1 1 1 0 # unix consensus -syscon misc MODE_SELECT 21 0 0 0 0 0 -syscon misc MODE_SELECT_10 85 0 0 0 0 0 -syscon misc MODE_SENSE 26 0 0 0 0 0 -syscon misc MODE_SENSE_10 90 0 0 0 0 0 - -syscon misc WRITE_10 42 0 0 0 0 0 -syscon misc WRITE_12 170 0 0 0 0 0 -syscon misc WRITE_6 10 0 0 0 0 0 -syscon misc WRITE_BUFFER 59 0 0 0 0 0 -syscon misc WRITE_FILEMARKS 0x10 0 0 0 0 0 -syscon misc WRITE_LONG 63 0 0 0 0 0 -syscon misc WRITE_LONG_2 234 0 0 0 0 0 -syscon misc WRITE_SAME 65 0 0 0 0 0 -syscon misc WRITE_VERIFY 46 0 0 0 0 0 -syscon misc WRITE_VERIFY_12 174 0 0 0 0 0 - syscon lock LOCK_UNLOCK_CACHE 54 0 0 0 0 0 # wut syscon misc ARPHRD_ETHER 1 1 1 1 1 0 # unix consensus @@ -2098,11 +1781,6 @@ syscon misc MCAST_INCLUDE 1 1 1 0 0 0 syscon misc MCAST_EXCLUDE 0 2 2 0 0 0 syscon misc MCAST_MSFILTER 48 0 0 0 0 0 -syscon misc SIG_BLOCK 0 1 1 1 1 0 # bsd consensus; faked nt -syscon misc SIG_UNBLOCK 1 2 2 2 2 1 # bsd consensus; faked nt -syscon misc SIG_SETMASK 2 3 3 3 3 2 # bsd consensus; faked nt -syscon misc SIG_ATOMIC_MIN -2147483648 -2147483648 -9223372036854775808 -2147483648 -2147483648 0 - syscon misc AREGTYPE 0 0 0 0 0 0 # consensus syscon misc B0 0 0 0 0 0 0 # consensus syscon misc CS5 0 0 0 0 0 0 # consensus @@ -2174,7 +1852,6 @@ syscon misc UDP_NO_CHECK6_RX 102 0 0 0 0 0 syscon misc UDP_NO_CHECK6_TX 101 0 0 0 0 0 syscon misc ACK 4 4 4 4 4 0 # unix consensus -syscon misc BIG_ENDIAN 0x10e1 0x10e1 0x10e1 0x10e1 0x10e1 0 # unix consensus syscon misc CDISCARD 15 15 15 15 15 0 # unix consensus syscon misc CDSUSP 25 25 25 25 25 0 # unix consensus syscon misc CEOF 4 4 4 4 4 0 # unix consensus @@ -2212,7 +1889,7 @@ syscon misc EXPR_NEST_MAX 0x20 0x20 0x20 0x20 0x20 0 # unix conse # linux fallocate() flags # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon misc FALLOC_FL_KEEP_SIZE 0x01 -1 -1 -1 -1 -1 # bsd consensus syscon misc FALLOC_FL_PUNCH_HOLE 0x02 -1 -1 -1 -1 -1 # bsd consensus syscon misc FALLOC_FL_NO_HIDE_STALE 0x04 -1 -1 -1 -1 -1 # bsd consensus @@ -2221,513 +1898,9 @@ syscon misc FALLOC_FL_ZERO_RANGE 0x10 -1 -1 -1 -1 0x000980C8 # bsd syscon misc FALLOC_FL_INSERT_RANGE 0x20 -1 -1 -1 -1 -1 # bsd consensus syscon misc FALLOC_FL_UNSHARE_RANGE 0x40 -1 -1 -1 -1 -1 # bsd consensus -syscon misc FIFOTYPE 54 54 54 54 54 0 # unix consensus -syscon misc GRPQUOTA 1 1 1 1 1 0 # unix consensus -syscon misc IF_NAMESIZE 0x10 0x10 0x10 0x10 0x10 0 # unix consensus -syscon misc INTERMEDIATE_C_GOOD 10 0 0 0 0 0 -syscon misc INTERMEDIATE_GOOD 8 0 0 0 0 0 - -syscon misc IOV_MAX 0x0400 0x0400 0x0400 0x0400 0x0400 16 # unix consensus & MSG_MAXIOVLEN -syscon misc LINE_MAX 0x0800 0x0800 0x0800 0x0800 0x0800 0 # unix consensus -syscon misc LINKED_CMD_COMPLETE 10 0 0 0 0 0 -syscon misc LINKED_FLG_CMD_COMPLETE 11 0 0 0 0 0 - -syscon misc LITTLE_ENDIAN 0x04d2 0x04d2 0x04d2 0x04d2 0x04d2 0 # unix consensus -syscon misc LNKTYPE 49 49 49 49 49 0 # unix consensus -syscon misc MAXNAMLEN 255 255 255 255 255 0 # unix consensus -syscon misc MAXQUOTAS 2 2 2 2 2 0 # unix consensus -syscon misc MEDIUM_ERROR 3 0 0 0 0 0 -syscon misc MEDIUM_SCAN 56 0 0 0 0 0 - -syscon misc NBBY 8 8 8 8 8 0 # unix consensus -syscon misc NR_DQHASH 43 0 0 0 0 0 -syscon misc NR_DQUOTS 0x0100 0 0 0 0 0 - -syscon misc PERSISTENT_RESERVE_IN 94 0 0 0 0 0 -syscon misc PERSISTENT_RESERVE_OUT 95 0 0 0 0 0 - -syscon misc PRELIM 1 1 1 1 1 0 # unix consensus -syscon misc REGTYPE 48 48 48 48 48 0 # unix consensus -syscon misc RES_PRF_CLASS 4 4 4 4 4 0 # unix consensus -syscon misc RHF_GUARANTEE_START_INIT 0x80 0 0 0 0 0 -syscon misc RHF_NO_LIBRARY_REPLACEMENT 4 0 0 0 0 0 - -syscon misc RRQ 1 1 1 1 1 0 # unix consensus -syscon misc RTF_NOFORWARD 0x1000 0 0 0 0 0 -syscon misc RTF_NOPMTUDISC 0x4000 0 0 0 0 0 - -syscon misc SARMAG 8 8 8 8 8 0 # unix consensus -syscon misc SEGSIZE 0x0200 0x0200 0x0200 0x0200 0x0200 0 # unix consensus -syscon misc SEND_DIAGNOSTIC 29 0 0 0 0 0 -syscon misc SEND_VOLUME_TAG 182 0 0 0 0 0 - -syscon misc SET_LIMITS 51 0 0 0 0 0 -syscon misc SET_WINDOW 36 0 0 0 0 0 - -syscon misc SFD_CLOEXEC 0x080000 0 0 0 0 0 -syscon misc SFD_NONBLOCK 0x0800 0 0 0 0 0 - -syscon misc SOMAXCONN 0x80 0x80 0x80 0x80 0x80 0x7fffffff # unix consensus -syscon misc SUBCMDMASK 255 255 255 255 255 0 # unix consensus -syscon misc SUBCMDSHIFT 8 8 8 8 8 0 # unix consensus -syscon misc SYMTYPE 50 50 50 50 50 0 # unix consensus -syscon misc TGEXEC 8 8 8 8 8 0 # unix consensus -syscon misc TGREAD 0x20 0x20 0x20 0x20 0x20 0 # unix consensus -syscon misc TGWRITE 0x10 0x10 0x10 0x10 0x10 0 # unix consensus -syscon misc TMAGLEN 6 6 6 6 6 0 # unix consensus -syscon misc TOEXEC 1 1 1 1 1 0 # unix consensus -syscon misc TOREAD 4 4 4 4 4 0 # unix consensus -syscon misc TOWRITE 2 2 2 2 2 0 # unix consensus -syscon misc TRANSIENT 4 4 4 4 4 0 # unix consensus -syscon misc TRY_AGAIN 2 2 2 2 2 0x2afa # unix consensus -syscon misc TSGID 0x0400 0x0400 0x0400 0x0400 0x0400 0 # unix consensus -syscon misc TSUID 0x0800 0x0800 0x0800 0x0800 0x0800 0 # unix consensus -syscon misc TSVTX 0x0200 0x0200 0x0200 0x0200 0x0200 0 # unix consensus -syscon misc TUEXEC 0x40 0x40 0x40 0x40 0x40 0 # unix consensus -syscon misc TUREAD 0x0100 0x0100 0x0100 0x0100 0x0100 0 # unix consensus -syscon misc TUWRITE 0x80 0x80 0x80 0x80 0x80 0 # unix consensus -syscon misc TVERSLEN 2 2 2 2 2 0 # unix consensus -syscon misc WORD_BIT 0x20 0x20 0x20 0x20 0x20 0 # unix consensus -syscon misc WRQ 2 2 2 2 2 0 # unix consensus -syscon misc SIGEV_THREAD 2 3 2 0 2 0 -syscon misc SIGEV_SIGNAL 0 1 1 0 1 0 -syscon misc SIGEV_NONE 1 0 0 0 0 0 - -syscon misc BC_BASE_MAX 99 99 99 0x7fffffff 0x7fffffff 0 -syscon misc BC_DIM_MAX 0x0800 0x0800 0x0800 0xffff 0xffff 0 -syscon misc BC_SCALE_MAX 99 99 99 0x7fffffff 0x7fffffff 0 -syscon misc BC_STRING_MAX 0x03e8 0x03e8 0x03e8 0x7fffffff 0x7fffffff 0 - -syscon misc ABORTED_COMMAND 11 0 0 0 0 0 -syscon misc ACORE 0 8 8 8 8 0 # bsd consensus -syscon misc AFORK 0 1 1 1 1 0 # bsd consensus -syscon misc AIO_ALLDONE 2 1 3 0 0 0 -syscon misc AIO_NOTCANCELED 1 4 2 0 0 0 -syscon misc AIO_CANCELED 0 2 1 0 0 0 - -syscon misc ALLOW_MEDIUM_REMOVAL 30 0 0 0 0 0 -syscon misc ASU 0 2 2 2 2 0 # bsd consensus -syscon misc ATF_NETMASK 0x20 0 0 0 0 0 -syscon misc AXSIG 0 0x10 0x10 0x10 0x10 0 # bsd consensus -syscon misc B1000000 0x1008 0 0 0 0 0 -syscon misc B110 3 110 110 110 110 0 # bsd consensus -syscon misc B115200 0x1002 0x01c200 0x01c200 0x01c200 0x01c200 0 # bsd consensus -syscon misc B1152000 0x1009 0 0 0 0 0 -syscon misc B1200 9 0x04b0 0x04b0 0x04b0 0x04b0 0 # bsd consensus -syscon misc B134 4 134 134 134 134 0 # bsd consensus -syscon misc B150 5 150 150 150 150 0 # bsd consensus -syscon misc B1500000 0x100a 0 0 0 0 0 -syscon misc B1800 10 0x0708 0x0708 0x0708 0x0708 0 # bsd consensus -syscon misc B19200 14 0x4b00 0x4b00 0x4b00 0x4b00 0 # bsd consensus -syscon misc B200 6 200 200 200 200 0 # bsd consensus -syscon misc B2000000 0x100b 0 0 0 0 0 -syscon misc B230400 0x1003 0x038400 0x038400 0x038400 0x038400 0 # bsd consensus -syscon misc B2400 11 0x0960 0x0960 0x0960 0x0960 0 # bsd consensus -syscon misc B2500000 0x100c 0 0 0 0 0 -syscon misc B300 7 300 300 300 300 0 # bsd consensus -syscon misc B3000000 0x100d 0 0 0 0 0 -syscon misc B3500000 0x100e 0 0 0 0 0 -syscon misc B38400 15 0x9600 0x9600 0x9600 0x9600 0 # bsd consensus -syscon misc B4000000 0x100f 0 0 0 0 0 -syscon misc B4800 12 0x12c0 0x12c0 0x12c0 0x12c0 0 # bsd consensus -syscon misc B50 1 50 50 50 50 0 # bsd consensus -syscon misc B500000 0x1005 0 0 0 0 0 -syscon misc B57600 0x1001 0xe100 0xe100 0xe100 0xe100 0 # bsd consensus -syscon misc B576000 0x1006 0 0 0 0 0 -syscon misc B600 8 600 600 600 600 0 # bsd consensus -syscon misc B75 2 75 75 75 75 0 # bsd consensus -syscon misc B9600 13 0x2580 0x2580 0x2580 0x2580 0 # bsd consensus -syscon misc BITSPERBYTE 8 0 0 0 0 0 -syscon misc BLANK_CHECK 8 0 0 0 0 0 -syscon misc CHANGE_DEFINITION 0x40 0 0 0 0 0 -syscon misc CHARBITS 8 0 0 0 0 0 -syscon misc CHECK_CONDITION 1 0 0 0 0 0 -syscon misc CONDITION_GOOD 2 0 0 0 0 0 -syscon misc CREAD 0x80 0x0800 0x0800 0x0800 0x0800 0 # bsd consensus -syscon misc CSTOPB 0x40 0x0400 0x0400 0x0400 0x0400 0 # bsd consensus -syscon misc DATA_PROTECT 7 0 0 0 0 0 -syscon misc DELAYTIMER_MAX 0x7fffffff 0 0 0 0 0 -syscon misc DMAXEXP 0x0400 0 0 0 0 0 -syscon misc DMINEXP -1021 0 0 0 0 0 -syscon misc DOUBLEBITS 0x40 0 0 0 0 0 -syscon misc ERA_D_FMT 0x02002e 46 46 0 0 0 -syscon misc ERA_D_T_FMT 0x020030 47 47 0 0 0 -syscon misc ERA_T_FMT 0x020031 48 48 0 0 0 - -# Teletypewriter Control, e.g. -# -# TCSETS → About 70,800 results (0.31 seconds) -# = TCSETNOW → About 47,700 results (0.31 seconds) -# ≈ TCSETA → About 12,600 results (0.32 seconds) -# = TIOCSETA → About 3,110 results (0.41 seconds) -# -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary -syscon termios TCGETS 0x5401 0x40487413 0x402c7413 0x402c7413 0x402c7413 0 # Gets console settings; tcgetattr(tty, argp) → ioctl(tty, TCGETS, struct termios *argp); polyfilled NT -syscon compat TIOCGETA 0x5401 0x40487413 0x402c7413 0x402c7413 0x402c7413 0 # Gets console settings; = tcgetattr(tty, struct termios *argp) -#syscon compat TCGETA 0x5405 0 0 0 0 0 # Gets console settings; ≈ ioctl(fd, TCGETA, struct termio *argp) -syscon termios TCSANOW 0 0 0 0 0 0 # Sets console settings; tcsetattr(fd, TCSANOW, argp); polyfilled NT -syscon termios TCSETS 0x5402 0x80487414 0x802c7414 0x802c7414 0x802c7414 0x5402 # Sets console settings; = ioctl(tty, TCSETS, const struct termios *argp); polyfilled NT -syscon compat TIOCSETA 0x5402 0x80487414 0x802c7414 0x802c7414 0x802c7414 0x5402 # Sets console settings; = ioctl(tty, TIOCSETA, const struct termios *argp); polyfilled NT -#syscon compat TCSETA 0x5402 0x80487414 0x802c7414 0x802c7414 0x802c7414 0x5402 # Sets console settings; ≈ ioctl(tty, TCSETA, const struct termio *argp); polyfilled NT -syscon termios TCSADRAIN 1 1 1 1 1 1 # Drains output & sets console settings; tcsetawttr(fd, TCSADRAIN, argp); polyfilled NT -syscon termios TCSETSW 0x5403 0x80487415 0x802c7415 0x802c7415 0x802c7415 0x5403 # Drains output & sets console settings; = ioctl(tty, TCSETSW, const struct termios *argp); polyfilled NT -syscon compat TIOCSETAW 0x5403 0x80487415 0x802c7415 0x802c7415 0x802c7415 0x5403 # Drains output & sets console settings; = ioctl(tty, TIOCSETAW, const struct termios *argp); polyfilled NT -#syscon compat TCSETAW 0x5403 0x80487415 0x802c7415 0x802c7415 0x802c7415 0x5403 # Drains output & sets console settings; ≈ ioctl(tty, TCSETAW, const struct termio *argp); polyfilled NT -syscon termios TCSAFLUSH 2 2 2 2 2 2 # Drops input & drains output & sets console settings; tcsetafttr(fd, TCSAFLUSH, argp); polyfilled NT -syscon termios TCSETSF 0x5404 0x80487416 0x802c7416 0x802c7416 0x802c7416 0x5404 # Drops input & drains output & sets console settings; = ioctl(tty, TCSETSF, const struct termios *argp); polyfilled NT -syscon compat TIOCSETAF 0x5404 0x80487416 0x802c7416 0x802c7416 0x802c7416 0x5402 # Drops input & drains output & sets console settings; = ioctl(tty, TIOCSETAF, const struct termios *argp); polyfilled NT -#syscon compat TCSETAF 0x5404 0x80487416 0x802c7416 0x802c7416 0x802c7416 0x5402 # Drops input & drains output & sets console settings; ≈ ioctl(tty, TCSETAF, const struct termio *argp); polyfilled NT -syscon termios TIOCGWINSZ 0x5413 1074295912 1074295912 1074295912 1074295912 0x5413 # ioctl(tty, TIOCGWINSZ, struct winsize *argp); polyfilled NT -syscon termios TIOCSWINSZ 0x5414 0x80087467 0x80087467 0x80087467 0x80087467 0x5414 # ioctl(tty, TIOCSWINSZ, const struct winsize *argp) (faked NT) -syscon termios TIOCOUTQ 0x5411 0x40047473 0x40047473 0x40047473 0x40047473 0 # get # bytes queued in TTY's output buffer ioctl(tty, TIOCSWINSZ, const struct winsize *argp) -syscon termios TIOCCBRK 0x5428 0x2000747a 0x2000747a 0x2000747a 0x2000747a 0 # boop -syscon termios TIOCCONS 0x541d 0x80047462 0x80047462 0x80047462 0x80047462 0 # boop -syscon termios TIOCGETD 0x5424 0x4004741a 0x4004741a 0x4004741a 0x4004741a 0 # boop -syscon termios TIOCGPGRP 0x540f 0x40047477 0x40047477 0x40047477 0x40047477 0 # boop -syscon termios TIOCNOTTY 0x5422 0x20007471 0x20007471 0x20007471 0x20007471 0 # boop -syscon termios TIOCNXCL 0x540d 0x2000740e 0x2000740e 0x2000740e 0x2000740e 0 # boop -syscon termios TIOCSBRK 0x5427 0x2000747b 0x2000747b 0x2000747b 0x2000747b 0 # boop -syscon termios TIOCSCTTY 0x540e 0x20007461 0x20007461 0x20007461 0x20007461 0 # boop -syscon termios TIOCSETD 0x5423 0x8004741b 0x8004741b 0x8004741b 0x8004741b 0 # boop -syscon termios TIOCSIG 0x40045436 0x2000745f 0x2004745f 0x8004745f 0x8004745f 0 # boop -syscon termios TIOCSPGRP 0x5410 0x80047476 0x80047476 0x80047476 0x80047476 0 # boop -syscon termios TIOCSTI 0x5412 0x80017472 0x80017472 0 0 0 # boop -syscon termios TIOCGPTN 0x80045430 0 0x4004740f 0 0 0 # boop -syscon termios TIOCGSID 0x5429 0 0x40047463 0x40047463 0x40047463 0 # boop -syscon termios TABLDISC 0 0x3 0 0x3 0x3 0 # boop -syscon termios SLIPDISC 0 0x4 0x4 0x4 0x4 0 # boop -syscon termios PPPDISC 0 0x5 0x5 0x5 0x5 0 # boop -syscon termios TIOCDRAIN 0 0x2000745e 0x2000745e 0x2000745e 0x2000745e 0 # boop -syscon termios TIOCSTAT 0 0x20007465 0x20007465 0x20007465 0x20007465 0 # boop -syscon termios TIOCSTART 0 0x2000746e 0x2000746e 0x2000746e 0x2000746e 0 # boop -syscon termios TIOCCDTR 0 0x20007478 0x20007478 0x20007478 0x20007478 0 # boop -syscon termios TIOCSDTR 0 0x20007479 0x20007479 0x20007479 0x20007479 0 # boop -syscon termios TIOCFLUSH 0 0x80047410 0x80047410 0x80047410 0x80047410 0 # boop -syscon termios TIOCEXT 0 0x80047460 0x80047460 0x80047460 0x80047460 0 # boop -syscon termios TIOCGDRAINWAIT 0 0x40047456 0x40047456 0 0 0 # boop -syscon termios TIOCTIMESTAMP 0 0x40107459 0x40107459 0 0 0 # boop -syscon termios TIOCSDRAINWAIT 0 0x80047457 0x80047457 0 0 0 # boop -syscon termios TIOCREMOTE 0 0x80047469 0 0x80047469 0x80047469 0 # boop -syscon termios TTYDISC 0 0 0 0 0 0 # boop -syscon termios TIOCFLAG_SOFTCAR 0 0 0 0x1 0x1 0 # boop -syscon termios TIOCFLAG_PPS 0 0 0 0x10 0x10 0 # boop -syscon termios TIOCFLAG_CLOCAL 0 0 0 0x2 0x2 0 # boop -syscon termios TIOCCHKVERAUTH 0 0 0 0x2000741e 0x2000741e 0 # boop -syscon termios TIOCGFLAGS 0 0 0 0x4004745d 0x4004745d 0 # boop -syscon termios TIOCGTSTAMP 0 0 0 0x4010745b 0x4010745b 0 # boop -syscon termios STRIPDISC 0 0 0 0x6 0x6 0 # boop -syscon termios NMEADISC 0 0 0 0x7 0x7 0 # boop -syscon termios TIOCUCNTL_CBRK 0 0 0 0x7a 0x7a 0 # boop -syscon termios TIOCFLAG_MDMBUF 0 0 0 0x8 0x8 0 # boop -syscon termios TIOCSETVERAUTH 0 0 0 0x8004741c 0x8004741c 0 # boop -syscon termios TIOCSFLAGS 0 0 0 0x8004745c 0x8004745c 0 # boop -syscon termios TIOCSTSTAMP 0 0 0 0x8008745a 0x8008745a 0 # boop -syscon termios ENDRUNDISC 0 0 0 0x9 0x9 0 # boop -syscon termios TIOCPTMASTER 0 0 0x2000741c 0 0 0 # boop -syscon termios NETGRAPHDISC 0 0 0x6 0 0 0 # boop -syscon termios H4DISC 0 0 0x7 0 0 0 # boop - -syscon termios ISIG 0b0000000000000001 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000000000001 # termios.c_lflag|=ISIG makes Ctrl-C, Ctrl-\, etc. generate signals -syscon termios ICANON 0b0000000000000010 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000000000010 # termios.c_lflag&=~ICANON disables 1960's version of gnu readline (see also VMIN) -syscon termios XCASE 0b0000000000000100 0 0 16777216 16777216 0b0000000000000100 # termios.c_lflag -syscon termios ECHO 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 # termios.c_lflag&=~ECHO is for passwords and raw mode -syscon termios ECHOE 0b0000000000010000 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000010000 # termios.c_lflag -syscon termios ECHOK 0b0000000000100000 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000100000 # termios.c_lflag -syscon termios ECHONL 0b0000000001000000 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000001000000 # termios.c_lflag -syscon termios NOFLSH 0b0000000010000000 2147483648 2147483648 2147483648 2147483648 0b0000000010000000 # termios.c_lflag|=NOFLSH means don't flush on INT/QUIT/SUSP -syscon termios TOSTOP 0b0000000100000000 4194304 4194304 4194304 4194304 0b0000000100000000 # termios.c_lflag|=TOSTOP raises SIGTTOU to process group if background job tries to write to controlling terminal -syscon termios ECHOCTL 0b0000001000000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000001000000000 # termios.c_lflag|=ECHOCTL prints ^𝑥 codes for monotonic motion -syscon termios ECHOPRT 0b0000010000000000 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000010000000000 # termios.c_lflag|=ECHOPRT includes the parity bit -syscon termios ECHOKE 0b0000100000000000 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000100000000000 # termios.c_lflag -syscon termios FLUSHO 0b0001000000000000 8388608 8388608 8388608 8388608 0b0001000000000000 # termios.c_lflag -syscon termios PENDIN 0b0100000000000000 536870912 536870912 536870912 536870912 0b0100000000000000 # termios.c_lflag -syscon termios IEXTEN 0b1000000000000000 0b0000010000000000 0b0000010000000000 0b0000010000000000 0b0000010000000000 0b1000000000000000 # termios.c_lflag&=~IEXTEN disables platform input processing magic -syscon termios EXTPROC 65536 0b0000100000000000 0b0000100000000000 0b0000100000000000 0b0000100000000000 65536 # termios.c_lflag - -syscon termios IGNBRK 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 # termios.c_iflag it's complicated, uart only? UNIXCONSENSUS -syscon termios BRKINT 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000010 # termios.c_iflag it's complicated, uart only? UNIXCONSENSUS -syscon termios IGNPAR 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000000100 # termios.c_iflag|=IGNPAR ignores parity and framing errors; see PARMRK UNIXCONSENSUS -syscon termios PARMRK 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 # termios.c_iflag|=PARMRK passes-through parity bit UNIXCONSENSUS -syscon termios INPCK 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000010000 # termios.c_iflag|=INPCK enables parity checking UNIXCONSENSUS -syscon termios ISTRIP 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000000000100000 # termios.c_iflag|=ISTRIP automates read(1)&0x7f UNIXCONSENSUS -syscon termios INLCR 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 # termios.c_iflag|=INLCR maps \n → \r input UNIXCONSENSUS -syscon termios IGNCR 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 # termios.c_iflag|=IGNCR maps \r → ∅ input UNIXCONSENSUS -syscon termios ICRNL 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 # termios.c_iflag|=ICRNL maps \r → \n input UNIXCONSENSUS -syscon termios IUCLC 0b0000001000000000 0 0 0b0001000000000000 0b0001000000000000 0b0000001000000000 # termios.c_iflag|=IUCLC maps A-Z → a-z input -syscon termios IXON 0b0000010000000000 0b0000001000000000 0b0000001000000000 0b0000001000000000 0b0000001000000000 0b0000010000000000 # termios.c_iflag|=IXON enables flow rida -syscon termios IXANY 0b0000100000000000 0b0000100000000000 0b0000100000000000 0b0000100000000000 0b0000100000000000 0b0000100000000000 # termios.c_iflag|=IXANY tying will un-stuck teletype UNIXCONSENSUS -syscon termios IXOFF 0b0001000000000000 0b0000010000000000 0b0000010000000000 0b0000010000000000 0b0000010000000000 0b0001000000000000 # termios.c_iflag|=IXOFF disables annoying display freeze keys -syscon termios IMAXBEL 0b0010000000000000 0b0010000000000000 0b0010000000000000 0b0010000000000000 0b0010000000000000 0b0010000000000000 # termios.c_iflag|=IMAXBEL rings when queue full UNIXCONSENSUS -syscon termios IUTF8 0b0100000000000000 0b0100000000000000 0 0 0 0b0100000000000000 # termios.c_iflag|=IUTF8 helps w/ rubout on UTF-8 input - -syscon termios OPOST 0b0000000000000001 0b000000000000000001 0b000000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 # termios.c_oflag&=~OPOST disables output processing magic -syscon termios OLCUC 0b0000000000000010 0b000000000000000000 0 0b0000000000100000 0b0000000000100000 0b0000000000000010 # termios.c_oflag|=OLCUC maps a-z → A-Z output -syscon termios ONLCR 0b0000000000000100 0b000000000000000010 0b000000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000100 # termios.c_oflag|=ONLCR maps \n → \r\n output -syscon termios OCRNL 0b0000000000001000 0b000000000000010000 0b000000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000001000 # termios.c_oflag|=OCRNL maps \r → \n output -syscon termios ONOCR 0b0000000000010000 0b000000000000100000 0b000000000000100000 0b0000000001000000 0b0000000001000000 0b0000000000010000 # termios.c_oflag|=ONOCR maps \r → ∅ output iff column 0 -syscon termios ONLRET 0b0000000000100000 0b000000000001000000 0b000000000001000000 0b0000000010000000 0b0000000010000000 0b0000000000100000 # termios.c_oflag|=ONLRET maps \r → ∅ output -syscon termios OFILL 0b0000000001000000 0b000000000010000000 0 0 0 0b0000000001000000 # termios.c_oflag -syscon termios OFDEL 0b0000000010000000 0b100000000000000000 0 0 0 0b0000000010000000 # termios.c_oflag -syscon termios NLDLY 0b0000000100000000 0b000000001100000000 0b000000001100000000 0 0 0b0000000100000000 # (termios.c_oflag & NLDLY) ∈ {NL0,NL1,NL2,NL3} -syscon termios NL0 0b0000000000000000 0b000000000000000000 0b000000000000000000 0 0 0b0000000000000000 # (termios.c_oflag & NLDLY) == NL0 -syscon termios NL1 0b0000000100000000 0b000000000100000000 0b000000000100000000 0 0 0b0000000100000000 # (termios.c_oflag & NLDLY) == NL1 -syscon termios NL2 0 0b000000001000000000 0b000000001000000000 0 0 0 # (termios.c_oflag & NLDLY) == NL2 -syscon termios NL3 0 0b000000001100000000 0b000000001100000000 0 0 0 # (termios.c_oflag & NLDLY) == NL3 -syscon termios CRDLY 0b0000011000000000 0b000011000000000000 0b000011000000000000 0 0 0b0000011000000000 # (termios.c_oflag & CRDLY) ∈ {CR0,CR1,CR2,CR3} -syscon termios CR0 0b0000000000000000 0b000000000000000000 0b000000000000000000 0x0 0x0 0b0000000000000000 # (termios.c_oflag & CRDLY) == CR0 -syscon termios CR1 0b0000001000000000 0b000001000000000000 0b000001000000000000 0x0 0x0 0b0000001000000000 # (termios.c_oflag & CRDLY) == CR1 -syscon termios CR2 0b0000010000000000 0b000010000000000000 0b000010000000000000 0x0 0x0 0b0000010000000000 # (termios.c_oflag & CRDLY) == CR2 -syscon termios CR3 0b0000011000000000 0b000011000000000000 0b000011000000000000 0x0 0x0 0b0000011000000000 # (termios.c_oflag & CRDLY) == CR3 -syscon termios TABDLY 0b0001100000000000 0b000000110000000100 0b000000000000000100 0 0 0b0001100000000000 # (termios.c_oflag & TABDLY) ∈ {TAB0,TAB1,TAB2,TAB3,XTABS} -syscon termios TAB0 0b0000000000000000 0b000000000000000000 0b000000000000000000 0 0 0b0000000000000000 # (termios.c_oflag & TABDLY) == TAB0 -syscon termios TAB1 0b0000100000000000 0b000000010000000000 0b000000010000000000 0 0 0b0000100000000000 # (termios.c_oflag & TABDLY) == TAB1 -syscon termios TAB2 0b0001000000000000 0b000000100000000000 0b000000100000000000 0 0 0b0001000000000000 # (termios.c_oflag & TABDLY) == TAB2 -syscon termios TAB3 0b0001100000000000 0b000000000000000100 0b000000000000000100 0 0 0b0001100000000000 # (termios.c_oflag & TABDLY) == TAB3 -syscon termios XTABS 0b0001100000000000 0b000000000000000000 0b000000110000000000 0 0 0b0001100000000000 # (termios.c_oflag & TABDLY) == XTABS -syscon termios BSDLY 0b0010000000000000 0b001000000000000000 0b001000000000000000 0 0 0b0010000000000000 # termios.c_oflag -syscon termios BS0 0b0000000000000000 0b000000000000000000 0b000000000000000000 0 0 0b0000000000000000 # termios.c_oflag -syscon termios BS1 0b0010000000000000 0b001000000000000000 0b001000000000000000 0 0 0b0010000000000000 # termios.c_oflag -syscon termios VTDLY 0b0100000000000000 0b010000000000000000 0b010000000000000000 0 0 0b0100000000000000 # termios.c_oflag -syscon termios VT0 0b0000000000000000 0b000000000000000000 0b000000000000000000 0 0 0b0000000000000000 # termios.c_oflag -syscon termios VT1 0b0100000000000000 0b010000000000000000 0b010000000000000000 0 0 0b0100000000000000 # termios.c_oflag -syscon termios FFDLY 0b1000000000000000 0b000100000000000000 0b000100000000000000 0 0 0b1000000000000000 # termios.c_oflag -syscon termios FF0 0b0000000000000000 0b000000000000000000 0b000000000000000000 0 0 0b0000000000000000 # termios.c_oflag -syscon termios FF1 0b1000000000000000 0b000100000000000000 0b000100000000000000 0 0 0b1000000000000000 # termios.c_oflag - -syscon termios CS6 0b0000000000010000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000000010000 # termios.c_cflag flag for 6-bit characters -syscon termios CS7 0b0000000000100000 0b0000001000000000 0b0000001000000000 0b0000001000000000 0b0000001000000000 0b0000000000100000 # termios.c_cflag flag for 7-bit characters -syscon termios CS8 0b0000000000110000 0b0000001100000000 0b0000001100000000 0b0000001100000000 0b0000001100000000 0b0000000000110000 # termios.c_cflag flag for 8-bit characters -syscon termios CSIZE 0b0000000000110000 0b0000001100000000 0b0000001100000000 0b0000001100000000 0b0000001100000000 0b0000000000110000 # mask for CS𝑥 flags - -syscon termios NCCS 32 32 32 32 20 32 # ARRAYLEN(termios.c_cc); faked xnu/freebsd/openbsd (originally 20) and faked nt -syscon termios VINTR 0 8 8 8 8 0 # termios.c_cc[VINTR]=𝑥 -syscon termios VQUIT 1 9 9 9 9 0 # termios.c_cc[VQUIT]=𝑥 -syscon termios VERASE 2 3 3 3 3 0 # termios.c_cc[VERASE]=𝑥 -syscon termios VKILL 3 5 5 5 5 0 # termios.c_cc[VKILL]=𝑥 -syscon termios VEOF 4 0 0 0 0 0 # termios.c_cc[VEOF]=𝑥 -syscon termios VTIME 5 17 17 17 17 0 # termios.c_cc[VTIME]=𝑥 sets non-canonical read timeout to 𝑥×𝟷𝟶𝟶ms which is needed when entering escape sequences manually with the escape key -syscon termios VMIN 6 16 16 16 16 0 # termios.c_cc[VMIN]=𝑥 in non-canonical mode can be set to 0 for non-blocking reads, 1 for single character raw mode reads, or higher to buffer -syscon termios VSWTC 7 0 0 0 0 0 # termios.c_cc[VSWTC]=𝑥 -syscon termios VSTART 8 12 12 12 12 0 # termios.c_cc[VSTART]=𝑥 -syscon termios VSTOP 9 13 13 13 13 0 # termios.c_cc[VSTOP]=𝑥 -syscon termios VSUSP 10 10 10 10 10 0 # termios.c_cc[VSUSP]=𝑥 defines suspend, i.e. Ctrl-Z (a.k.a. →, ^Z, SUB, 26, 032, 0x1A, ord('Z')^0b01000000); unix consensus -syscon termios VEOL 11 1 1 1 1 0 # termios.c_cc[VEOL]=𝑥 -syscon termios VEOL2 16 2 2 2 2 0 # termios.c_cc[VEOL2]=𝑥 -syscon termios VREPRINT 12 6 6 6 6 0 # termios.c_cc[VREPRINT]=𝑥 -syscon termios VDISCARD 13 15 15 15 15 0 # termios.c_cc[VDISCARD]=𝑥 -syscon termios VWERASE 14 4 4 4 4 0 # termios.c_cc[VWERASE]=𝑥 -syscon termios VLNEXT 15 14 14 14 14 0 # termios.c_cc[VLNEXT]=𝑥 - -syscon termios TIOCSERGETLSR 0x5459 0 0 0 0 0 # -syscon termios TIOCSERGETMULTI 0x545a 0 0 0 0 0 # -syscon termios TIOCSERSETMULTI 0x545b 0 0 0 0 0 # -syscon termios TIOCSER_TEMT 1 0 0 0 0 0 # -syscon termios VERIFY 47 0 0 0 0 0 -syscon termios PARENB 0x0100 0x1000 0x1000 0x1000 0x1000 0 # -syscon termios PARODD 0x0200 0x2000 0x2000 0x2000 0x2000 0 # -syscon termios CIBAUD 0x100f0000 0 0 0 0 0 -syscon termios CLOCAL 0x0800 0x8000 0x8000 0x8000 0x8000 0 # -syscon termios CMSPAR 0x40000000 0 0 0 0 0 -syscon termios BUSY 4 0 0 0 0 0 -syscon termios CANBSIZ 255 0 0 0 0 0 -syscon termios CBAUD 0x100f 0 0 0 0 0 -syscon termios CBAUDEX 0x1000 0 0 0 0 0 -syscon termios CBRK 0 255 255 255 255 0 # -syscon termios CEOL 0 255 255 255 255 0 # - -# Pseudoteletypewriter Control -# -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary -syscon pty TIOCPKT 0x5420 0x80047470 0x80047470 0x80047470 0x80047470 -1 # boop -syscon pty TIOCPKT_DATA 0 0 0 0 0 0 # consensus -syscon pty TIOCPKT_FLUSHREAD 1 1 1 1 1 1 # unix consensus -syscon pty TIOCPKT_FLUSHWRITE 2 2 2 2 2 2 # unix consensus -syscon pty TIOCPKT_STOP 4 4 4 4 4 4 # unix consensus -syscon pty TIOCPKT_START 8 8 8 8 8 8 # unix consensus -syscon pty TIOCPKT_NOSTOP 16 16 16 16 16 16 # unix consensus -syscon pty TIOCPKT_DOSTOP 32 32 32 32 32 32 # unix consensus -syscon pty TIOCPKT_IOCTL 64 64 64 64 64 64 # unix consensus -syscon pty TIOCSPTLCK 0x40045431 0 0 0 0 -1 # boop -syscon pty PTMGET 0 0 0 0x40287401 0x40287401 -1 # for /dev/ptm - -# Modem Control -# -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX Commentary -syscon modem TIOCMGET 0x5415 0x4004746a 0x4004746a 0x4004746a 0x4004746a -1 # get status of modem bits; ioctl(fd, TIOCMGET, int *argp) -syscon modem TIOCMSET 0x5418 0x8004746d 0x8004746d 0x8004746d 0x8004746d -1 # set status of modem bits; ioctl(fd, TIOCMSET, const int *argp) -syscon modem TIOCMBIC 0x5417 0x8004746b 0x8004746b 0x8004746b 0x8004746b -1 # clear indicated modem bits; ioctl(fd, TIOCMBIC, int *argp) -syscon modem TIOCMBIS 0x5416 0x8004746c 0x8004746c 0x8004746c 0x8004746c -1 # set indicated modem bits; ioctl(fd, TIOCMBIS, int *argp) -syscon modem TIOCM_LE 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 0b0000000000000001 # consensus -syscon modem TIOCM_DTR 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000010 0b0000000000000010 # consensus -syscon modem TIOCM_RTS 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000000100 0b0000000000000100 # consensus -syscon modem TIOCM_ST 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 0b0000000000001000 # consensus -syscon modem TIOCM_SR 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000010000 0b0000000000010000 # consensus -syscon modem TIOCM_CTS 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000000000100000 0b0000000000100000 # consensus -syscon modem TIOCM_CAR 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 # consensus -syscon modem TIOCM_CD 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 0b0000000001000000 # boop -syscon modem TIOCM_RI 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 # boop -syscon modem TIOCM_RNG 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 0b0000000010000000 # boop -syscon modem TIOCM_DSR 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 0b0000000100000000 # consensus -syscon modem TIOCM_DCD 0 0 0x40 0 0 -1 # wut -syscon modem TIOCMODG 0 0x40047403 0 0x4004746a 0x4004746a -1 # wut -syscon modem TIOCMODS 0 0x80047404 0 0x8004746d 0x8004746d -1 # wut -syscon modem TIOCMSDTRWAIT 0 0x8004745b 0x8004745b 0 0 -1 # wut - -syscon ioctl FIONBIO 0x5421 0x8004667e 0x8004667e 0x8004667e 0x8004667e 0x8004667e # BSD-Windows consensus; FIONBIO is traditional O_NONBLOCK; see F_SETFL for re-imagined api -syscon ioctl FIOASYNC 0x5452 0x8004667d 0x8004667d 0x8004667d 0x8004667d 0x8004667d # BSD-Windows consensus -syscon ioctl FIONREAD 0x541b 0x4004667f 0x4004667f 0x4004667f 0x4004667f 0x4004667f # BSD-Windows consensus; bytes waiting in FD's input buffer -#syscon ioctl FIONWRITE 0x0 0x0 0x40046677 0x0 0x0 -1 # [FreeBSD Generalization] bytes queued in FD's output buffer (same as TIOCOUTQ for TTY FDs; see also SO_SNDBUF) -#syscon ioctl FIONSPACE 0x0 0x0 0x40046676 0x0 0x0 -1 # [FreeBSD Generalization] capacity of FD's output buffer, e.g. equivalent to TIOCGSERIAL w/ UART -syscon ioctl TIOCINQ 0x541b 0x4004667f 0x4004667f 0x4004667f 0x4004667f 0x4004667f # [Linuxism] same as FIONREAD -#syscon ioctl TIOCOUTQ 0x5411 0x40047473 0x40047473 0x40047473 0x40047473 -1 # bytes queued in TTY's output buffer - -syscon misc FANOTIFY_METADATA_VERSION 3 0 0 0 0 0 -syscon misc FAPPEND 0x0400 8 8 8 8 0 # bsd consensus -syscon misc FASYNC 0x2000 0x40 0x40 0x40 0x40 0 # bsd consensus -syscon misc FFSYNC 0x101000 0x80 0x80 0x80 0x80 0 # bsd consensus -syscon misc FILENAME_MAX 0x1000 0x0400 0x0400 0x0400 0x0400 0 # bsd consensus -syscon misc FIOGETOWN 0x8903 0x4004667b 0x4004667b 0x4004667b 0x4004667b 0 # bsd consensus -syscon misc FIOSETOWN 0x8901 0x8004667c 0x8004667c 0x8004667c 0x8004667c 0 # bsd consensus -syscon misc FMAXEXP 0x80 0 0 0 0 0 -syscon misc FMINEXP -125 0 0 0 0 0 -syscon misc FNDELAY 0x0800 4 4 4 4 0 # bsd consensus -syscon misc FNONBLOCK 0x0800 4 4 4 4 0 # bsd consensus -syscon misc FOPEN_MAX 0x10 20 20 20 20 0 # bsd consensus -syscon misc FORMAT_UNIT 4 0 0 0 0 0 -syscon misc HARDWARE_ERROR 4 0 0 0 0 0 -syscon misc HEAD_OF_QUEUE_TAG 33 0 0 0 0 0 -syscon misc HUPCL 0x0400 0x4000 0x4000 0x4000 0x4000 0 # bsd consensus -syscon misc IGMP_MEMBERSHIP_QUERY 17 0 0 0 0 0 -syscon misc ILLEGAL_REQUEST 5 0 0 0 0 0 -syscon misc INITIATE_RECOVERY 15 0 0 0 0 0 -syscon misc INITIATOR_ERROR 5 0 0 0 0 0 -syscon misc INQUIRY 18 0 0 0 0 0 -syscon misc MAXHOSTNAMELEN 0x40 0x0100 0x0100 0x0100 0x0100 0 # bsd consensus -syscon misc MAXPATHLEN 255 255 255 255 255 255 # forced consensus -syscon misc MAXSYMLINKS 20 0x20 0x20 0x20 0x20 0 # bsd consensus -syscon misc MESSAGE_REJECT 7 0 0 0 0 0 -syscon misc MISCOMPARE 14 0 0 0 0 0 -syscon misc MOVE_MEDIUM 165 0 0 0 0 0 -syscon misc MTCOMPRESSION 0x20 0 0 0 0 0 -syscon misc MTFSFM 11 0 0 0 0 0 -syscon misc MTLOCK 28 0 0 0 0 0 -syscon misc MTMKPART 34 0 0 0 0 0 -syscon misc MTRAS1 14 0 0 0 0 0 -syscon misc MTRAS3 0x10 0 0 0 0 0 -syscon misc MTSETBLK 20 0 0 0 0 0 -syscon misc MTSETDENSITY 21 0 0 0 0 0 -syscon misc MTSETDRVBUFFER 24 0 0 0 0 0 -syscon misc MTSETPART 33 0 0 0 0 0 -syscon misc MTUNLOAD 31 0 0 0 0 0 -syscon misc MTUNLOCK 29 0 0 0 0 0 -syscon misc NCARGS 0x020000 0x040000 0x040000 0x040000 0x040000 0 # bsd consensus -syscon misc NGREG 23 0 0 0 0 0 -syscon misc NOGROUP -1 0xffff 0xffff 0xffff 0xffff 0 # bsd consensus -syscon misc ORDERED_QUEUE_TAG 34 0 0 0 0 0 -syscon misc ORIG_RAX 15 0 0 0 0 0 -syscon misc PIPE_BUF 0x1000 0x0200 0x0200 0x0200 0x0200 0 # bsd consensus -syscon misc PRE_FETCH 52 0 0 0 0 0 -syscon misc QUEUE_FULL 20 0 0 0 0 0 -syscon misc REASSIGN_BLOCKS 7 0 0 0 0 0 -syscon misc RECEIVE_DIAGNOSTIC 28 0 0 0 0 0 -syscon misc RECOVERED_ERROR 1 0 0 0 0 0 -syscon misc RECOVER_BUFFERED_DATA 20 0 0 0 0 0 -syscon misc RELEASE_RECOVERY 0x10 0 0 0 0 0 -syscon misc REQUEST_SENSE 3 0 0 0 0 0 -syscon misc RESERVATION_CONFLICT 12 0 0 0 0 0 -syscon misc RESERVE 22 0 0 0 0 0 -syscon misc RESERVE_10 86 0 0 0 0 0 -syscon misc RESTORE_POINTERS 3 0 0 0 0 0 -syscon misc REZERO_UNIT 1 0 0 0 0 0 -syscon misc RE_DUP_MAX 0x7fff 255 255 255 255 0 # bsd consensus -syscon misc RTCF_DOREDIRECT 0x01000000 0 0 0 0 0 -syscon misc SAVE_POINTERS 2 0 0 0 0 0 -syscon misc SEM_VALUE_MAX 0x7fffffff 0x7fff 0x7fffffff 0xffffffff 0xffffffff 0 -syscon misc SEM_INFO 19 0 11 0 0 0 -syscon misc SEM_STAT 18 0 10 0 0 0 - -syscon misc SHMLBA 0 0x1000 0x1000 0x1000 0x1000 0 # bsd consensus -syscon misc SIMPLE_QUEUE_TAG 0x20 0 0 0 0 0 -syscon misc SPACE 17 0 0 0 0 0 -syscon misc START_STOP 27 0 0 0 0 0 -syscon misc STATUS_MASK 62 0 0 0 0 0 -syscon misc SWAP_FLAG_DISCARD 0x010000 0 0 0 0 0 -syscon misc SYNCHRONIZE_CACHE 53 0 0 0 0 0 -syscon misc UMOUNT_NOFOLLOW 8 0 0 0 0 0 -syscon misc UNIT_ATTENTION 6 0 0 0 0 0 -syscon misc UPDATE_BLOCK 61 0 0 0 0 0 -syscon misc UT_HOSTSIZE 0x0100 0x10 0 0x0100 0x0100 0 -syscon misc UT_LINESIZE 0x20 8 0 8 8 0 -syscon misc UT_NAMESIZE 0x20 8 0 0x20 0x20 0 - -syscon misc WEOF 0xffffffff -1 -1 -1 -1 -1 # bsd consensus (win fake) -syscon misc _LINUX_QUOTA_VERSION 2 0 0 0 0 0 -syscon misc _SEM_SEMUN_UNDEFINED 1 0 0 0 0 0 -syscon misc D_FMT 0x020029 2 2 1 1 0 -syscon misc D_T_FMT 0x020028 1 1 0 0 0 - -syscon misc LOGIN_PROCESS 6 6 6 0 0 0 -syscon misc LOGIN_NAME_MAX 0x0100 0 0 0x20 0x20 0 - -syscon misc T_FMT 0x02002a 3 3 2 2 0 -syscon misc T_FMT_AMPM 0x02002b 4 4 3 3 0 - -syscon misc UL_GETFSIZE 1 1 1 0 0 0 -syscon misc UL_SETFSIZE 2 2 2 0 0 0 - -syscon misc XATTR_CREATE 1 2 0 0 0 0 -syscon misc XATTR_REPLACE 2 4 0 0 0 0 - -syscon misc ACCOUNTING 9 9 0 0 0 0 -syscon misc AHZ 100 0x40 0 0x40 0x40 0 -syscon misc ALT_DIGITS 0x02002f 49 49 0 0 0 -syscon misc AM_STR 0x020026 5 5 4 4 0 -syscon misc B460800 0x1004 0 0x070800 0 0 0 -syscon misc B921600 0x1007 0 0x0e1000 0 0 0 -syscon misc BOOT_TIME 2 2 1 0 0 0 -syscon misc CHARCLASS_NAME_MAX 0x0800 14 14 0 0 0 -syscon misc CLOCKS_PER_SEC 1000000 1000000 0x80 100 100 10000000 -syscon misc CODESET 14 0 0 51 51 0 -syscon misc COLL_WEIGHTS_MAX 255 2 10 2 2 0 -syscon misc CPU_SETSIZE 0x0400 0 0x0100 0 0 0 -syscon misc CRNCYSTR 0x04000f 56 56 50 50 0 -syscon misc CRTSCTS 0x80000000 0x030000 0x030000 0x010000 0x010000 0 -syscon misc CSTATUS 0 20 20 255 255 0 -syscon misc DEAD_PROCESS 8 8 7 0 0 0 -syscon misc FNM_NOSYS -1 -1 -1 2 2 0 -syscon misc INIT_PROCESS 5 5 5 0 0 0 -syscon misc MINSIGSTKSZ 0x0800 0x8000 0x0800 0x3000 0x2000 0 -syscon misc MQ_PRIO_MAX 0x8000 0 0x40 0 0 0 -syscon misc MTERASE 13 0 12 9 9 0 -syscon misc MTLOAD 30 0 19 0 0 0 -syscon misc MTRETEN 9 0 0 8 8 0 -syscon misc NEW_TIME 3 4 3 0 0 0 -syscon misc NFDBITS 0x40 0x20 0x40 0x20 0x20 0 -syscon misc NGROUPS 0x010000 0x10 0x0400 0x10 0x10 0 -syscon misc NGROUPS_MAX 0x010000 0x10 0x03ff 0x10 0x10 0 -syscon misc NOEXPR 0x050001 53 53 49 49 0 -syscon misc NOFILE 0x0100 0x0100 0x40 0x40 0x40 0 -syscon misc NOSTR 0x050003 55 55 48 48 0 -syscon misc OLD_TIME 4 3 2 0 0 0 -syscon misc PM_STR 0x020027 6 6 5 5 0 -syscon misc RADIXCHAR 0x010000 50 50 44 44 0 -syscon misc RUN_LVL 1 1 0 0 0 0 -syscon misc STA_RONLY 0xff00 0 0xff00 0 0 0 -syscon misc SYMLOOP_MAX 0 0 0 0x20 0x20 0 -syscon misc THOUSEP 0x010001 51 51 45 45 0 -syscon misc TIMER_ABSTIME 1 0 1 1 1 0 -syscon misc TIME_UTC 1 0 1 0 0 0 -syscon misc TMP_MAX 0x03a2f8 0x1269ae40 0x1269ae40 0x7fffffff 0x7fffffff 0 -syscon misc TSS_DTOR_ITERATIONS 0 0 4 0 0 0 -syscon misc TTY_NAME_MAX 0x20 0 0 260 260 0 -syscon misc UIO_MAXIOV 0x0400 0 0 0x0400 0x0400 0 -syscon misc USER_PROCESS 7 7 4 0 0 0 -syscon misc YESEXPR 0x050000 52 52 47 47 0 -syscon misc YESSTR 0x050002 54 54 46 46 0 - # System Call Numbers. # -# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD XENIX +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology syscon nr __NR_exit 0x003c 0x2000001 0x0001 0x0001 0x001 0xfff syscon nr __NR_exit_group 0x00e7 0x2000001 0x0001 0x0001 0x001 0xfff syscon nr __NR_read 0x0000 0x2000003 0x0003 0x0003 0x003 0xfff @@ -3495,4 +2668,809 @@ syscon nr __NR_shared_region_map_and_slide_np 0xfff 0x20001b6 0xfff 0xfff syscon nr __NR_guarded_open_dprotected_np 0xfff 0x20001e4 0xfff 0xfff 0xfff 0xfff syscon nr __NR_stack_snapshot_with_config 0xfff 0x20001eb 0xfff 0xfff 0xfff 0xfff +# unilateral undocumented errnos +# +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary +syscon junkerr ECHRNG 44 0 0 0 0 0 +syscon junkerr EL2NSYNC 45 0 0 0 0 0 +syscon junkerr EL3HLT 46 0 0 0 0 0 +syscon junkerr EL3RST 47 0 0 0 0 0 +syscon junkerr ELNRNG 48 0 0 0 0 0 +syscon junkerr EUNATCH 49 0 0 0 0 0 +syscon junkerr ENOCSI 50 0 0 0 0 0 +syscon junkerr EL2HLT 51 0 0 0 0 0 +syscon junkerr EBADE 52 0 0 0 0 0 +syscon junkerr EBADR 53 0 0 0 0 0 +syscon junkerr EXFULL 54 0 0 0 0 0 +syscon junkerr ENOANO 55 0 0 0 0 0 +syscon junkerr EBADRQC 56 0 0 0 0 0 +syscon junkerr EBADSLT 57 0 0 0 0 0 +syscon junkerr ENOPKG 65 0 0 0 0 0 +syscon junkerr EADV 68 0 0 0 0 0 +syscon junkerr ESRMNT 69 0 0 0 0 0 +syscon junkerr ECOMM 70 0 0 0 0 0 +syscon junkerr EDOTDOT 73 0 0 0 0 0 +syscon junkerr ENOTUNIQ 76 0 0 0 0 0 +syscon junkerr EBADFD 77 9 0 0 0 0 +syscon junkerr EREMCHG 78 0 0 0 0 0 +syscon junkerr ELIBACC 79 0 0 0 0 0 +syscon junkerr ELIBBAD 80 0 0 0 0 0 +syscon junkerr ELIBSCN 81 0 0 0 0 0 +syscon junkerr ELIBMAX 82 0 0 0 0 0 +syscon junkerr ELIBEXEC 83 0 0 0 0 0 +syscon junkerr ESTRPIPE 86 0 0 0 0 0 +syscon junkerr EUCLEAN 117 0 0 0 0 0 +syscon junkerr ENOTNAM 118 0 0 0 0 0 +syscon junkerr ENAVAIL 119 0 0 0 0 0 +syscon junkerr EISNAM 120 0 0 0 0 0 +syscon junkerr EREMOTEIO 121 0 0 0 0 0 +syscon junkerr ENOKEY 126 0 0 0 0 0 +syscon junkerr EKEYEXPIRED 127 0 0 0 0 0 +syscon junkerr EKEYREVOKED 128 0 0 0 0 0 +syscon junkerr EKEYREJECTED 129 0 0 0 0 0 +syscon junkerr ERFKILL 132 0 0 0 0 0 +syscon junkerr EHWPOISON 133 0 0 0 0 0 + +# arpanet fork combating human-induced exhaustion of our ipv4 address space +# +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary +syscon ipv6 IPV6_PMTUDISC_DONT 0 0 0 0 0 0 # consensus +syscon ipv6 IPV6_RTHDR_LOOSE 0 0 0 0 0 0 # consensus +syscon ipv6 IPV6_RTHDR_TYPE_0 0 0 0 0 0 0 # consensus +syscon ipv6 IPV6_CHECKSUM 7 26 26 26 26 26 # bsd consensus +syscon ipv6 IPV6_JOIN_GROUP 20 12 12 12 12 12 # bsd consensus +syscon ipv6 IPV6_LEAVE_GROUP 21 13 13 13 13 13 # bsd consensus +syscon ipv6 IPV6_MULTICAST_HOPS 18 10 10 10 10 10 # bsd consensus +syscon ipv6 IPV6_MULTICAST_IF 17 9 9 9 9 9 # bsd consensus +syscon ipv6 IPV6_MULTICAST_LOOP 19 11 11 11 11 11 # bsd consensus +syscon ipv6 IPV6_UNICAST_HOPS 0x10 4 4 4 4 4 # bsd consensus +syscon ipv6 IPV6_V6ONLY 26 27 27 27 27 27 # bsd consensus +syscon ipv6 IPV6_RECVTCLASS 66 35 57 57 57 40 +syscon ipv6 IPV6_TCLASS 67 36 61 61 61 39 +syscon ipv6 IPV6_DONTFRAG 62 0 62 62 62 14 +syscon ipv6 IPV6_HOPLIMIT 52 0 47 47 47 21 +syscon ipv6 IPV6_HOPOPTS 54 0 49 49 49 1 +syscon ipv6 IPV6_PKTINFO 50 0 46 46 46 19 +syscon ipv6 IPV6_RECVRTHDR 56 0 38 38 38 38 +syscon ipv6 IPV6_RTHDR 57 0 51 51 51 0x20 +syscon ipv6 IPV6_DSTOPTS 59 0 50 50 50 0 +syscon ipv6 IPV6_IPSEC_POLICY 34 28 28 0 0 0 +syscon ipv6 IPV6_NEXTHOP 9 0 48 48 48 0 +syscon ipv6 IPV6_PATHMTU 61 0 44 44 44 0 +syscon ipv6 IPV6_RECVDSTOPTS 58 0 40 40 40 0 +syscon ipv6 IPV6_RECVHOPLIMIT 51 0 37 37 37 0 +syscon ipv6 IPV6_RECVHOPOPTS 53 0 39 39 39 0 +syscon ipv6 IPV6_RECVPATHMTU 60 0 43 43 43 0 +syscon ipv6 IPV6_RECVPKTINFO 49 0 36 36 36 0 +syscon ipv6 IPV6_RTHDRDSTOPTS 55 0 35 35 35 0 +syscon ipv6 IPV6_RTHDR_STRICT 1 1 1 0 0 0 +syscon ipv6 IPV6_ADD_MEMBERSHIP 20 0 0 0 0 12 # bsd consensus +syscon ipv6 IPV6_DROP_MEMBERSHIP 21 0 0 0 0 13 # bsd consensus +syscon ipv6 IPV6_HDRINCL 36 0 0 0 0 2 # bsd consensus +syscon ipv6 IPV6_MTU 24 0 0 0 0 72 # bsd consensus +syscon ipv6 IPV6_MTU_DISCOVER 23 0 0 0 0 71 # bsd consensus +syscon ipv6 IPV6_RECVERR 25 0 0 0 0 75 # bsd consensus +syscon ipv6 IPV6_2292DSTOPTS 4 23 0 0 0 0 +syscon ipv6 IPV6_2292HOPLIMIT 8 20 0 0 0 0 +syscon ipv6 IPV6_2292HOPOPTS 3 22 0 0 0 0 +syscon ipv6 IPV6_2292PKTINFO 2 19 0 0 0 0 +syscon ipv6 IPV6_2292PKTOPTIONS 6 25 0 0 0 0 +syscon ipv6 IPV6_2292RTHDR 5 24 0 0 0 0 +syscon ipv6 IPV6_AUTOFLOWLABEL 0 0 59 59 59 0 +syscon ipv6 IPV6_ADDRFORM 1 0 0 0 0 0 +syscon ipv6 IPV6_AUTHHDR 10 0 0 0 0 0 +syscon ipv6 IPV6_JOIN_ANYCAST 27 0 0 0 0 0 +syscon ipv6 IPV6_LEAVE_ANYCAST 28 0 0 0 0 0 +syscon ipv6 IPV6_PMTUDISC_DO 2 0 0 0 0 0 +syscon ipv6 IPV6_PMTUDISC_INTERFACE 4 0 0 0 0 0 +syscon ipv6 IPV6_PMTUDISC_OMIT 5 0 0 0 0 0 +syscon ipv6 IPV6_PMTUDISC_PROBE 3 0 0 0 0 0 +syscon ipv6 IPV6_PMTUDISC_WANT 1 0 0 0 0 0 +syscon ipv6 IPV6_ROUTER_ALERT 22 0 0 0 0 0 +syscon ipv6 IPV6_RXDSTOPTS 59 0 0 0 0 0 +syscon ipv6 IPV6_RXHOPOPTS 54 0 0 0 0 0 +syscon ipv6 IPV6_XFRM_POLICY 35 0 0 0 0 0 +syscon ipv6 IPV6_MINHOPCOUNT 0 0 0 65 65 0 +syscon ipv6 IPV6_ORIGDSTADDR 0 0 72 0 0 0 +syscon ipv6 IPV6_RECVORIGDSTADDR 0 0 72 0 0 0 +syscon ipv6 INET6_ADDRSTRLEN 46 46 46 46 46 65 # unix consensus +syscon icmp6 ICMP6_DST_UNREACH_NOROUTE 0 0 0 0 0 0 # consensus +syscon icmp6 ICMP6_PARAMPROB_HEADER 0 0 0 0 0 0 # consensus +syscon icmp6 ICMP6_TIME_EXCEED_TRANSIT 0 0 0 0 0 0 # consensus +syscon icmp6 ICMP6_DST_UNREACH_ADMIN 1 1 1 1 1 1 # consensus +syscon icmp6 ICMP6_PARAMPROB_NEXTHEADER 1 1 1 1 1 1 # consensus +syscon icmp6 ICMP6_TIME_EXCEED_REASSEMBLY 1 1 1 1 1 1 # consensus +syscon icmp6 ICMP6_DST_UNREACH 1 1 1 1 1 0 # unix consensus +syscon icmp6 ICMP6_FILTER 1 18 18 18 18 0 # bsd consensus +syscon icmp6 ICMP6_DST_UNREACH_BEYONDSCOPE 2 2 2 2 2 2 # consensus +syscon icmp6 ICMP6_PARAMPROB_OPTION 2 2 2 2 2 2 # consensus +syscon icmp6 ICMP6_PACKET_TOO_BIG 2 2 2 2 2 0 # unix consensus +syscon icmp6 ICMP6_DST_UNREACH_ADDR 3 3 3 3 3 3 # consensus +syscon icmp6 ICMP6_TIME_EXCEEDED 3 3 3 3 3 0 # unix consensus +syscon icmp6 ICMP6_DST_UNREACH_NOPORT 4 4 4 4 4 4 # consensus +syscon icmp6 ICMP6_PARAM_PROB 4 4 4 4 4 0 # unix consensus +syscon icmp6 ICMP6_RR_FLAGS_PREVDONE 8 8 8 8 8 0 # unix consensus +syscon icmp6 ICMP6_RR_FLAGS_SPECSITE 0x10 0x10 0x10 0x10 0x10 0 # unix consensus +syscon icmp6 ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10 0x40 0x40 0x40 0x40 0 # bsd consensus +syscon icmp6 ICMP6_RR_FLAGS_FORCEAPPLY 0x20 0x20 0x20 0x20 0x20 0 # unix consensus +syscon icmp6 ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20 0x80 0x80 0x80 0x80 0 # bsd consensus +syscon icmp6 ICMP6_RR_FLAGS_REQRESULT 0x40 0x40 0x40 0x40 0x40 0 # unix consensus +syscon icmp6 ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40 0x40 0x40 0x40 0x40 0 # unix consensus +syscon icmp6 ICMP6_INFOMSG_MASK 0x80 0x80 0x80 0x80 0x80 0x80 # consensus +syscon icmp6 ICMP6_ECHO_REQUEST 0x80 0x80 0x80 0x80 0x80 0 # unix consensus +syscon icmp6 ICMP6_RR_FLAGS_TEST 0x80 0x80 0x80 0x80 0x80 0 # unix consensus +syscon icmp6 ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80 0x80 0x80 0x80 0x80 0 # unix consensus +syscon icmp6 ICMP6_ECHO_REPLY 129 129 129 129 129 0 # unix consensus +syscon icmp6 ICMP6_ROUTER_RENUMBERING 138 138 138 138 138 0 # unix consensus +syscon icmp6 ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100 0x0100 0x0100 0x0100 0x0100 0 # unix consensus +syscon icmp6 ICMP6_RR_RESULT_FLAGS_OOB 0x0200 0x0200 0x0200 0x0200 0x0200 0 # unix consensus + +# java's computational model +# solves the sharing problem by defining everything as shared +# +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary +syscon misc PTHREAD_MUTEX_STALLED 0 0 0 0 0 0 # consensus +syscon misc PTHREAD_PRIO_NONE 0 0 0 0 0 0 # consensus +syscon misc PTHREAD_PRIO_INHERIT 0 1 1 1 1 0 # bsd consensus +syscon misc PTHREAD_PRIO_PROTECT 0 2 2 2 2 0 # bsd consensus +syscon misc PTHREAD_DESTRUCTOR_ITERATIONS 4 4 4 4 4 0 # unix consensus +syscon misc PTHREAD_PROCESS_SHARED 1 1 1 1 1 0 # unix consensus +syscon misc PTHREAD_CREATE_DETACHED 1 2 1 1 1 0 +syscon misc PTHREAD_KEYS_MAX 0x0400 0x0200 0x0100 0x0100 0x0100 0 +syscon misc PTHREAD_STACK_MIN 0x4000 0x2000 0x0800 0x1000 0x1000 0 +syscon misc PTHREAD_BARRIER_SERIAL_THREAD -1 0 -1 -1 -1 0 +syscon misc PTHREAD_CANCEL_ASYNCHRONOUS 1 0 2 2 2 0 +syscon misc PTHREAD_CANCEL_DISABLE 1 0 1 1 1 0 +syscon misc PTHREAD_INHERIT_SCHED 0 1 4 4 4 0 +syscon misc PTHREAD_SCOPE_SYSTEM 0 1 2 2 2 0 +syscon misc PTHREAD_EXPLICIT_SCHED 1 2 0 0 0 0 +syscon misc PTHREAD_MUTEX_DEFAULT 0 0 1 4 4 0 +syscon misc PTHREAD_MUTEX_ERRORCHECK 0 1 0 1 1 0 +syscon misc PTHREAD_MUTEX_RECURSIVE 0 2 0 2 2 0 +syscon misc PTHREAD_SCOPE_PROCESS 1 2 0 0 0 0 +syscon misc PTHREAD_CANCEL_DEFERRED 0 2 0 0 0 0 +syscon misc PTHREAD_CANCEL_ENABLE 0 1 0 0 0 0 +syscon misc PTHREAD_CREATE_JOINABLE 0 1 0 0 0 0 +syscon misc PTHREAD_MUTEX_NORMAL 0 0 0 3 3 0 +syscon misc PTHREAD_MUTEX_ROBUST 0 0 1 0 0 0 +syscon misc PTHREAD_PROCESS_PRIVATE 0 2 0 0 0 0 + +syscon fan FAN_CLASS_NOTIF 0 0 0 0 0 0 # consensus +syscon fan FAN_ACCESS 1 0 0 0 0 0 +syscon fan FAN_ACCESS_PERM 0x020000 0 0 0 0 0 +syscon fan FAN_ALLOW 1 0 0 0 0 0 +syscon fan FAN_ALL_CLASS_BITS 12 0 0 0 0 0 +syscon fan FAN_ALL_EVENTS 59 0 0 0 0 0 +syscon fan FAN_ALL_INIT_FLAGS 63 0 0 0 0 0 +syscon fan FAN_ALL_MARK_FLAGS 255 0 0 0 0 0 +syscon fan FAN_ALL_OUTGOING_EVENTS 0x03403b 0 0 0 0 0 +syscon fan FAN_ALL_PERM_EVENTS 0x030000 0 0 0 0 0 +syscon fan FAN_CLASS_CONTENT 4 0 0 0 0 0 +syscon fan FAN_CLASS_PRE_CONTENT 8 0 0 0 0 0 +syscon fan FAN_CLOEXEC 1 0 0 0 0 0 +syscon fan FAN_CLOSE 24 0 0 0 0 0 +syscon fan FAN_CLOSE_NOWRITE 0x10 0 0 0 0 0 +syscon fan FAN_CLOSE_WRITE 8 0 0 0 0 0 +syscon fan FAN_DENY 2 0 0 0 0 0 +syscon fan FAN_EVENT_METADATA_LEN 24 0 0 0 0 0 +syscon fan FAN_EVENT_ON_CHILD 0x08000000 0 0 0 0 0 +syscon fan FAN_MARK_ADD 1 0 0 0 0 0 +syscon fan FAN_MARK_DONT_FOLLOW 4 0 0 0 0 0 +syscon fan FAN_MARK_FLUSH 0x80 0 0 0 0 0 +syscon fan FAN_MARK_IGNORED_MASK 0x20 0 0 0 0 0 +syscon fan FAN_MARK_IGNORED_SURV_MODIFY 0x40 0 0 0 0 0 +syscon fan FAN_MARK_MOUNT 0x10 0 0 0 0 0 +syscon fan FAN_MARK_ONLYDIR 8 0 0 0 0 0 +syscon fan FAN_MARK_REMOVE 2 0 0 0 0 0 +syscon fan FAN_MODIFY 2 0 0 0 0 0 +syscon fan FAN_NOFD -1 0 0 0 0 0 +syscon fan FAN_NONBLOCK 2 0 0 0 0 0 +syscon fan FAN_ONDIR 0x40000000 0 0 0 0 0 +syscon fan FAN_OPEN 0x20 0 0 0 0 0 +syscon fan FAN_OPEN_PERM 0x010000 0 0 0 0 0 +syscon fan FAN_Q_OVERFLOW 0x4000 0 0 0 0 0 +syscon fan FAN_UNLIMITED_MARKS 0x20 0 0 0 0 0 +syscon fan FAN_UNLIMITED_QUEUE 0x10 0 0 0 0 0 + +syscon misc FIFOTYPE 54 54 54 54 54 0 # unix consensus +syscon misc GRPQUOTA 1 1 1 1 1 0 # unix consensus +syscon misc IF_NAMESIZE 0x10 0x10 0x10 0x10 0x10 0 # unix consensus +syscon misc INTERMEDIATE_C_GOOD 10 0 0 0 0 0 +syscon misc INTERMEDIATE_GOOD 8 0 0 0 0 0 + +syscon misc IOV_MAX 0x0400 0x0400 0x0400 0x0400 0x0400 16 # unix consensus & MSG_MAXIOVLEN +syscon misc LINE_MAX 0x0800 0x0800 0x0800 0x0800 0x0800 0 # unix consensus +syscon misc LINKED_CMD_COMPLETE 10 0 0 0 0 0 +syscon misc LINKED_FLG_CMD_COMPLETE 11 0 0 0 0 0 + +syscon misc LNKTYPE 49 49 49 49 49 0 # unix consensus +syscon misc MAXNAMLEN 255 255 255 255 255 0 # unix consensus +syscon misc MAXQUOTAS 2 2 2 2 2 0 # unix consensus +syscon misc MEDIUM_ERROR 3 0 0 0 0 0 +syscon misc MEDIUM_SCAN 56 0 0 0 0 0 + +syscon misc NBBY 8 8 8 8 8 0 # unix consensus +syscon misc NR_DQHASH 43 0 0 0 0 0 +syscon misc NR_DQUOTS 0x0100 0 0 0 0 0 + +syscon misc PERSISTENT_RESERVE_IN 94 0 0 0 0 0 +syscon misc PERSISTENT_RESERVE_OUT 95 0 0 0 0 0 + +syscon misc PRELIM 1 1 1 1 1 0 # unix consensus +syscon misc REGTYPE 48 48 48 48 48 0 # unix consensus +syscon misc RES_PRF_CLASS 4 4 4 4 4 0 # unix consensus +syscon misc RHF_GUARANTEE_START_INIT 0x80 0 0 0 0 0 +syscon misc RHF_NO_LIBRARY_REPLACEMENT 4 0 0 0 0 0 + +syscon misc RRQ 1 1 1 1 1 0 # unix consensus +syscon misc RTF_NOFORWARD 0x1000 0 0 0 0 0 +syscon misc RTF_NOPMTUDISC 0x4000 0 0 0 0 0 + +syscon misc SARMAG 8 8 8 8 8 0 # unix consensus +syscon misc SEGSIZE 0x0200 0x0200 0x0200 0x0200 0x0200 0 # unix consensus +syscon misc SEND_DIAGNOSTIC 29 0 0 0 0 0 +syscon misc SEND_VOLUME_TAG 182 0 0 0 0 0 + +syscon misc SET_LIMITS 51 0 0 0 0 0 +syscon misc SET_WINDOW 36 0 0 0 0 0 + +syscon misc SFD_CLOEXEC 0x080000 0 0 0 0 0 +syscon misc SFD_NONBLOCK 0x0800 0 0 0 0 0 + +syscon misc SOMAXCONN 0x80 0x80 0x80 0x80 0x80 0x7fffffff # unix consensus +syscon misc SUBCMDMASK 255 255 255 255 255 0 # unix consensus +syscon misc SUBCMDSHIFT 8 8 8 8 8 0 # unix consensus +syscon misc SYMTYPE 50 50 50 50 50 0 # unix consensus +syscon misc TGEXEC 8 8 8 8 8 0 # unix consensus +syscon misc TGREAD 0x20 0x20 0x20 0x20 0x20 0 # unix consensus +syscon misc TGWRITE 0x10 0x10 0x10 0x10 0x10 0 # unix consensus +syscon misc TMAGLEN 6 6 6 6 6 0 # unix consensus +syscon misc TOEXEC 1 1 1 1 1 0 # unix consensus +syscon misc TOREAD 4 4 4 4 4 0 # unix consensus +syscon misc TOWRITE 2 2 2 2 2 0 # unix consensus +syscon misc TRANSIENT 4 4 4 4 4 0 # unix consensus +syscon misc TRY_AGAIN 2 2 2 2 2 0x2afa # unix consensus +syscon misc TSGID 0x0400 0x0400 0x0400 0x0400 0x0400 0 # unix consensus +syscon misc TSUID 0x0800 0x0800 0x0800 0x0800 0x0800 0 # unix consensus +syscon misc TSVTX 0x0200 0x0200 0x0200 0x0200 0x0200 0 # unix consensus +syscon misc TUEXEC 0x40 0x40 0x40 0x40 0x40 0 # unix consensus +syscon misc TUREAD 0x0100 0x0100 0x0100 0x0100 0x0100 0 # unix consensus +syscon misc TUWRITE 0x80 0x80 0x80 0x80 0x80 0 # unix consensus +syscon misc TVERSLEN 2 2 2 2 2 0 # unix consensus +syscon misc WORD_BIT 0x20 0x20 0x20 0x20 0x20 0 # unix consensus +syscon misc WRQ 2 2 2 2 2 0 # unix consensus +syscon misc SIGEV_THREAD 2 3 2 0 2 0 +syscon misc SIGEV_SIGNAL 0 1 1 0 1 0 +syscon misc SIGEV_NONE 1 0 0 0 0 0 + +syscon misc BC_BASE_MAX 99 99 99 0x7fffffff 0x7fffffff 0 +syscon misc BC_DIM_MAX 0x0800 0x0800 0x0800 0xffff 0xffff 0 +syscon misc BC_SCALE_MAX 99 99 99 0x7fffffff 0x7fffffff 0 +syscon misc BC_STRING_MAX 0x03e8 0x03e8 0x03e8 0x7fffffff 0x7fffffff 0 + +syscon misc ABORTED_COMMAND 11 0 0 0 0 0 +syscon misc ACORE 0 8 8 8 8 0 # bsd consensus +syscon misc AFORK 0 1 1 1 1 0 # bsd consensus +syscon misc AIO_ALLDONE 2 1 3 0 0 0 +syscon misc AIO_NOTCANCELED 1 4 2 0 0 0 +syscon misc AIO_CANCELED 0 2 1 0 0 0 + +syscon misc ALLOW_MEDIUM_REMOVAL 30 0 0 0 0 0 +syscon misc ASU 0 2 2 2 2 0 # bsd consensus +syscon misc ATF_NETMASK 0x20 0 0 0 0 0 +syscon misc AXSIG 0 0x10 0x10 0x10 0x10 0 # bsd consensus +syscon misc B1000000 0x1008 0 0 0 0 0 +syscon misc B110 3 110 110 110 110 0 # bsd consensus +syscon misc B115200 0x1002 0x01c200 0x01c200 0x01c200 0x01c200 0 # bsd consensus +syscon misc B1152000 0x1009 0 0 0 0 0 +syscon misc B1200 9 0x04b0 0x04b0 0x04b0 0x04b0 0 # bsd consensus +syscon misc B134 4 134 134 134 134 0 # bsd consensus +syscon misc B150 5 150 150 150 150 0 # bsd consensus +syscon misc B1500000 0x100a 0 0 0 0 0 +syscon misc B1800 10 0x0708 0x0708 0x0708 0x0708 0 # bsd consensus +syscon misc B19200 14 0x4b00 0x4b00 0x4b00 0x4b00 0 # bsd consensus +syscon misc B200 6 200 200 200 200 0 # bsd consensus +syscon misc B2000000 0x100b 0 0 0 0 0 +syscon misc B230400 0x1003 0x038400 0x038400 0x038400 0x038400 0 # bsd consensus +syscon misc B2400 11 0x0960 0x0960 0x0960 0x0960 0 # bsd consensus +syscon misc B2500000 0x100c 0 0 0 0 0 +syscon misc B300 7 300 300 300 300 0 # bsd consensus +syscon misc B3000000 0x100d 0 0 0 0 0 +syscon misc B3500000 0x100e 0 0 0 0 0 +syscon misc B38400 15 0x9600 0x9600 0x9600 0x9600 0 # bsd consensus +syscon misc B4000000 0x100f 0 0 0 0 0 +syscon misc B4800 12 0x12c0 0x12c0 0x12c0 0x12c0 0 # bsd consensus +syscon misc B50 1 50 50 50 50 0 # bsd consensus +syscon misc B500000 0x1005 0 0 0 0 0 +syscon misc B57600 0x1001 0xe100 0xe100 0xe100 0xe100 0 # bsd consensus +syscon misc B576000 0x1006 0 0 0 0 0 +syscon misc B600 8 600 600 600 600 0 # bsd consensus +syscon misc B75 2 75 75 75 75 0 # bsd consensus +syscon misc B9600 13 0x2580 0x2580 0x2580 0x2580 0 # bsd consensus +syscon misc BITSPERBYTE 8 0 0 0 0 0 +syscon misc BLANK_CHECK 8 0 0 0 0 0 +syscon misc CHANGE_DEFINITION 0x40 0 0 0 0 0 +syscon misc CHARBITS 8 0 0 0 0 0 +syscon misc CHECK_CONDITION 1 0 0 0 0 0 +syscon misc CONDITION_GOOD 2 0 0 0 0 0 +syscon misc CREAD 0x80 0x0800 0x0800 0x0800 0x0800 0 # bsd consensus +syscon misc CSTOPB 0x40 0x0400 0x0400 0x0400 0x0400 0 # bsd consensus +syscon misc DATA_PROTECT 7 0 0 0 0 0 +syscon misc DELAYTIMER_MAX 0x7fffffff 0 0 0 0 0 +syscon misc DMAXEXP 0x0400 0 0 0 0 0 +syscon misc DMINEXP -1021 0 0 0 0 0 +syscon misc DOUBLEBITS 0x40 0 0 0 0 0 +syscon misc ERA_D_FMT 0x02002e 46 46 0 0 0 +syscon misc ERA_D_T_FMT 0x020030 47 47 0 0 0 +syscon misc ERA_T_FMT 0x020031 48 48 0 0 0 + +syscon misc FANOTIFY_METADATA_VERSION 3 0 0 0 0 0 +syscon misc FAPPEND 0x0400 8 8 8 8 0 # bsd consensus +syscon misc FASYNC 0x2000 0x40 0x40 0x40 0x40 0 # bsd consensus +syscon misc FFSYNC 0x101000 0x80 0x80 0x80 0x80 0 # bsd consensus +syscon misc FILENAME_MAX 0x1000 0x0400 0x0400 0x0400 0x0400 0 # bsd consensus +syscon misc FIOGETOWN 0x8903 0x4004667b 0x4004667b 0x4004667b 0x4004667b 0 # bsd consensus +syscon misc FIOSETOWN 0x8901 0x8004667c 0x8004667c 0x8004667c 0x8004667c 0 # bsd consensus +syscon misc FMAXEXP 0x80 0 0 0 0 0 +syscon misc FMINEXP -125 0 0 0 0 0 +syscon misc FNDELAY 0x0800 4 4 4 4 0 # bsd consensus +syscon misc FNONBLOCK 0x0800 4 4 4 4 0 # bsd consensus +syscon misc FOPEN_MAX 0x10 20 20 20 20 0 # bsd consensus +syscon misc FORMAT_UNIT 4 0 0 0 0 0 +syscon misc HARDWARE_ERROR 4 0 0 0 0 0 +syscon misc HEAD_OF_QUEUE_TAG 33 0 0 0 0 0 +syscon misc HUPCL 0x0400 0x4000 0x4000 0x4000 0x4000 0 # bsd consensus +syscon misc IGMP_MEMBERSHIP_QUERY 17 0 0 0 0 0 +syscon misc ILLEGAL_REQUEST 5 0 0 0 0 0 +syscon misc INITIATE_RECOVERY 15 0 0 0 0 0 +syscon misc INITIATOR_ERROR 5 0 0 0 0 0 +syscon misc INQUIRY 18 0 0 0 0 0 +syscon misc MAXHOSTNAMELEN 0x40 0x0100 0x0100 0x0100 0x0100 0 # bsd consensus +syscon misc MAXPATHLEN 255 255 255 255 255 255 # forced consensus +syscon misc MAXSYMLINKS 20 0x20 0x20 0x20 0x20 0 # bsd consensus +syscon misc MESSAGE_REJECT 7 0 0 0 0 0 +syscon misc MISCOMPARE 14 0 0 0 0 0 +syscon misc MOVE_MEDIUM 165 0 0 0 0 0 +syscon misc MTCOMPRESSION 0x20 0 0 0 0 0 +syscon misc MTFSFM 11 0 0 0 0 0 +syscon misc MTLOCK 28 0 0 0 0 0 +syscon misc MTMKPART 34 0 0 0 0 0 +syscon misc MTRAS1 14 0 0 0 0 0 +syscon misc MTRAS3 0x10 0 0 0 0 0 +syscon misc MTSETBLK 20 0 0 0 0 0 +syscon misc MTSETDENSITY 21 0 0 0 0 0 +syscon misc MTSETDRVBUFFER 24 0 0 0 0 0 +syscon misc MTSETPART 33 0 0 0 0 0 +syscon misc MTUNLOAD 31 0 0 0 0 0 +syscon misc MTUNLOCK 29 0 0 0 0 0 +syscon misc NCARGS 0x020000 0x040000 0x040000 0x040000 0x040000 0 # bsd consensus +syscon misc NGREG 23 0 0 0 0 0 +syscon misc NOGROUP -1 0xffff 0xffff 0xffff 0xffff 0 # bsd consensus +syscon misc ORDERED_QUEUE_TAG 34 0 0 0 0 0 +syscon misc ORIG_RAX 15 0 0 0 0 0 +syscon misc PIPE_BUF 0x1000 0x0200 0x0200 0x0200 0x0200 0 # bsd consensus +syscon misc PRE_FETCH 52 0 0 0 0 0 +syscon misc QUEUE_FULL 20 0 0 0 0 0 +syscon misc REASSIGN_BLOCKS 7 0 0 0 0 0 +syscon misc RECEIVE_DIAGNOSTIC 28 0 0 0 0 0 +syscon misc RECOVERED_ERROR 1 0 0 0 0 0 +syscon misc RECOVER_BUFFERED_DATA 20 0 0 0 0 0 +syscon misc RELEASE_RECOVERY 0x10 0 0 0 0 0 +syscon misc REQUEST_SENSE 3 0 0 0 0 0 +syscon misc RESERVATION_CONFLICT 12 0 0 0 0 0 +syscon misc RESERVE 22 0 0 0 0 0 +syscon misc RESERVE_10 86 0 0 0 0 0 +syscon misc RESTORE_POINTERS 3 0 0 0 0 0 +syscon misc REZERO_UNIT 1 0 0 0 0 0 +syscon misc RE_DUP_MAX 0x7fff 255 255 255 255 0 # bsd consensus +syscon misc RTCF_DOREDIRECT 0x01000000 0 0 0 0 0 +syscon misc SAVE_POINTERS 2 0 0 0 0 0 +syscon misc SEM_VALUE_MAX 0x7fffffff 0x7fff 0x7fffffff 0xffffffff 0xffffffff 0 +syscon misc SEM_INFO 19 0 11 0 0 0 +syscon misc SEM_STAT 18 0 10 0 0 0 + +syscon misc SHMLBA 0 0x1000 0x1000 0x1000 0x1000 0 # bsd consensus +syscon misc SIMPLE_QUEUE_TAG 0x20 0 0 0 0 0 +syscon misc SPACE 17 0 0 0 0 0 +syscon misc START_STOP 27 0 0 0 0 0 +syscon misc STATUS_MASK 62 0 0 0 0 0 +syscon misc SWAP_FLAG_DISCARD 0x010000 0 0 0 0 0 +syscon misc SYNCHRONIZE_CACHE 53 0 0 0 0 0 +syscon misc UMOUNT_NOFOLLOW 8 0 0 0 0 0 +syscon misc UNIT_ATTENTION 6 0 0 0 0 0 +syscon misc UPDATE_BLOCK 61 0 0 0 0 0 +syscon misc UT_HOSTSIZE 0x0100 0x10 0 0x0100 0x0100 0 +syscon misc UT_LINESIZE 0x20 8 0 8 8 0 +syscon misc UT_NAMESIZE 0x20 8 0 0x20 0x20 0 + +syscon misc WEOF 0xffffffff -1 -1 -1 -1 -1 # bsd consensus (win fake) +syscon misc _LINUX_QUOTA_VERSION 2 0 0 0 0 0 +syscon misc _SEM_SEMUN_UNDEFINED 1 0 0 0 0 0 +syscon misc D_FMT 0x020029 2 2 1 1 0 +syscon misc D_T_FMT 0x020028 1 1 0 0 0 + +syscon misc LOGIN_PROCESS 6 6 6 0 0 0 +syscon misc LOGIN_NAME_MAX 0x0100 0 0 0x20 0x20 0 + +syscon misc T_FMT 0x02002a 3 3 2 2 0 +syscon misc T_FMT_AMPM 0x02002b 4 4 3 3 0 + +syscon misc UL_GETFSIZE 1 1 1 0 0 0 +syscon misc UL_SETFSIZE 2 2 2 0 0 0 + +syscon misc XATTR_CREATE 1 2 0 0 0 0 +syscon misc XATTR_REPLACE 2 4 0 0 0 0 + +syscon misc ACCOUNTING 9 9 0 0 0 0 +syscon misc AHZ 100 0x40 0 0x40 0x40 0 +syscon misc ALT_DIGITS 0x02002f 49 49 0 0 0 +syscon misc AM_STR 0x020026 5 5 4 4 0 +syscon misc B460800 0x1004 0 0x070800 0 0 0 +syscon misc B921600 0x1007 0 0x0e1000 0 0 0 +syscon misc BOOT_TIME 2 2 1 0 0 0 +syscon misc CHARCLASS_NAME_MAX 0x0800 14 14 0 0 0 +syscon misc CLOCKS_PER_SEC 1000000 1000000 0x80 100 100 10000000 +syscon misc CODESET 14 0 0 51 51 0 +syscon misc COLL_WEIGHTS_MAX 255 2 10 2 2 0 +syscon misc CPU_SETSIZE 0x0400 0 0x0100 0 0 0 +syscon misc CRNCYSTR 0x04000f 56 56 50 50 0 +syscon misc CRTSCTS 0x80000000 0x030000 0x030000 0x010000 0x010000 0 +syscon misc CSTATUS 0 20 20 255 255 0 +syscon misc DEAD_PROCESS 8 8 7 0 0 0 +syscon misc FNM_NOSYS -1 -1 -1 2 2 0 +syscon misc INIT_PROCESS 5 5 5 0 0 0 +syscon misc MINSIGSTKSZ 0x0800 0x8000 0x0800 0x3000 0x2000 0 +syscon misc MQ_PRIO_MAX 0x8000 0 0x40 0 0 0 +syscon misc MTERASE 13 0 12 9 9 0 +syscon misc MTLOAD 30 0 19 0 0 0 +syscon misc MTRETEN 9 0 0 8 8 0 +syscon misc NEW_TIME 3 4 3 0 0 0 +syscon misc NFDBITS 0x40 0x20 0x40 0x20 0x20 0 +syscon misc NGROUPS 0x010000 0x10 0x0400 0x10 0x10 0 +syscon misc NGROUPS_MAX 0x010000 0x10 0x03ff 0x10 0x10 0 +syscon misc NOEXPR 0x050001 53 53 49 49 0 +syscon misc NOFILE 0x0100 0x0100 0x40 0x40 0x40 0 +syscon misc NOSTR 0x050003 55 55 48 48 0 +syscon misc OLD_TIME 4 3 2 0 0 0 +syscon misc PM_STR 0x020027 6 6 5 5 0 +syscon misc RADIXCHAR 0x010000 50 50 44 44 0 +syscon misc RUN_LVL 1 1 0 0 0 0 +syscon misc STA_RONLY 0xff00 0 0xff00 0 0 0 +syscon misc SYMLOOP_MAX 0 0 0 0x20 0x20 0 +syscon misc THOUSEP 0x010001 51 51 45 45 0 +syscon misc TIMER_ABSTIME 1 0 1 1 1 0 +syscon misc TIME_UTC 1 0 1 0 0 0 +syscon misc TMP_MAX 0x03a2f8 0x1269ae40 0x1269ae40 0x7fffffff 0x7fffffff 0 +syscon misc TSS_DTOR_ITERATIONS 0 0 4 0 0 0 +syscon misc TTY_NAME_MAX 0x20 0 0 260 260 0 +syscon misc UIO_MAXIOV 0x0400 0 0 0x0400 0x0400 0 +syscon misc USER_PROCESS 7 7 4 0 0 0 +syscon misc YESEXPR 0x050000 52 52 47 47 0 +syscon misc YESSTR 0x050002 54 54 46 46 0 + +syscon in IN_LOOPBACKNET 127 127 127 127 127 0 # unix consensus +syscon in IN_ACCESS 1 0 0 0 0 0 +syscon in IN_ALL_EVENTS 0x0fff 0 0 0 0 0 +syscon in IN_ATTRIB 4 0 0 0 0 0 +syscon in IN_CLOEXEC 0x080000 0 0 0 0 0 +syscon in IN_CLOSE 24 0 0 0 0 0 +syscon in IN_CLOSE_NOWRITE 0x10 0 0 0 0 0 +syscon in IN_CLOSE_WRITE 8 0 0 0 0 0 +syscon in IN_CREATE 0x0100 0 0 0 0 0 +syscon in IN_DELETE 0x0200 0 0 0 0 0 +syscon in IN_DELETE_SELF 0x0400 0 0 0 0 0 +syscon in IN_DONT_FOLLOW 0x02000000 0 0 0 0 0 +syscon in IN_EXCL_UNLINK 0x04000000 0 0 0 0 0 +syscon in IN_IGNORED 0x8000 0 0 0 0 0 +syscon in IN_ISDIR 0x40000000 0 0 0 0 0 +syscon in IN_MASK_ADD 0x20000000 0 0 0 0 0 +syscon in IN_MODIFY 2 0 0 0 0 0 +syscon in IN_MOVE 192 0 0 0 0 0 +syscon in IN_MOVED_FROM 0x40 0 0 0 0 0 +syscon in IN_MOVED_TO 0x80 0 0 0 0 0 +syscon in IN_MOVE_SELF 0x0800 0 0 0 0 0 +syscon in IN_NONBLOCK 0x0800 0 0 0 0 0 +syscon in IN_ONESHOT 0x80000000 0 0 0 0 0 +syscon in IN_ONLYDIR 0x01000000 0 0 0 0 0 +syscon in IN_OPEN 0x20 0 0 0 0 0 +syscon in IN_Q_OVERFLOW 0x4000 0 0 0 0 0 +syscon in IN_UNMOUNT 0x2000 0 0 0 0 0 + +syscon posix _POSIX_ARG_MAX 0x1000 0x1000 0x1000 0x1000 0x1000 0 # unix consensus +syscon posix _POSIX_CHILD_MAX 25 25 25 25 25 0 # unix consensus +syscon posix _POSIX_HOST_NAME_MAX 255 255 255 255 255 0 # unix consensus +syscon posix _POSIX_LINK_MAX 8 8 8 8 8 0 # unix consensus +syscon posix _POSIX_LOGIN_NAME_MAX 9 9 9 9 9 0 # unix consensus +syscon posix _POSIX_MAX_CANON 255 255 255 255 255 0 # unix consensus +syscon posix _POSIX_MAX_INPUT 255 255 255 255 255 0 # unix consensus +syscon posix _POSIX_NAME_MAX 14 14 14 14 14 14 # forced consensus +syscon posix _POSIX_NGROUPS_MAX 8 8 8 8 8 0 # unix consensus +syscon posix _POSIX_OPEN_MAX 20 20 20 20 20 20 # forced consensus +syscon posix _POSIX_PATH_MAX 255 255 255 255 255 255 # forced consensus +syscon posix _POSIX_PIPE_BUF 0x0200 0x0200 0x0200 0x0200 0x0200 0 # unix consensus +syscon posix _POSIX_RE_DUP_MAX 255 255 255 255 255 0 # unix consensus +syscon posix _POSIX_SEM_NSEMS_MAX 0x0100 0x0100 0x0100 0x0100 0x0100 0 # unix consensus +syscon posix _POSIX_SEM_VALUE_MAX 0x7fff 0x7fff 0x7fff 0x7fff 0x7fff 0 # unix consensus +syscon posix _POSIX_SSIZE_MAX 0x7fff 0x7fff 0x7fff 0x7fff 0x7fff 0 # unix consensus +syscon posix _POSIX_STREAM_MAX 8 8 8 8 8 0 # unix consensus +syscon posix _POSIX_SYMLINK_MAX 255 255 255 255 255 0 # unix consensus +syscon posix _POSIX_SYMLOOP_MAX 8 8 8 8 8 0 # unix consensus +syscon posix _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 4 4 4 4 0 # unix consensus +syscon posix _POSIX_THREAD_KEYS_MAX 0x80 0x80 0x80 0x80 0x80 0 # unix consensus +syscon posix _POSIX_TTY_NAME_MAX 9 9 9 9 9 0 # unix consensus +syscon posix _POSIX_TZNAME_MAX 6 6 6 6 6 0 # unix consensus +syscon posix _POSIX_CLOCK_SELECTION 0x031069 -1 -1 -1 -1 0 # bsd consensus +syscon posix _POSIX_FSYNC 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus +syscon posix _POSIX_MAPPED_FILES 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus +syscon posix _POSIX_MEMORY_PROTECTION 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus +syscon posix _POSIX_READER_WRITER_LOCKS 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus +syscon posix _POSIX_THREADS 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus +syscon posix _POSIX_THREAD_ATTR_STACKADDR 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus +syscon posix _POSIX_THREAD_ATTR_STACKSIZE 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus +syscon posix _POSIX_ADVISORY_INFO 0x031069 -1 0x030db0 -1 -1 0 +syscon posix _POSIX_ASYNCHRONOUS_IO 0x031069 -1 0x030db0 -1 -1 0 +syscon posix _POSIX_BARRIERS 0x031069 -1 0x030db0 0x030db0 0x030db0 0 +syscon posix _POSIX_JOB_CONTROL 1 0x030db0 1 1 1 0 +syscon posix _POSIX_MEMLOCK 0x031069 -1 -1 0x030db0 0x030db0 0 +syscon posix _POSIX_MEMLOCK_RANGE 0x031069 -1 0x030db0 0x030db0 0x030db0 0 +syscon posix _POSIX_MESSAGE_PASSING 0x031069 -1 0x030db0 -1 -1 0 +syscon posix _POSIX_NO_TRUNC 1 0x030db0 1 1 1 0 +syscon posix _POSIX_RAW_SOCKETS 0x031069 -1 0x030db0 0x030db0 0x030db0 0 +syscon posix _POSIX_REALTIME_SIGNALS 0x031069 -1 0x030db0 -1 -1 0 +syscon posix _POSIX_REGEXP 1 0x030db0 1 1 1 0 +syscon posix _POSIX_SEMAPHORES 0x031069 -1 0x030db0 0x030db0 0x030db0 0 +syscon posix _POSIX_SHARED_MEMORY_OBJECTS 0x031069 -1 0x030db0 0x031069 0x031069 0 +syscon posix _POSIX_SHELL 1 0x030db0 1 1 1 0 +syscon posix _POSIX_SPAWN 0x031069 -1 0x030db0 0x030db0 0x030db0 0 +syscon posix _POSIX_SPIN_LOCKS 0x031069 -1 0x030db0 0x030db0 0x030db0 0 +syscon posix _POSIX_THREAD_PRIORITY_SCHEDULING 0x031069 -1 0x030db0 -1 -1 0 +syscon posix _POSIX_THREAD_PROCESS_SHARED 0x031069 0x030db0 0x030db0 -1 -1 0 +syscon posix _POSIX_THREAD_SAFE_FUNCTIONS 0x031069 0x030db0 -1 0x030db0 0x030db0 0 +syscon posix _POSIX_THREAD_THREADS_MAX 0x40 0x40 0x40 4 4 0 +syscon posix _POSIX_TIMEOUTS 0x031069 -1 0x030db0 0x030db0 0x030db0 0 +syscon posix _POSIX_TIMERS 0x031069 -1 0x030db0 -1 -1 0 +syscon posix _POSIX_VERSION 0x031069 0x030db0 0x030db0 0x031069 0x031069 0 +syscon posix _POSIX_VDISABLE 0 255 255 255 255 0 # bsd consensus +syscon posix _POSIX_AIO_LISTIO_MAX 2 2 2 0 0 0 +syscon posix _POSIX_AIO_MAX 1 1 1 0 0 0 +syscon posix _POSIX_CHOWN_RESTRICTED 0 0x030db0 1 1 1 0 +syscon posix _POSIX_CLOCKRES_MIN 0x01312d00 0 0x01312d00 0x01312d00 0x01312d00 0 +syscon posix _POSIX_CPUTIME 0 -1 0x030db0 0x031069 0x031069 0 +syscon posix _POSIX_DELAYTIMER_MAX 0x20 0x20 0x20 0 0 0 +syscon posix _POSIX_MONOTONIC_CLOCK 0 -1 0x030db0 0x030db0 0x030db0 0 +syscon posix _POSIX_MQ_OPEN_MAX 8 8 8 0 0 0 +syscon posix _POSIX_MQ_PRIO_MAX 0x20 0x20 0x20 0 0 0 +syscon posix _POSIX_RTSIG_MAX 8 8 8 0 0 0 +syscon posix _POSIX_SAVED_IDS 1 0x030db0 0 1 1 0 +syscon posix _POSIX_SIGQUEUE_MAX 0x20 0x20 0x20 0 0 0 +syscon posix _POSIX_THREAD_CPUTIME 0 -1 0x030db0 0x031069 0x031069 0 +syscon posix _POSIX_TIMER_MAX 0x20 0x20 0x20 0 0 0 +syscon posix _POSIX_IPV6 0x031069 0x030db0 0 0 0 0 +syscon posix _POSIX_SS_REPL_MAX 0 4 4 0 0 0 +syscon posix _POSIX_TRACE_EVENT_NAME_MAX 0 30 30 0 0 0 +syscon posix _POSIX_TRACE_NAME_MAX 0 8 8 0 0 0 +syscon posix _POSIX_TRACE_SYS_MAX 0 8 8 0 0 0 +syscon posix _POSIX_TRACE_USER_EVENT_MAX 0 0x20 0x20 0 0 0 +syscon posix _POSIX_V6_LP64_OFF64 1 1 0 0 0 0 +syscon posix _POSIX_V7_LP64_OFF64 1 1 0 0 0 0 + +syscon misc TYPE_DISK 0 0 0 0 0 0 # consensus +syscon misc TYPE_A 1 1 1 1 1 0 # unix consensus +syscon misc TYPE_E 2 2 2 2 2 0 # unix consensus +syscon misc TYPE_I 3 3 3 3 3 0 # unix consensus +syscon misc TYPE_L 4 4 4 4 4 0 # unix consensus +syscon misc TYPE_ENCLOSURE 13 0 0 0 0 0 +syscon misc TYPE_MEDIUM_CHANGER 8 0 0 0 0 0 +syscon misc TYPE_MOD 7 0 0 0 0 0 +syscon misc TYPE_NO_LUN 127 0 0 0 0 0 +syscon misc TYPE_PROCESSOR 3 0 0 0 0 0 +syscon misc TYPE_ROM 5 0 0 0 0 0 +syscon misc TYPE_SCANNER 6 0 0 0 0 0 +syscon misc TYPE_TAPE 1 0 0 0 0 0 +syscon misc TYPE_WORM 4 0 0 0 0 0 + +syscon misc _POSIX2_BC_BASE_MAX 99 99 99 99 99 0 # unix consensus +syscon misc _POSIX2_BC_DIM_MAX 0x0800 0x0800 0x0800 0x0800 0x0800 0 # unix consensus +syscon misc _POSIX2_BC_SCALE_MAX 99 99 99 99 99 0 # unix consensus +syscon misc _POSIX2_BC_STRING_MAX 0x03e8 0x03e8 0x03e8 0x03e8 0x03e8 0 # unix consensus +syscon misc _POSIX2_CHARCLASS_NAME_MAX 14 14 14 14 14 0 # unix consensus +syscon misc _POSIX2_COLL_WEIGHTS_MAX 2 2 2 2 2 0 # unix consensus +syscon misc _POSIX2_EXPR_NEST_MAX 0x20 0x20 0x20 0x20 0x20 0 # unix consensus +syscon misc _POSIX2_LINE_MAX 0x0800 0x0800 0x0800 0x0800 0x0800 0 # unix consensus +syscon misc _POSIX2_RE_DUP_MAX 255 255 255 255 255 0 # unix consensus +syscon misc _POSIX2_C_BIND 0x031069 0x030db0 0x030db0 0x030db0 0x030db0 0 # bsd consensus +syscon misc _POSIX2_VERSION 0x031069 0x030db0 0x030a2c 0x031069 0x031069 0 + +syscon nd ND_RA_FLAG_MANAGED 0x80 0x80 0x80 0x80 0x80 0x80 # consensus +syscon nd ND_RA_FLAG_OTHER 0x40 0x40 0x40 0x40 0x40 0x40 # consensus +syscon nd ND_NA_FLAG_OVERRIDE 0x20 0x20 0x20 0x20 0x20 0x20000000 # unix consensus +syscon nd ND_NA_FLAG_ROUTER 0x80 0x80 0x80 0x80 0x80 0x80000000 # unix consensus +syscon nd ND_NA_FLAG_SOLICITED 0x40 0x40 0x40 0x40 0x40 0x40000000 # unix consensus +syscon nd ND_NEIGHBOR_ADVERT 136 136 136 136 136 0 # unix consensus +syscon nd ND_NEIGHBOR_SOLICIT 135 135 135 135 135 0 # unix consensus +syscon nd ND_REDIRECT 137 137 137 137 137 0 # unix consensus +syscon nd ND_ROUTER_ADVERT 134 134 134 134 134 0 # unix consensus +syscon nd ND_ROUTER_SOLICIT 133 133 133 133 133 0 # unix consensus +syscon nd ND_RA_FLAG_HOME_AGENT 0x20 0 0 0 0 0x20 # bsd consensus + +syscon misc N_TTY 0 0 0 0 0 0 # consensus +syscon misc N_6PACK 7 0 0 0 0 0 +syscon misc N_AX25 5 0 0 0 0 0 +syscon misc N_HCI 15 0 0 0 0 0 +syscon misc N_HDLC 13 0 0 0 0 0 +syscon misc N_IRDA 11 0 0 0 0 0 +syscon misc N_MASC 8 0 0 0 0 0 +syscon misc N_MOUSE 2 0 0 0 0 0 +syscon misc N_PPP 3 0 0 0 0 0 +syscon misc N_PROFIBUS_FDL 10 0 0 0 0 0 +syscon misc N_R3964 9 0 0 0 0 0 +syscon misc N_SLIP 1 0 0 0 0 0 +syscon misc N_SMSBLOCK 12 0 0 0 0 0 +syscon misc N_STRIP 4 0 0 0 0 0 +syscon misc N_SYNC_PPP 14 0 0 0 0 0 +syscon misc N_X25 6 0 0 0 0 0 + +syscon misc BLKTYPE 52 52 52 52 52 0 # unix consensus +syscon misc BLKBSZGET 0x80081270 0 0 0 0 0 +syscon misc BLKBSZSET 0x40081271 0 0 0 0 0 +syscon misc BLKFLSBUF 0x1261 0 0 0 0 0 +syscon misc BLKFRAGET 0x1265 0 0 0 0 0 +syscon misc BLKFRASET 0x1264 0 0 0 0 0 +syscon misc BLKGETSIZE 0x1260 0 0 0 0 0 +syscon misc BLKGETSIZE64 0x80081272 0 0 0 0 0 +syscon misc BLKRAGET 0x1263 0 0 0 0 0 +syscon misc BLKRASET 0x1262 0 0 0 0 0 +syscon misc BLKROGET 0x125e 0 0 0 0 0 +syscon misc BLKROSET 0x125d 0 0 0 0 0 +syscon misc BLKRRPART 0x125f 0 0 0 0 0 +syscon misc BLKSECTGET 0x1267 0 0 0 0 0 +syscon misc BLKSECTSET 0x1266 0 0 0 0 0 +syscon misc BLKSSZGET 0x1268 0 0 0 0 0 + +syscon misc ETH_P_CUST 0x6006 0 0 0 0 0 +syscon misc ETH_P_DDCMP 6 0 0 0 0 0 +syscon misc ETH_P_DEC 0x6000 0 0 0 0 0 +syscon misc ETH_P_DIAG 0x6005 0 0 0 0 0 +syscon misc ETH_P_DNA_DL 0x6001 0 0 0 0 0 +syscon misc ETH_P_DNA_RC 0x6002 0 0 0 0 0 +syscon misc ETH_P_DNA_RT 0x6003 0 0 0 0 0 +syscon misc ETH_P_IEEE802154 246 0 0 0 0 0 +syscon misc ETH_P_LAT 0x6004 0 0 0 0 0 +syscon misc ETH_P_LOCALTALK 9 0 0 0 0 0 +syscon misc ETH_P_PPP_MP 8 0 0 0 0 0 +syscon misc ETH_P_RARP 0x8035 0 0 0 0 0 +syscon misc ETH_P_SCA 0x6007 0 0 0 0 0 +syscon misc ETH_P_WAN_PPP 7 0 0 0 0 0 + +syscon scsi SCSI_IOCTL_BENCHMARK_COMMAND 3 0 0 0 0 0 +syscon scsi SCSI_IOCTL_DOORLOCK 0x5380 0 0 0 0 0 +syscon scsi SCSI_IOCTL_DOORUNLOCK 0x5381 0 0 0 0 0 +syscon scsi SCSI_IOCTL_GET_BUS_NUMBER 0x5386 0 0 0 0 0 +syscon scsi SCSI_IOCTL_GET_IDLUN 0x5382 0 0 0 0 0 +syscon scsi SCSI_IOCTL_PROBE_HOST 0x5385 0 0 0 0 0 +syscon scsi SCSI_IOCTL_SEND_COMMAND 1 0 0 0 0 0 +syscon scsi SCSI_IOCTL_START_UNIT 5 0 0 0 0 0 +syscon scsi SCSI_IOCTL_STOP_UNIT 6 0 0 0 0 0 +syscon scsi SCSI_IOCTL_SYNC 4 0 0 0 0 0 +syscon scsi SCSI_IOCTL_TAGGED_DISABLE 0x5384 0 0 0 0 0 +syscon scsi SCSI_IOCTL_TAGGED_ENABLE 0x5383 0 0 0 0 0 +syscon scsi SCSI_IOCTL_TEST_UNIT_READY 2 0 0 0 0 0 +syscon scsi BUS_DEVICE_RESET 12 0 0 0 0 0 # SIGBUS; +syscon scsi READ_10 40 0 0 0 0 0 +syscon scsi READ_12 168 0 0 0 0 0 +syscon scsi READ_6 8 0 0 0 0 0 +syscon scsi READ_BLOCK_LIMITS 5 0 0 0 0 0 +syscon scsi READ_BUFFER 60 0 0 0 0 0 +syscon scsi READ_CAPACITY 37 0 0 0 0 0 +syscon scsi READ_DEFECT_DATA 55 0 0 0 0 0 +syscon scsi READ_ELEMENT_STATUS 184 0 0 0 0 0 +syscon scsi READ_LONG 62 0 0 0 0 0 +syscon scsi READ_POSITION 52 0 0 0 0 0 +syscon scsi READ_REVERSE 15 0 0 0 0 0 +syscon scsi READ_TOC 67 0 0 0 0 0 +syscon scsi WRITE_10 42 0 0 0 0 0 +syscon scsi WRITE_12 170 0 0 0 0 0 +syscon scsi WRITE_6 10 0 0 0 0 0 +syscon scsi WRITE_BUFFER 59 0 0 0 0 0 +syscon scsi WRITE_FILEMARKS 0x10 0 0 0 0 0 +syscon scsi WRITE_LONG 63 0 0 0 0 0 +syscon scsi WRITE_LONG_2 234 0 0 0 0 0 +syscon scsi WRITE_SAME 65 0 0 0 0 0 +syscon scsi WRITE_VERIFY 46 0 0 0 0 0 +syscon scsi WRITE_VERIFY_12 174 0 0 0 0 0 + +syscon log LOG_EMERG 0 0 0 0 0 0 # consensus +syscon log LOG_KERN 0 0 0 0 0 0 # consensus +syscon log LOG_ALERT 1 1 1 1 1 1 # unix consensus +syscon log LOG_PID 1 1 1 1 1 1 # unix consensus +syscon log LOG_CONS 2 2 2 2 2 2 # unix consensus +syscon log LOG_CRIT 2 2 2 2 2 2 # unix consensus +syscon log LOG_ERR 3 3 3 3 3 3 # unix consensus +syscon log LOG_ODELAY 4 4 4 4 4 4 # unix consensus +syscon log LOG_WARNING 4 4 4 4 4 4 # unix consensus +syscon log LOG_NOTICE 5 5 5 5 5 5 # unix consensus +syscon log LOG_INFO 6 6 6 6 6 6 # unix consensus +syscon log LOG_DEBUG 7 7 7 7 7 7 # unix consensus +syscon log LOG_PRIMASK 7 7 7 7 7 7 # unix consensus +syscon log LOG_NDELAY 8 8 8 8 8 8 # unix consensus +syscon log LOG_USER 8 8 8 8 8 8 # unix consensus +syscon log LOG_MAIL 0x10 0x10 0x10 0x10 0x10 0x10 # unix consensus +syscon log LOG_NOWAIT 0x10 0x10 0x10 0x10 0x10 0x10 # unix consensus +syscon log LOG_DAEMON 24 24 24 24 24 24 # unix consensus +syscon log LOG_NFACILITIES 24 25 24 24 24 24 +syscon log LOG_AUTH 0x20 0x20 0x20 0x20 0x20 0x20 # unix consensus +syscon log LOG_PERROR 0x20 0x20 0x20 0x20 0x20 0x20 # unix consensus +syscon log LOG_SYSLOG 40 40 40 40 40 40 # unix consensus +syscon log LOG_LPR 48 48 48 48 48 48 # unix consensus +syscon log LOG_NEWS 56 56 56 56 56 56 # unix consensus +syscon log LOG_UUCP 0x40 0x40 0x40 0x40 0x40 40 # unix consensus +syscon log LOG_CRON 72 72 72 72 72 72 # unix consensus +syscon log LOG_SELECT 76 0 0 0 0 0 +syscon log LOG_SENSE 77 0 0 0 0 0 +syscon log LOG_LOCAL0 0x80 0x80 0x80 0x80 0x80 0x80 # unix consensus +syscon log LOG_LOCAL1 136 136 136 136 136 136 # unix consensus +syscon log LOG_LOCAL2 144 144 144 144 144 144 # unix consensus +syscon log LOG_LOCAL3 152 152 152 152 152 152 # unix consensus +syscon log LOG_LOCAL4 160 160 160 160 160 160 # unix consensus +syscon log LOG_LOCAL5 168 168 168 168 168 168 # unix consensus +syscon log LOG_LOCAL6 176 176 176 176 176 176 # unix consensus +syscon log LOG_LOCAL7 184 184 184 184 184 184 # unix consensus +syscon log LOG_FACMASK 0x03f8 0x03f8 0x03f8 0x03f8 0x03f8 0x03f8 # unix consensus + +syscon sg SG_DXFER_TO_FROM_DEV -4 0 0 0 0 0 +syscon sg SG_DXFER_FROM_DEV -3 0 0 0 0 0 +syscon sg SG_DXFER_TO_DEV -2 0 0 0 0 0 +syscon sg SG_DXFER_NONE -1 0 0 0 0 0 +syscon sg SG_DEF_COMMAND_Q 0 0 0 0 0 0 # consensus +syscon sg SG_DEF_FORCE_LOW_DMA 0 0 0 0 0 0 # consensus +syscon sg SG_DEF_FORCE_PACK_ID 0 0 0 0 0 0 # consensus +syscon sg SG_DEF_KEEP_ORPHAN 0 0 0 0 0 0 # consensus +syscon sg SG_DEF_UNDERRUN_FLAG 0 0 0 0 0 0 # consensus +syscon sg SG_INFO_INDIRECT_IO 0 0 0 0 0 0 # consensus +syscon sg SG_INFO_OK 0 0 0 0 0 0 # consensus +syscon sg SG_SCSI_RESET_NOTHING 0 0 0 0 0 0 # consensus +syscon sg SG_DEFAULT_RETRIES 1 0 0 0 0 0 +syscon sg SG_FLAG_DIRECT_IO 1 0 0 0 0 0 +syscon sg SG_INFO_CHECK 1 0 0 0 0 0 +syscon sg SG_INFO_OK_MASK 1 0 0 0 0 0 +syscon sg SG_SCSI_RESET_DEVICE 1 0 0 0 0 0 +syscon sg SG_FLAG_LUN_INHIBIT 2 0 0 0 0 0 +syscon sg SG_INFO_DIRECT_IO 2 0 0 0 0 0 +syscon sg SG_SCSI_RESET_BUS 2 0 0 0 0 0 +syscon sg SG_SCSI_RESET_HOST 3 0 0 0 0 0 +syscon sg SG_INFO_MIXED_IO 4 0 0 0 0 0 +syscon sg SG_INFO_DIRECT_IO_MASK 6 0 0 0 0 0 +syscon misc VOLUME_OVERFLOW 13 0 0 0 0 0 +syscon sg SG_MAX_QUEUE 0x10 0 0 0 0 0 +syscon sg SG_MAX_SENSE 0x10 0 0 0 0 0 +syscon sg SG_DEFAULT_TIMEOUT 0x1770 0 0 0 0 0 +syscon sg SG_SET_TIMEOUT 0x2201 0 0 0 0 0 +syscon sg SG_GET_TIMEOUT 0x2202 0 0 0 0 0 +syscon sg SG_EMULATED_HOST 0x2203 0 0 0 0 0 +syscon sg SG_SET_TRANSFORM 0x2204 0 0 0 0 0 +syscon sg SG_GET_TRANSFORM 0x2205 0 0 0 0 0 +syscon sg SG_GET_COMMAND_Q 0x2270 0 0 0 0 0 +syscon sg SG_SET_COMMAND_Q 0x2271 0 0 0 0 0 +syscon sg SG_GET_RESERVED_SIZE 0x2272 0 0 0 0 0 +syscon sg SG_SET_RESERVED_SIZE 0x2275 0 0 0 0 0 +syscon sg SG_GET_SCSI_ID 0x2276 0 0 0 0 0 +syscon sg SG_SET_FORCE_LOW_DMA 0x2279 0 0 0 0 0 +syscon sg SG_GET_LOW_DMA 0x227a 0 0 0 0 0 +syscon sg SG_SET_FORCE_PACK_ID 0x227b 0 0 0 0 0 +syscon sg SG_GET_PACK_ID 0x227c 0 0 0 0 0 +syscon sg SG_GET_NUM_WAITING 0x227d 0 0 0 0 0 +syscon sg SG_SET_DEBUG 0x227e 0 0 0 0 0 +syscon sg SG_GET_SG_TABLESIZE 0x227f 0 0 0 0 0 +syscon sg SG_GET_VERSION_NUM 0x2282 0 0 0 0 0 +syscon sg SG_NEXT_CMD_LEN 0x2283 0 0 0 0 0 +syscon sg SG_SCSI_RESET 0x2284 0 0 0 0 0 +syscon sg SG_IO 0x2285 0 0 0 0 0 +syscon sg SG_GET_REQUEST_TABLE 0x2286 0 0 0 0 0 +syscon sg SG_SET_KEEP_ORPHAN 0x2287 0 0 0 0 0 +syscon sg SG_GET_KEEP_ORPHAN 0x2288 0 0 0 0 0 +syscon sg SG_BIG_BUFF 0x8000 0 0 0 0 0 +syscon sg SG_DEF_RESERVED_SIZE 0x8000 0 0 0 0 0 +syscon sg SG_SCATTER_SZ 0x8000 0 0 0 0 0 +syscon sg SG_FLAG_NO_DXFER 0x010000 0 0 0 0 0 + # https://youtu.be/GUQUD3IMbb4?t=85 diff --git a/libc/sysv/consts/AI_ADDRCONFIG.S b/libc/sysv/consts/AI_ADDRCONFIG.S deleted file mode 100644 index 50088414..00000000 --- a/libc/sysv/consts/AI_ADDRCONFIG.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon gai,AI_ADDRCONFIG,0x20,0x0400,0x0400,0x40,0x40,0x0400 diff --git a/libc/sysv/consts/AI_ALL.S b/libc/sysv/consts/AI_ALL.S deleted file mode 100644 index 2193f2ef..00000000 --- a/libc/sysv/consts/AI_ALL.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon gai,AI_ALL,0x10,0x0100,0x0100,0,0,0x0100 diff --git a/libc/sysv/consts/AI_CANONNAME.S b/libc/sysv/consts/AI_CANONNAME.S deleted file mode 100644 index 6639a8f2..00000000 --- a/libc/sysv/consts/AI_CANONNAME.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon gai,AI_CANONNAME,2,2,2,2,2,2 diff --git a/libc/sysv/consts/AI_NUMERICHOST.S b/libc/sysv/consts/AI_NUMERICHOST.S deleted file mode 100644 index 08404d17..00000000 --- a/libc/sysv/consts/AI_NUMERICHOST.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon gai,AI_NUMERICHOST,4,4,4,4,4,4 diff --git a/libc/sysv/consts/AI_NUMERICSERV.S b/libc/sysv/consts/AI_NUMERICSERV.S deleted file mode 100644 index f93e42cf..00000000 --- a/libc/sysv/consts/AI_NUMERICSERV.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon gai,AI_NUMERICSERV,0x0400,0x1000,8,0x10,0x10,8 diff --git a/libc/sysv/consts/AI_PASSIVE.S b/libc/sysv/consts/AI_PASSIVE.S deleted file mode 100644 index fd32e171..00000000 --- a/libc/sysv/consts/AI_PASSIVE.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon gai,AI_PASSIVE,1,1,1,1,1,1 diff --git a/libc/sysv/consts/AI_V4MAPPED.S b/libc/sysv/consts/AI_V4MAPPED.S deleted file mode 100644 index 08122a1b..00000000 --- a/libc/sysv/consts/AI_V4MAPPED.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon gai,AI_V4MAPPED,8,0x0800,0x0800,0,0,0x0800 diff --git a/libc/sysv/consts/BIG_ENDIAN.S b/libc/sysv/consts/BIG_ENDIAN.S deleted file mode 100644 index 8e37ec0a..00000000 --- a/libc/sysv/consts/BIG_ENDIAN.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,BIG_ENDIAN,0x10e1,0x10e1,0x10e1,0x10e1,0x10e1,0 diff --git a/libc/sysv/consts/BLK_BYTECOUNT.S b/libc/sysv/consts/BLK_BYTECOUNT.S deleted file mode 100644 index 848166f5..00000000 --- a/libc/sysv/consts/BLK_BYTECOUNT.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,BLK_BYTECOUNT,2,2,2,2,2,0 diff --git a/libc/sysv/consts/BLK_EOF.S b/libc/sysv/consts/BLK_EOF.S deleted file mode 100644 index 9d9439db..00000000 --- a/libc/sysv/consts/BLK_EOF.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,BLK_EOF,0x40,0x40,0x40,0x40,0x40,0 diff --git a/libc/sysv/consts/BLK_EOR.S b/libc/sysv/consts/BLK_EOR.S deleted file mode 100644 index 1acd0dfe..00000000 --- a/libc/sysv/consts/BLK_EOR.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,BLK_EOR,0x80,0x80,0x80,0x80,0x80,0 diff --git a/libc/sysv/consts/BLK_ERRORS.S b/libc/sysv/consts/BLK_ERRORS.S deleted file mode 100644 index 34b41a25..00000000 --- a/libc/sysv/consts/BLK_ERRORS.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,BLK_ERRORS,0x20,0x20,0x20,0x20,0x20,0 diff --git a/libc/sysv/consts/BLK_RESTART.S b/libc/sysv/consts/BLK_RESTART.S deleted file mode 100644 index 75cdc463..00000000 --- a/libc/sysv/consts/BLK_RESTART.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,BLK_RESTART,0x10,0x10,0x10,0x10,0x10,0 diff --git a/libc/sysv/consts/BUS_DEVICE_RESET.S b/libc/sysv/consts/BUS_DEVICE_RESET.S index 1d56d622..0e33b317 100644 --- a/libc/sysv/consts/BUS_DEVICE_RESET.S +++ b/libc/sysv/consts/BUS_DEVICE_RESET.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,BUS_DEVICE_RESET,12,0,0,0,0,0 +.syscon scsi,BUS_DEVICE_RESET,12,0,0,0,0,0 diff --git a/libc/sysv/consts/CR0.S b/libc/sysv/consts/CR0.S index 79e096b2..02c2e947 100644 --- a/libc/sysv/consts/CR0.S +++ b/libc/sysv/consts/CR0.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,CR0,0b0000000000000000,0b000000000000000000,0b000000000000000000,0x0,0x0,0b0000000000000000 +.syscon termios,CR0,0b0000000000000000,0b000000000000000000,0b000000000000000000,0,0b000000000000000000,0b0000000000000000 diff --git a/libc/sysv/consts/CR1.S b/libc/sysv/consts/CR1.S index 49059cb7..480913c8 100644 --- a/libc/sysv/consts/CR1.S +++ b/libc/sysv/consts/CR1.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,CR1,0b0000001000000000,0b000001000000000000,0b000001000000000000,0x0,0x0,0b0000001000000000 +.syscon termios,CR1,0b0000001000000000,0b000001000000000000,0b000001000000000000,0,0b000001000000000000,0b0000001000000000 diff --git a/libc/sysv/consts/CR2.S b/libc/sysv/consts/CR2.S index dbdc665b..bb27c694 100644 --- a/libc/sysv/consts/CR2.S +++ b/libc/sysv/consts/CR2.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,CR2,0b0000010000000000,0b000010000000000000,0b000010000000000000,0x0,0x0,0b0000010000000000 +.syscon termios,CR2,0b0000010000000000,0b000010000000000000,0b000010000000000000,0,0b000000010000000000,0b0000010000000000 diff --git a/libc/sysv/consts/CR3.S b/libc/sysv/consts/CR3.S index 3cebe9dc..5e65c9fe 100644 --- a/libc/sysv/consts/CR3.S +++ b/libc/sysv/consts/CR3.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,CR3,0b0000011000000000,0b000011000000000000,0b000011000000000000,0x0,0x0,0b0000011000000000 +.syscon termios,CR3,0b0000011000000000,0b000011000000000000,0b000011000000000000,0,0b000000011000000000,0b0000011000000000 diff --git a/libc/sysv/consts/EBADFD.S b/libc/sysv/consts/EBADFD.S index 3d23845e..45199857 100644 --- a/libc/sysv/consts/EBADFD.S +++ b/libc/sysv/consts/EBADFD.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon junkerr,EBADFD,77,9,9,9,9,6 +.syscon junkerr,EBADFD,77,9,0,0,0,0 diff --git a/libc/sysv/consts/EMEDIUMTYPE.S b/libc/sysv/consts/EMEDIUMTYPE.S index 488841a6..e2397891 100644 --- a/libc/sysv/consts/EMEDIUMTYPE.S +++ b/libc/sysv/consts/EMEDIUMTYPE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon junkerr,EMEDIUMTYPE,124,0,0,86,86,0 +.syscon errno,EMEDIUMTYPE,124,0,0,86,0,0 diff --git a/libc/sysv/consts/EMPTY.S b/libc/sysv/consts/EMPTY.S index 26cd5eb8..5a9295f0 100644 --- a/libc/sysv/consts/EMPTY.S +++ b/libc/sysv/consts/EMPTY.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,EMPTY,0,0,0,0,0,0 +.syscon termios,EMPTY,0,0,0,0,0,0 diff --git a/libc/sysv/consts/EMULTIHOP.S b/libc/sysv/consts/EMULTIHOP.S index cfff27b7..434e7875 100644 --- a/libc/sysv/consts/EMULTIHOP.S +++ b/libc/sysv/consts/EMULTIHOP.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon junkerr,EMULTIHOP,72,95,90,0,94,0 +.syscon errno,EMULTIHOP,72,95,90,0,94,0 diff --git a/libc/sysv/consts/ENODATA.S b/libc/sysv/consts/ENODATA.S index c406f9ae..e9b938bb 100644 --- a/libc/sysv/consts/ENODATA.S +++ b/libc/sysv/consts/ENODATA.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon junkerr,ENODATA,61,96,0,0,89,0 +.syscon errno,ENODATA,61,96,0,0,89,0 diff --git a/libc/sysv/consts/ENOLINK.S b/libc/sysv/consts/ENOLINK.S index 9d890098..875ea6b1 100644 --- a/libc/sysv/consts/ENOLINK.S +++ b/libc/sysv/consts/ENOLINK.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon junkerr,ENOLINK,67,97,91,0,95,0 +.syscon errno,ENOLINK,67,97,91,0,95,0 diff --git a/libc/sysv/consts/ENOMEDIUM.S b/libc/sysv/consts/ENOMEDIUM.S index 7243999b..e7125df4 100644 --- a/libc/sysv/consts/ENOMEDIUM.S +++ b/libc/sysv/consts/ENOMEDIUM.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon junkerr,ENOMEDIUM,123,0,0,85,85,0 +.syscon errno,ENOMEDIUM,123,0,0,85,0,0 diff --git a/libc/sysv/consts/ENOSR.S b/libc/sysv/consts/ENOSR.S index ea4d91cf..6dde58df 100644 --- a/libc/sysv/consts/ENOSR.S +++ b/libc/sysv/consts/ENOSR.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon junkerr,ENOSR,63,98,0,0,90,0 +.syscon errno,ENOSR,63,98,0,90,90,0 diff --git a/libc/sysv/consts/ENOSTR.S b/libc/sysv/consts/ENOSTR.S index 9dde5727..749624fa 100644 --- a/libc/sysv/consts/ENOSTR.S +++ b/libc/sysv/consts/ENOSTR.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon junkerr,ENOSTR,60,99,0,0,91,0 +.syscon errno,ENOSTR,60,99,0,0,91,0 diff --git a/libc/sysv/consts/ERA.S b/libc/sysv/consts/ERA.S index 59abd10c..b356dc91 100644 --- a/libc/sysv/consts/ERA.S +++ b/libc/sysv/consts/ERA.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ERA,0x02002c,45,45,0,0,0 +.syscon termios,ERA,0x02002c,45,45,0,0,0 diff --git a/libc/sysv/consts/ERESTART.S b/libc/sysv/consts/ERESTART.S index 646d27df..8cd52c1b 100644 --- a/libc/sysv/consts/ERESTART.S +++ b/libc/sysv/consts/ERESTART.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon errno,ERESTART,85,0,0,0,-3,0 +.syscon errno,ERESTART,85,-1,-1,-1,-3,0 diff --git a/libc/sysv/consts/EXTA.S b/libc/sysv/consts/EXTA.S index 802c182c..9c56df55 100644 --- a/libc/sysv/consts/EXTA.S +++ b/libc/sysv/consts/EXTA.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,EXTA,14,0x4b00,0x4b00,0x4b00,0x4b00,0 +.syscon termios,EXTA,14,0x4b00,0x4b00,0x4b00,0x4b00,0 diff --git a/libc/sysv/consts/EXTB.S b/libc/sysv/consts/EXTB.S index 5177cf47..82b0ece7 100644 --- a/libc/sysv/consts/EXTB.S +++ b/libc/sysv/consts/EXTB.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,EXTB,15,0x9600,0x9600,0x9600,0x9600,0 +.syscon termios,EXTB,15,0x9600,0x9600,0x9600,0x9600,0 diff --git a/libc/sysv/consts/F_GETLK.S b/libc/sysv/consts/F_GETLK.S index 1dd0b999..47419280 100644 --- a/libc/sysv/consts/F_GETLK.S +++ b/libc/sysv/consts/F_GETLK.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon fcntl,F_GETLK,5,7,11,7,7,0 +.syscon fcntl,F_GETLK,5,7,11,7,7,5 diff --git a/libc/sysv/consts/F_GETLK64.S b/libc/sysv/consts/F_GETLK64.S index 6d2fcfee..b4a57a90 100644 --- a/libc/sysv/consts/F_GETLK64.S +++ b/libc/sysv/consts/F_GETLK64.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon fcntl,F_GETLK64,5,0,0,0,0,0 +.syscon compat,F_GETLK64,5,7,11,7,7,5 diff --git a/libc/sysv/consts/F_SETLK.S b/libc/sysv/consts/F_SETLK.S index a229d718..6f4ec8b2 100644 --- a/libc/sysv/consts/F_SETLK.S +++ b/libc/sysv/consts/F_SETLK.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon fcntl,F_SETLK,6,8,12,8,8,0 +.syscon fcntl,F_SETLK,6,8,12,8,8,6 diff --git a/libc/sysv/consts/F_SETLK64.S b/libc/sysv/consts/F_SETLK64.S index 7aa99996..0747c5ae 100644 --- a/libc/sysv/consts/F_SETLK64.S +++ b/libc/sysv/consts/F_SETLK64.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon fcntl,F_SETLK64,6,0,0,0,0,0 +.syscon compat,F_SETLK64,6,8,12,8,8,6 diff --git a/libc/sysv/consts/F_SETLKW.S b/libc/sysv/consts/F_SETLKW.S index 48896c36..04293372 100644 --- a/libc/sysv/consts/F_SETLKW.S +++ b/libc/sysv/consts/F_SETLKW.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon fcntl,F_SETLKW,7,9,13,9,9,0 +.syscon fcntl,F_SETLKW,7,9,13,9,9,7 diff --git a/libc/sysv/consts/F_SETLKW64.S b/libc/sysv/consts/F_SETLKW64.S index 31dca8a6..569ba2b7 100644 --- a/libc/sysv/consts/F_SETLKW64.S +++ b/libc/sysv/consts/F_SETLKW64.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon fcntl,F_SETLKW64,7,0,0,0,0,0 +.syscon compat,F_SETLKW64,7,9,13,9,9,7 diff --git a/libc/sysv/consts/F_UNLCK.S b/libc/sysv/consts/F_UNLCK.S index 5811e422..6e40c08f 100644 --- a/libc/sysv/consts/F_UNLCK.S +++ b/libc/sysv/consts/F_UNLCK.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon fcntl,F_UNLCK,2,2,2,2,2,0 +.syscon fcntl,F_UNLCK,2,2,2,2,2,2 diff --git a/libc/sysv/consts/F_WRLCK.S b/libc/sysv/consts/F_WRLCK.S index 6f0aa3d8..bf409837 100644 --- a/libc/sysv/consts/F_WRLCK.S +++ b/libc/sysv/consts/F_WRLCK.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon fcntl,F_WRLCK,1,3,3,3,3,0 +.syscon fcntl,F_WRLCK,1,3,3,3,3,1 diff --git a/libc/sysv/consts/INADDR_ALLHOSTS_GROUP.S b/libc/sysv/consts/INADDR_ALLHOSTS_GROUP.S deleted file mode 100644 index 44972e02..00000000 --- a/libc/sysv/consts/INADDR_ALLHOSTS_GROUP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,INADDR_ALLHOSTS_GROUP,0xe0000001,0xe0000001,0xe0000001,0xe0000001,0xe0000001,0 diff --git a/libc/sysv/consts/INADDR_ALLRTRS_GROUP.S b/libc/sysv/consts/INADDR_ALLRTRS_GROUP.S deleted file mode 100644 index 1685edf3..00000000 --- a/libc/sysv/consts/INADDR_ALLRTRS_GROUP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,INADDR_ALLRTRS_GROUP,0xe0000002,0xe0000002,0xe0000002,0,0,0 diff --git a/libc/sysv/consts/INADDR_ANY.S b/libc/sysv/consts/INADDR_ANY.S deleted file mode 100644 index 0c073177..00000000 --- a/libc/sysv/consts/INADDR_ANY.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,INADDR_ANY,0,0,0,0,0,0 diff --git a/libc/sysv/consts/INADDR_BROADCAST.S b/libc/sysv/consts/INADDR_BROADCAST.S deleted file mode 100644 index 44147bdc..00000000 --- a/libc/sysv/consts/INADDR_BROADCAST.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,INADDR_BROADCAST,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff diff --git a/libc/sysv/consts/INADDR_LOOPBACK.S b/libc/sysv/consts/INADDR_LOOPBACK.S deleted file mode 100644 index 035b6dcf..00000000 --- a/libc/sysv/consts/INADDR_LOOPBACK.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,INADDR_LOOPBACK,0x7f000001,0x7f000001,0x7f000001,0x7f000001,0x7f000001,0x7f000001 diff --git a/libc/sysv/consts/INADDR_MAX_LOCAL_GROUP.S b/libc/sysv/consts/INADDR_MAX_LOCAL_GROUP.S deleted file mode 100644 index dc6a9b1c..00000000 --- a/libc/sysv/consts/INADDR_MAX_LOCAL_GROUP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,INADDR_MAX_LOCAL_GROUP,0xe00000ff,0xe00000ff,0xe00000ff,0xe00000ff,0xe00000ff,0 diff --git a/libc/sysv/consts/INADDR_NONE.S b/libc/sysv/consts/INADDR_NONE.S deleted file mode 100644 index 7add7365..00000000 --- a/libc/sysv/consts/INADDR_NONE.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,INADDR_NONE,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff diff --git a/libc/sysv/consts/INADDR_UNSPEC_GROUP.S b/libc/sysv/consts/INADDR_UNSPEC_GROUP.S deleted file mode 100644 index b9533448..00000000 --- a/libc/sysv/consts/INADDR_UNSPEC_GROUP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,INADDR_UNSPEC_GROUP,0xe0000000,0xe0000000,0xe0000000,0xe0000000,0xe0000000,0 diff --git a/libc/sysv/consts/IUCLC.S b/libc/sysv/consts/IUCLC.S index d6e17f9c..a65687f6 100644 --- a/libc/sysv/consts/IUCLC.S +++ b/libc/sysv/consts/IUCLC.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,IUCLC,0b0000001000000000,0,0,0b0001000000000000,0b0001000000000000,0b0000001000000000 +.syscon termios,IUCLC,0b0000001000000000,0,0,0b0001000000000000,0,0b0000001000000000 diff --git a/libc/sysv/consts/LITTLE_ENDIAN.S b/libc/sysv/consts/LITTLE_ENDIAN.S deleted file mode 100644 index 0999effa..00000000 --- a/libc/sysv/consts/LITTLE_ENDIAN.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,LITTLE_ENDIAN,0x04d2,0x04d2,0x04d2,0x04d2,0x04d2,0 diff --git a/libc/sysv/consts/MAP_CONCEAL.S b/libc/sysv/consts/MAP_CONCEAL.S index 8b4b4987..8077b179 100644 --- a/libc/sysv/consts/MAP_CONCEAL.S +++ b/libc/sysv/consts/MAP_CONCEAL.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon mmap,MAP_CONCEAL,0,0,0x20000,0x8000,0x8000,0 +.syscon mmap,MAP_CONCEAL,0,0,0,0x8000,0,0 diff --git a/libc/sysv/consts/MAP_TYPE.S b/libc/sysv/consts/MAP_TYPE.S index 8b2daa23..d530757e 100644 --- a/libc/sysv/consts/MAP_TYPE.S +++ b/libc/sysv/consts/MAP_TYPE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon mmap,MAP_TYPE,15,0,0,0,0,0 +.syscon mmap,MAP_TYPE,15,15,15,15,15,15 diff --git a/libc/sysv/consts/MODE_B.S b/libc/sysv/consts/MODE_B.S deleted file mode 100644 index 7385006b..00000000 --- a/libc/sysv/consts/MODE_B.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,MODE_B,2,2,2,2,2,0 diff --git a/libc/sysv/consts/MODE_C.S b/libc/sysv/consts/MODE_C.S deleted file mode 100644 index 8b01e205..00000000 --- a/libc/sysv/consts/MODE_C.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,MODE_C,3,3,3,3,3,0 diff --git a/libc/sysv/consts/MODE_S.S b/libc/sysv/consts/MODE_S.S deleted file mode 100644 index 80a10d82..00000000 --- a/libc/sysv/consts/MODE_S.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,MODE_S,1,1,1,1,1,0 diff --git a/libc/sysv/consts/MODE_SELECT.S b/libc/sysv/consts/MODE_SELECT.S deleted file mode 100644 index 3521ec2b..00000000 --- a/libc/sysv/consts/MODE_SELECT.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,MODE_SELECT,21,0,0,0,0,0 diff --git a/libc/sysv/consts/MODE_SELECT_10.S b/libc/sysv/consts/MODE_SELECT_10.S deleted file mode 100644 index 72200e6c..00000000 --- a/libc/sysv/consts/MODE_SELECT_10.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,MODE_SELECT_10,85,0,0,0,0,0 diff --git a/libc/sysv/consts/MODE_SENSE.S b/libc/sysv/consts/MODE_SENSE.S deleted file mode 100644 index 40108da5..00000000 --- a/libc/sysv/consts/MODE_SENSE.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,MODE_SENSE,26,0,0,0,0,0 diff --git a/libc/sysv/consts/MODE_SENSE_10.S b/libc/sysv/consts/MODE_SENSE_10.S deleted file mode 100644 index ca1fd682..00000000 --- a/libc/sysv/consts/MODE_SENSE_10.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,MODE_SENSE_10,90,0,0,0,0,0 diff --git a/libc/sysv/consts/NL0.S b/libc/sysv/consts/NL0.S index 073fa6c8..5d667bfd 100644 --- a/libc/sysv/consts/NL0.S +++ b/libc/sysv/consts/NL0.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,NL0,0b0000000000000000,0b000000000000000000,0b000000000000000000,0,0,0b0000000000000000 +.syscon termios,NL0,0b0000000000000000,0b000000000000000000,0b000000000000000000,0,0b000000000000000000,0b0000000000000000 diff --git a/libc/sysv/consts/NL1.S b/libc/sysv/consts/NL1.S index e63bb35c..c2d164ed 100644 --- a/libc/sysv/consts/NL1.S +++ b/libc/sysv/consts/NL1.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,NL1,0b0000000100000000,0b000000000100000000,0b000000000100000000,0,0,0b0000000100000000 +.syscon termios,NL1,0b0000000100000000,0b000000000100000000,0b000000000100000000,0,0b000000000100000000,0b0000000100000000 diff --git a/libc/sysv/consts/NL2.S b/libc/sysv/consts/NL2.S index 8407a6ac..38a53630 100644 --- a/libc/sysv/consts/NL2.S +++ b/libc/sysv/consts/NL2.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,NL2,0,0b000000001000000000,0b000000001000000000,0,0,0 +.syscon termios,NL2,0,0b000000001000000000,0b000000001000000000,0,0b000000001000000000,0 diff --git a/libc/sysv/consts/NL3.S b/libc/sysv/consts/NL3.S index 1f9e92ae..6bd74840 100644 --- a/libc/sysv/consts/NL3.S +++ b/libc/sysv/consts/NL3.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,NL3,0,0b000000001100000000,0b000000001100000000,0,0,0 +.syscon termios,NL3,0,0b000000001100000000,0b000000001100000000,0,0b000000001100000000,0 diff --git a/libc/sysv/consts/OLCUC.S b/libc/sysv/consts/OLCUC.S index 8122a71d..9a644b4a 100644 --- a/libc/sysv/consts/OLCUC.S +++ b/libc/sysv/consts/OLCUC.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,OLCUC,0b0000000000000010,0b000000000000000000,0,0b0000000000100000,0b0000000000100000,0b0000000000000010 +.syscon termios,OLCUC,0b0000000000000010,0,0,0b0000000000100000,0,0b0000000000000010 diff --git a/libc/sysv/consts/O_APPEND.S b/libc/sysv/consts/O_APPEND.S index 11f5843f..ee7a00db 100644 --- a/libc/sysv/consts/O_APPEND.S +++ b/libc/sysv/consts/O_APPEND.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_APPEND,0x0400,8,8,8,8,0x00000004 +.syscon open,O_APPEND,0x00000400,8,8,8,8,0x00000004 diff --git a/libc/sysv/consts/O_ASYNC.S b/libc/sysv/consts/O_ASYNC.S index 6e7067b7..63cbb6d9 100644 --- a/libc/sysv/consts/O_ASYNC.S +++ b/libc/sysv/consts/O_ASYNC.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_ASYNC,0x2000,0x40,0x40,0x40,0x40,0 +.syscon open,O_ASYNC,0x00002000,0x00000040,0x00000040,0x00000040,0x00000040,0 diff --git a/libc/sysv/consts/O_CLOEXEC.S b/libc/sysv/consts/O_CLOEXEC.S index 828eab06..77de11e3 100644 --- a/libc/sysv/consts/O_CLOEXEC.S +++ b/libc/sysv/consts/O_CLOEXEC.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_CLOEXEC,0x080000,0x01000000,0x100000,0x010000,0x400000,0x00080000 +.syscon open,O_CLOEXEC,0x00080000,0x01000000,0x00100000,0x00010000,0x00400000,0x00080000 diff --git a/libc/sysv/consts/O_CREAT.S b/libc/sysv/consts/O_CREAT.S index ca37ec69..9924d1ec 100644 --- a/libc/sysv/consts/O_CREAT.S +++ b/libc/sysv/consts/O_CREAT.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_CREAT,0x40,0x0200,0x0200,0x0200,0x0200,0x00000040 +.syscon open,O_CREAT,0x00000040,0x00000200,0x00000200,0x00000200,0x00000200,0x00000040 diff --git a/libc/sysv/consts/O_DIRECT.S b/libc/sysv/consts/O_DIRECT.S index 65395064..f9be1eb9 100644 --- a/libc/sysv/consts/O_DIRECT.S +++ b/libc/sysv/consts/O_DIRECT.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_DIRECT,0x4000,0,0x010000,0,0x80000,0x00200000 +.syscon open,O_DIRECT,0x00004000,0,0x00010000,0,0x00080000,0x00200000 diff --git a/libc/sysv/consts/O_DIRECTORY.S b/libc/sysv/consts/O_DIRECTORY.S index 33865aec..00fcac4d 100644 --- a/libc/sysv/consts/O_DIRECTORY.S +++ b/libc/sysv/consts/O_DIRECTORY.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_DIRECTORY,0x010000,0x100000,0x020000,0x020000,0x200000,0x02000000 +.syscon open,O_DIRECTORY,0x00010000,0x00100000,0x00020000,0x00020000,0x00200000,0x02000000 diff --git a/libc/sysv/consts/O_DSYNC.S b/libc/sysv/consts/O_DSYNC.S index 1d55d698..1670c547 100644 --- a/libc/sysv/consts/O_DSYNC.S +++ b/libc/sysv/consts/O_DSYNC.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_DSYNC,0x1000,0x400000,0,0x80,0x10000,0 +.syscon open,O_DSYNC,0x00001000,0x00400000,0,0x00000080,0x00010000,0 diff --git a/libc/sysv/consts/O_EXCL.S b/libc/sysv/consts/O_EXCL.S index 3798997c..07615526 100644 --- a/libc/sysv/consts/O_EXCL.S +++ b/libc/sysv/consts/O_EXCL.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_EXCL,0x80,0x0800,0x0800,0x0800,0x0800,0x00000080 +.syscon open,O_EXCL,0x00000080,0x00000800,0x00000800,0x00000800,0x00000800,0x00000080 diff --git a/libc/sysv/consts/O_EXEC.S b/libc/sysv/consts/O_EXEC.S index 28dadbf8..f8668386 100644 --- a/libc/sysv/consts/O_EXEC.S +++ b/libc/sysv/consts/O_EXEC.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_EXEC,0,0,0x040000,0,0x4000000,0 +.syscon open,O_EXEC,0,0,0x00040000,0,0x04000000,0 diff --git a/libc/sysv/consts/O_NDELAY.S b/libc/sysv/consts/O_NDELAY.S index 4aa12305..bb219105 100644 --- a/libc/sysv/consts/O_NDELAY.S +++ b/libc/sysv/consts/O_NDELAY.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_NDELAY,0x0800,4,4,4,4,0 +.syscon open,O_NDELAY,0x00000800,0x00000004,0x00000004,0x00000004,0x00000004,0x00000800 diff --git a/libc/sysv/consts/O_NOATIME.S b/libc/sysv/consts/O_NOATIME.S index 107d98f6..3ae86dc6 100644 --- a/libc/sysv/consts/O_NOATIME.S +++ b/libc/sysv/consts/O_NOATIME.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_NOATIME,0x040000,0,0,0,0,0 +.syscon open,O_NOATIME,0x00040000,0,0,0,0,0 diff --git a/libc/sysv/consts/O_NOCTTY.S b/libc/sysv/consts/O_NOCTTY.S index 48e72b6f..f6a1df49 100644 --- a/libc/sysv/consts/O_NOCTTY.S +++ b/libc/sysv/consts/O_NOCTTY.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_NOCTTY,0x0100,0x020000,0x8000,0x8000,0x8000,0 +.syscon open,O_NOCTTY,0x00000100,0x00020000,0x00008000,0x00008000,0x00008000,0 diff --git a/libc/sysv/consts/O_NOFOLLOW.S b/libc/sysv/consts/O_NOFOLLOW.S index 242824fe..b0b255d2 100644 --- a/libc/sysv/consts/O_NOFOLLOW.S +++ b/libc/sysv/consts/O_NOFOLLOW.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_NOFOLLOW,0x020000,0x0100,0x0100,0x0100,0x0100,0 +.syscon open,O_NOFOLLOW,0x00020000,0x00000100,0x00000100,0x00000100,0x00000100,0 diff --git a/libc/sysv/consts/O_NONBLOCK.S b/libc/sysv/consts/O_NONBLOCK.S index e62c9728..1ca6b078 100644 --- a/libc/sysv/consts/O_NONBLOCK.S +++ b/libc/sysv/consts/O_NONBLOCK.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_NONBLOCK,0x0800,4,4,4,4,0x00000800 +.syscon open,O_NONBLOCK,0x00000800,0x00000004,0x00000004,0x00000004,0x00000004,0x00000800 diff --git a/libc/sysv/consts/O_PATH.S b/libc/sysv/consts/O_PATH.S index 11af8d8d..d4603a0c 100644 --- a/libc/sysv/consts/O_PATH.S +++ b/libc/sysv/consts/O_PATH.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_PATH,0x200000,0,0,0,0,0 +.syscon open,O_PATH,0x00200000,0,0,0,0,0 diff --git a/libc/sysv/consts/O_RSYNC.S b/libc/sysv/consts/O_RSYNC.S index 891355ee..e412b6b7 100644 --- a/libc/sysv/consts/O_RSYNC.S +++ b/libc/sysv/consts/O_RSYNC.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_RSYNC,0x101000,0,0,0x80,0x20000,0 +.syscon open,O_RSYNC,0x00101000,0,0,0x00000080,0x00020000,0 diff --git a/libc/sysv/consts/O_SYNC.S b/libc/sysv/consts/O_SYNC.S index 4845b58a..fefb1ee2 100644 --- a/libc/sysv/consts/O_SYNC.S +++ b/libc/sysv/consts/O_SYNC.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_SYNC,0x101000,0x80,0x80,0x80,0x80,0 +.syscon open,O_SYNC,0x00101000,0x00000080,0x00000080,0x00000080,0x00000080,0 diff --git a/libc/sysv/consts/O_TMPFILE.S b/libc/sysv/consts/O_TMPFILE.S index 628774f1..3c060605 100644 --- a/libc/sysv/consts/O_TMPFILE.S +++ b/libc/sysv/consts/O_TMPFILE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_TMPFILE,0x410000,0,0,0,0,0x04000100 +.syscon open,O_TMPFILE,0x00410000,0,0,0,0,0x04000100 diff --git a/libc/sysv/consts/O_TRUNC.S b/libc/sysv/consts/O_TRUNC.S index b701802f..c54bfc42 100644 --- a/libc/sysv/consts/O_TRUNC.S +++ b/libc/sysv/consts/O_TRUNC.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_TRUNC,0x0200,0x0400,0x0400,0x0400,0x0400,0x00000200 +.syscon open,O_TRUNC,0x00000200,0x00000400,0x00000400,0x00000400,0x00000400,0x00000200 diff --git a/libc/sysv/consts/O_TTY_INIT.S b/libc/sysv/consts/O_TTY_INIT.S index 470a7568..f5d9281e 100644 --- a/libc/sysv/consts/O_TTY_INIT.S +++ b/libc/sysv/consts/O_TTY_INIT.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon open,O_TTY_INIT,0,0,0x080000,0,0,0 +.syscon open,O_TTY_INIT,0,0,0x00080000,0,0,0 diff --git a/libc/sysv/consts/READ_10.S b/libc/sysv/consts/READ_10.S index 0fb0766c..61042b8e 100644 --- a/libc/sysv/consts/READ_10.S +++ b/libc/sysv/consts/READ_10.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,READ_10,40,0,0,0,0,0 +.syscon scsi,READ_10,40,0,0,0,0,0 diff --git a/libc/sysv/consts/READ_12.S b/libc/sysv/consts/READ_12.S index fa76a110..048ee93e 100644 --- a/libc/sysv/consts/READ_12.S +++ b/libc/sysv/consts/READ_12.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,READ_12,168,0,0,0,0,0 +.syscon scsi,READ_12,168,0,0,0,0,0 diff --git a/libc/sysv/consts/READ_6.S b/libc/sysv/consts/READ_6.S index 6651219b..00dae389 100644 --- a/libc/sysv/consts/READ_6.S +++ b/libc/sysv/consts/READ_6.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,READ_6,8,0,0,0,0,0 +.syscon scsi,READ_6,8,0,0,0,0,0 diff --git a/libc/sysv/consts/READ_BLOCK_LIMITS.S b/libc/sysv/consts/READ_BLOCK_LIMITS.S index 7a3404c4..91b01f5f 100644 --- a/libc/sysv/consts/READ_BLOCK_LIMITS.S +++ b/libc/sysv/consts/READ_BLOCK_LIMITS.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,READ_BLOCK_LIMITS,5,0,0,0,0,0 +.syscon scsi,READ_BLOCK_LIMITS,5,0,0,0,0,0 diff --git a/libc/sysv/consts/READ_BUFFER.S b/libc/sysv/consts/READ_BUFFER.S index 98b75d65..66c0bdf8 100644 --- a/libc/sysv/consts/READ_BUFFER.S +++ b/libc/sysv/consts/READ_BUFFER.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,READ_BUFFER,60,0,0,0,0,0 +.syscon scsi,READ_BUFFER,60,0,0,0,0,0 diff --git a/libc/sysv/consts/READ_CAPACITY.S b/libc/sysv/consts/READ_CAPACITY.S index 93c58e31..6dd06c03 100644 --- a/libc/sysv/consts/READ_CAPACITY.S +++ b/libc/sysv/consts/READ_CAPACITY.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,READ_CAPACITY,37,0,0,0,0,0 +.syscon scsi,READ_CAPACITY,37,0,0,0,0,0 diff --git a/libc/sysv/consts/READ_DEFECT_DATA.S b/libc/sysv/consts/READ_DEFECT_DATA.S index e24c8202..84fb61d8 100644 --- a/libc/sysv/consts/READ_DEFECT_DATA.S +++ b/libc/sysv/consts/READ_DEFECT_DATA.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,READ_DEFECT_DATA,55,0,0,0,0,0 +.syscon scsi,READ_DEFECT_DATA,55,0,0,0,0,0 diff --git a/libc/sysv/consts/READ_ELEMENT_STATUS.S b/libc/sysv/consts/READ_ELEMENT_STATUS.S index 68c3368e..14a56851 100644 --- a/libc/sysv/consts/READ_ELEMENT_STATUS.S +++ b/libc/sysv/consts/READ_ELEMENT_STATUS.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,READ_ELEMENT_STATUS,184,0,0,0,0,0 +.syscon scsi,READ_ELEMENT_STATUS,184,0,0,0,0,0 diff --git a/libc/sysv/consts/READ_LONG.S b/libc/sysv/consts/READ_LONG.S index f5f595aa..7be143b6 100644 --- a/libc/sysv/consts/READ_LONG.S +++ b/libc/sysv/consts/READ_LONG.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,READ_LONG,62,0,0,0,0,0 +.syscon scsi,READ_LONG,62,0,0,0,0,0 diff --git a/libc/sysv/consts/READ_POSITION.S b/libc/sysv/consts/READ_POSITION.S index eb4477af..393cb5ca 100644 --- a/libc/sysv/consts/READ_POSITION.S +++ b/libc/sysv/consts/READ_POSITION.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,READ_POSITION,52,0,0,0,0,0 +.syscon scsi,READ_POSITION,52,0,0,0,0,0 diff --git a/libc/sysv/consts/READ_REVERSE.S b/libc/sysv/consts/READ_REVERSE.S index 6d3c641e..d206e3f6 100644 --- a/libc/sysv/consts/READ_REVERSE.S +++ b/libc/sysv/consts/READ_REVERSE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,READ_REVERSE,15,0,0,0,0,0 +.syscon scsi,READ_REVERSE,15,0,0,0,0,0 diff --git a/libc/sysv/consts/READ_TOC.S b/libc/sysv/consts/READ_TOC.S index ae5e483a..46d1301b 100644 --- a/libc/sysv/consts/READ_TOC.S +++ b/libc/sysv/consts/READ_TOC.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,READ_TOC,67,0,0,0,0,0 +.syscon scsi,READ_TOC,67,0,0,0,0,0 diff --git a/libc/sysv/consts/SCSI_IOCTL_BENCHMARK_COMMAND.S b/libc/sysv/consts/SCSI_IOCTL_BENCHMARK_COMMAND.S index 3676f654..cc60c521 100644 --- a/libc/sysv/consts/SCSI_IOCTL_BENCHMARK_COMMAND.S +++ b/libc/sysv/consts/SCSI_IOCTL_BENCHMARK_COMMAND.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCSI_IOCTL_BENCHMARK_COMMAND,3,0,0,0,0,0 +.syscon scsi,SCSI_IOCTL_BENCHMARK_COMMAND,3,0,0,0,0,0 diff --git a/libc/sysv/consts/SCSI_IOCTL_DOORLOCK.S b/libc/sysv/consts/SCSI_IOCTL_DOORLOCK.S index d799cb12..6b409e87 100644 --- a/libc/sysv/consts/SCSI_IOCTL_DOORLOCK.S +++ b/libc/sysv/consts/SCSI_IOCTL_DOORLOCK.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCSI_IOCTL_DOORLOCK,0x5380,0,0,0,0,0 +.syscon scsi,SCSI_IOCTL_DOORLOCK,0x5380,0,0,0,0,0 diff --git a/libc/sysv/consts/SCSI_IOCTL_DOORUNLOCK.S b/libc/sysv/consts/SCSI_IOCTL_DOORUNLOCK.S index 3454dcad..9aa9d4b6 100644 --- a/libc/sysv/consts/SCSI_IOCTL_DOORUNLOCK.S +++ b/libc/sysv/consts/SCSI_IOCTL_DOORUNLOCK.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCSI_IOCTL_DOORUNLOCK,0x5381,0,0,0,0,0 +.syscon scsi,SCSI_IOCTL_DOORUNLOCK,0x5381,0,0,0,0,0 diff --git a/libc/sysv/consts/SCSI_IOCTL_GET_BUS_NUMBER.S b/libc/sysv/consts/SCSI_IOCTL_GET_BUS_NUMBER.S index 470b22e2..1b96bdc5 100644 --- a/libc/sysv/consts/SCSI_IOCTL_GET_BUS_NUMBER.S +++ b/libc/sysv/consts/SCSI_IOCTL_GET_BUS_NUMBER.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCSI_IOCTL_GET_BUS_NUMBER,0x5386,0,0,0,0,0 +.syscon scsi,SCSI_IOCTL_GET_BUS_NUMBER,0x5386,0,0,0,0,0 diff --git a/libc/sysv/consts/SCSI_IOCTL_GET_IDLUN.S b/libc/sysv/consts/SCSI_IOCTL_GET_IDLUN.S index ddf20bd6..d5d88ee0 100644 --- a/libc/sysv/consts/SCSI_IOCTL_GET_IDLUN.S +++ b/libc/sysv/consts/SCSI_IOCTL_GET_IDLUN.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCSI_IOCTL_GET_IDLUN,0x5382,0,0,0,0,0 +.syscon scsi,SCSI_IOCTL_GET_IDLUN,0x5382,0,0,0,0,0 diff --git a/libc/sysv/consts/SCSI_IOCTL_PROBE_HOST.S b/libc/sysv/consts/SCSI_IOCTL_PROBE_HOST.S index cddb4487..70413e97 100644 --- a/libc/sysv/consts/SCSI_IOCTL_PROBE_HOST.S +++ b/libc/sysv/consts/SCSI_IOCTL_PROBE_HOST.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCSI_IOCTL_PROBE_HOST,0x5385,0,0,0,0,0 +.syscon scsi,SCSI_IOCTL_PROBE_HOST,0x5385,0,0,0,0,0 diff --git a/libc/sysv/consts/SCSI_IOCTL_SEND_COMMAND.S b/libc/sysv/consts/SCSI_IOCTL_SEND_COMMAND.S index 5c87b94e..db838a26 100644 --- a/libc/sysv/consts/SCSI_IOCTL_SEND_COMMAND.S +++ b/libc/sysv/consts/SCSI_IOCTL_SEND_COMMAND.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCSI_IOCTL_SEND_COMMAND,1,0,0,0,0,0 +.syscon scsi,SCSI_IOCTL_SEND_COMMAND,1,0,0,0,0,0 diff --git a/libc/sysv/consts/SCSI_IOCTL_START_UNIT.S b/libc/sysv/consts/SCSI_IOCTL_START_UNIT.S index 48f5002d..b46792db 100644 --- a/libc/sysv/consts/SCSI_IOCTL_START_UNIT.S +++ b/libc/sysv/consts/SCSI_IOCTL_START_UNIT.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCSI_IOCTL_START_UNIT,5,0,0,0,0,0 +.syscon scsi,SCSI_IOCTL_START_UNIT,5,0,0,0,0,0 diff --git a/libc/sysv/consts/SCSI_IOCTL_STOP_UNIT.S b/libc/sysv/consts/SCSI_IOCTL_STOP_UNIT.S index cd516713..5ddc444d 100644 --- a/libc/sysv/consts/SCSI_IOCTL_STOP_UNIT.S +++ b/libc/sysv/consts/SCSI_IOCTL_STOP_UNIT.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCSI_IOCTL_STOP_UNIT,6,0,0,0,0,0 +.syscon scsi,SCSI_IOCTL_STOP_UNIT,6,0,0,0,0,0 diff --git a/libc/sysv/consts/SCSI_IOCTL_SYNC.S b/libc/sysv/consts/SCSI_IOCTL_SYNC.S index bfc87375..d73e8e34 100644 --- a/libc/sysv/consts/SCSI_IOCTL_SYNC.S +++ b/libc/sysv/consts/SCSI_IOCTL_SYNC.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCSI_IOCTL_SYNC,4,0,0,0,0,0 +.syscon scsi,SCSI_IOCTL_SYNC,4,0,0,0,0,0 diff --git a/libc/sysv/consts/SCSI_IOCTL_TAGGED_DISABLE.S b/libc/sysv/consts/SCSI_IOCTL_TAGGED_DISABLE.S index 5058c16d..943f4650 100644 --- a/libc/sysv/consts/SCSI_IOCTL_TAGGED_DISABLE.S +++ b/libc/sysv/consts/SCSI_IOCTL_TAGGED_DISABLE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCSI_IOCTL_TAGGED_DISABLE,0x5384,0,0,0,0,0 +.syscon scsi,SCSI_IOCTL_TAGGED_DISABLE,0x5384,0,0,0,0,0 diff --git a/libc/sysv/consts/SCSI_IOCTL_TAGGED_ENABLE.S b/libc/sysv/consts/SCSI_IOCTL_TAGGED_ENABLE.S index a91bf195..5c3ebf57 100644 --- a/libc/sysv/consts/SCSI_IOCTL_TAGGED_ENABLE.S +++ b/libc/sysv/consts/SCSI_IOCTL_TAGGED_ENABLE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCSI_IOCTL_TAGGED_ENABLE,0x5383,0,0,0,0,0 +.syscon scsi,SCSI_IOCTL_TAGGED_ENABLE,0x5383,0,0,0,0,0 diff --git a/libc/sysv/consts/SCSI_IOCTL_TEST_UNIT_READY.S b/libc/sysv/consts/SCSI_IOCTL_TEST_UNIT_READY.S index 739647d1..eb37c0d1 100644 --- a/libc/sysv/consts/SCSI_IOCTL_TEST_UNIT_READY.S +++ b/libc/sysv/consts/SCSI_IOCTL_TEST_UNIT_READY.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCSI_IOCTL_TEST_UNIT_READY,2,0,0,0,0,0 +.syscon scsi,SCSI_IOCTL_TEST_UNIT_READY,2,0,0,0,0,0 diff --git a/libc/sysv/consts/ST_APPEND.S b/libc/sysv/consts/ST_APPEND.S index 5cf26b7b..99483b6f 100644 --- a/libc/sysv/consts/ST_APPEND.S +++ b/libc/sysv/consts/ST_APPEND.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ST_APPEND,0x0100,0,0,0,0,0 +.syscon statvfs,ST_APPEND,0x0100,0,0,0,0,0 diff --git a/libc/sysv/consts/ST_IMMUTABLE.S b/libc/sysv/consts/ST_IMMUTABLE.S index afa4f897..7eaaf6d5 100644 --- a/libc/sysv/consts/ST_IMMUTABLE.S +++ b/libc/sysv/consts/ST_IMMUTABLE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ST_IMMUTABLE,0x0200,0,0,0,0,0 +.syscon statvfs,ST_IMMUTABLE,0x0200,0,0,0,0,0 diff --git a/libc/sysv/consts/ST_MANDLOCK.S b/libc/sysv/consts/ST_MANDLOCK.S index a45c2a33..e23e806b 100644 --- a/libc/sysv/consts/ST_MANDLOCK.S +++ b/libc/sysv/consts/ST_MANDLOCK.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ST_MANDLOCK,0x40,0,0,0,0,0 +.syscon statvfs,ST_MANDLOCK,0x40,0,0,0,0,0 diff --git a/libc/sysv/consts/ST_NOATIME.S b/libc/sysv/consts/ST_NOATIME.S index 1c4a0aa9..1e4d7b62 100644 --- a/libc/sysv/consts/ST_NOATIME.S +++ b/libc/sysv/consts/ST_NOATIME.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ST_NOATIME,0x0400,0,0,0,0,0 +.syscon statvfs,ST_NOATIME,0x0400,0,0,0,0,0 diff --git a/libc/sysv/consts/ST_NODEV.S b/libc/sysv/consts/ST_NODEV.S index 5afa0a96..7b8b1e93 100644 --- a/libc/sysv/consts/ST_NODEV.S +++ b/libc/sysv/consts/ST_NODEV.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ST_NODEV,4,0,0,0,0,0 +.syscon statvfs,ST_NODEV,4,0,0,0,0,0 diff --git a/libc/sysv/consts/ST_NODIRATIME.S b/libc/sysv/consts/ST_NODIRATIME.S index 25e1e82f..6e0a3e7a 100644 --- a/libc/sysv/consts/ST_NODIRATIME.S +++ b/libc/sysv/consts/ST_NODIRATIME.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ST_NODIRATIME,0x0800,0,0,0,0,0 +.syscon statvfs,ST_NODIRATIME,0x0800,0,0,0,0,0 diff --git a/libc/sysv/consts/ST_NOEXEC.S b/libc/sysv/consts/ST_NOEXEC.S index a55d2b0b..ac55a179 100644 --- a/libc/sysv/consts/ST_NOEXEC.S +++ b/libc/sysv/consts/ST_NOEXEC.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ST_NOEXEC,8,0,0,0,0,0 +.syscon statvfs,ST_NOEXEC,8,0,0,0,0,0 diff --git a/libc/sysv/consts/ST_NOSUID.S b/libc/sysv/consts/ST_NOSUID.S index e6771545..288a22f4 100644 --- a/libc/sysv/consts/ST_NOSUID.S +++ b/libc/sysv/consts/ST_NOSUID.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ST_NOSUID,2,2,2,2,2,0 +.syscon statvfs,ST_NOSUID,2,2,2,2,2,0 diff --git a/libc/sysv/consts/ST_RDONLY.S b/libc/sysv/consts/ST_RDONLY.S index 31a3e122..9d677d2e 100644 --- a/libc/sysv/consts/ST_RDONLY.S +++ b/libc/sysv/consts/ST_RDONLY.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ST_RDONLY,1,1,1,1,1,0 +.syscon statvfs,ST_RDONLY,1,1,1,1,1,0 diff --git a/libc/sysv/consts/ST_RELATIME.S b/libc/sysv/consts/ST_RELATIME.S index 91730ce2..6b075f50 100644 --- a/libc/sysv/consts/ST_RELATIME.S +++ b/libc/sysv/consts/ST_RELATIME.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ST_RELATIME,0x1000,0,0,0,0,0 +.syscon statvfs,ST_RELATIME,0x1000,0,0,0,0,0 diff --git a/libc/sysv/consts/ST_SYNCHRONOUS.S b/libc/sysv/consts/ST_SYNCHRONOUS.S index 36fff28e..3ee29b54 100644 --- a/libc/sysv/consts/ST_SYNCHRONOUS.S +++ b/libc/sysv/consts/ST_SYNCHRONOUS.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ST_SYNCHRONOUS,0x10,0,0,0,0,0 +.syscon statvfs,ST_SYNCHRONOUS,0x10,0,0,0,0,0 diff --git a/libc/sysv/consts/ST_WRITE.S b/libc/sysv/consts/ST_WRITE.S index f8a6f39f..1945a52f 100644 --- a/libc/sysv/consts/ST_WRITE.S +++ b/libc/sysv/consts/ST_WRITE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ST_WRITE,0x80,0,0,0,0,0 +.syscon statvfs,ST_WRITE,0x80,0,0,0,0,0 diff --git a/libc/sysv/consts/TAB0.S b/libc/sysv/consts/TAB0.S index a7ef5756..05e012fe 100644 --- a/libc/sysv/consts/TAB0.S +++ b/libc/sysv/consts/TAB0.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,TAB0,0b0000000000000000,0b000000000000000000,0b000000000000000000,0,0,0b0000000000000000 +.syscon termios,TAB0,0b0000000000000000,0b000000000000000000,0b000000000000000000,0,0b000000000000000000,0b0000000000000000 diff --git a/libc/sysv/consts/TAB1.S b/libc/sysv/consts/TAB1.S index 313a37ee..5ca4f4c9 100644 --- a/libc/sysv/consts/TAB1.S +++ b/libc/sysv/consts/TAB1.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,TAB1,0b0000100000000000,0b000000010000000000,0b000000010000000000,0,0,0b0000100000000000 +.syscon termios,TAB1,0b0000100000000000,0b000000010000000000,0b000000010000000000,0,0b000000010000000000,0b0000100000000000 diff --git a/libc/sysv/consts/TAB2.S b/libc/sysv/consts/TAB2.S index cdb74139..75b6974e 100644 --- a/libc/sysv/consts/TAB2.S +++ b/libc/sysv/consts/TAB2.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,TAB2,0b0001000000000000,0b000000100000000000,0b000000100000000000,0,0,0b0001000000000000 +.syscon termios,TAB2,0b0001000000000000,0b000000100000000000,0b000000100000000000,0,0b000000100000000000,0b0001000000000000 diff --git a/libc/sysv/consts/TAB3.S b/libc/sysv/consts/TAB3.S index 62041474..986b1f80 100644 --- a/libc/sysv/consts/TAB3.S +++ b/libc/sysv/consts/TAB3.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,TAB3,0b0001100000000000,0b000000000000000100,0b000000000000000100,0,0,0b0001100000000000 +.syscon termios,TAB3,0b0001100000000000,0b000000000000000100,0b000000000000000100,0,0b000000000000000100,0b0001100000000000 diff --git a/libc/sysv/consts/TCFLSH.S b/libc/sysv/consts/TCFLSH.S index af83feb9..aa355d64 100644 --- a/libc/sysv/consts/TCFLSH.S +++ b/libc/sysv/consts/TCFLSH.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCFLSH,0x540b,0,0,0,0,0 +.syscon termios,TCFLSH,0x540b,0,0,0,0,0 diff --git a/libc/sysv/consts/TCIFLUSH.S b/libc/sysv/consts/TCIFLUSH.S index 5acc423f..c7085295 100644 --- a/libc/sysv/consts/TCIFLUSH.S +++ b/libc/sysv/consts/TCIFLUSH.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCIFLUSH,0,1,1,1,1,0 +.syscon termios,TCIFLUSH,0,1,1,1,1,0 diff --git a/libc/sysv/consts/TCIOFF.S b/libc/sysv/consts/TCIOFF.S index 58f8bd64..0b054347 100644 --- a/libc/sysv/consts/TCIOFF.S +++ b/libc/sysv/consts/TCIOFF.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCIOFF,2,3,3,3,3,0 +.syscon termios,TCIOFF,2,3,3,3,3,0 diff --git a/libc/sysv/consts/TCIOFLUSH.S b/libc/sysv/consts/TCIOFLUSH.S index a62678a3..c407ecd1 100644 --- a/libc/sysv/consts/TCIOFLUSH.S +++ b/libc/sysv/consts/TCIOFLUSH.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCIOFLUSH,2,3,3,3,3,0 +.syscon termios,TCIOFLUSH,2,3,3,3,3,0 diff --git a/libc/sysv/consts/TCION.S b/libc/sysv/consts/TCION.S index b8e5f2d7..9020fa38 100644 --- a/libc/sysv/consts/TCION.S +++ b/libc/sysv/consts/TCION.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCION,3,4,4,4,4,0 +.syscon termios,TCION,3,4,4,4,4,0 diff --git a/libc/sysv/consts/TCOFLUSH.S b/libc/sysv/consts/TCOFLUSH.S index 717e0ad8..a7e8523a 100644 --- a/libc/sysv/consts/TCOFLUSH.S +++ b/libc/sysv/consts/TCOFLUSH.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCOFLUSH,1,2,2,2,2,0 +.syscon termios,TCOFLUSH,1,2,2,2,2,0 diff --git a/libc/sysv/consts/TCOOFF.S b/libc/sysv/consts/TCOOFF.S index 6a35619a..d2f98b06 100644 --- a/libc/sysv/consts/TCOOFF.S +++ b/libc/sysv/consts/TCOOFF.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCOOFF,0,1,1,1,1,0 +.syscon termios,TCOOFF,0,1,1,1,1,0 diff --git a/libc/sysv/consts/TCOON.S b/libc/sysv/consts/TCOON.S index 01b15fc9..38c3f077 100644 --- a/libc/sysv/consts/TCOON.S +++ b/libc/sysv/consts/TCOON.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCOON,1,2,2,2,2,0 +.syscon termios,TCOON,1,2,2,2,2,0 diff --git a/libc/sysv/consts/WRITE_10.S b/libc/sysv/consts/WRITE_10.S index a8a41395..951e911d 100644 --- a/libc/sysv/consts/WRITE_10.S +++ b/libc/sysv/consts/WRITE_10.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,WRITE_10,42,0,0,0,0,0 +.syscon scsi,WRITE_10,42,0,0,0,0,0 diff --git a/libc/sysv/consts/WRITE_12.S b/libc/sysv/consts/WRITE_12.S index 4a601fe9..ce4375bc 100644 --- a/libc/sysv/consts/WRITE_12.S +++ b/libc/sysv/consts/WRITE_12.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,WRITE_12,170,0,0,0,0,0 +.syscon scsi,WRITE_12,170,0,0,0,0,0 diff --git a/libc/sysv/consts/WRITE_6.S b/libc/sysv/consts/WRITE_6.S index ec8a380f..63727b62 100644 --- a/libc/sysv/consts/WRITE_6.S +++ b/libc/sysv/consts/WRITE_6.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,WRITE_6,10,0,0,0,0,0 +.syscon scsi,WRITE_6,10,0,0,0,0,0 diff --git a/libc/sysv/consts/WRITE_BUFFER.S b/libc/sysv/consts/WRITE_BUFFER.S index 08269023..80fc2949 100644 --- a/libc/sysv/consts/WRITE_BUFFER.S +++ b/libc/sysv/consts/WRITE_BUFFER.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,WRITE_BUFFER,59,0,0,0,0,0 +.syscon scsi,WRITE_BUFFER,59,0,0,0,0,0 diff --git a/libc/sysv/consts/WRITE_FILEMARKS.S b/libc/sysv/consts/WRITE_FILEMARKS.S index dd55e6e6..5058a502 100644 --- a/libc/sysv/consts/WRITE_FILEMARKS.S +++ b/libc/sysv/consts/WRITE_FILEMARKS.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,WRITE_FILEMARKS,0x10,0,0,0,0,0 +.syscon scsi,WRITE_FILEMARKS,0x10,0,0,0,0,0 diff --git a/libc/sysv/consts/WRITE_LONG.S b/libc/sysv/consts/WRITE_LONG.S index 42917846..5dc83904 100644 --- a/libc/sysv/consts/WRITE_LONG.S +++ b/libc/sysv/consts/WRITE_LONG.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,WRITE_LONG,63,0,0,0,0,0 +.syscon scsi,WRITE_LONG,63,0,0,0,0,0 diff --git a/libc/sysv/consts/WRITE_LONG_2.S b/libc/sysv/consts/WRITE_LONG_2.S index 016c7f94..6c6cea5e 100644 --- a/libc/sysv/consts/WRITE_LONG_2.S +++ b/libc/sysv/consts/WRITE_LONG_2.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,WRITE_LONG_2,234,0,0,0,0,0 +.syscon scsi,WRITE_LONG_2,234,0,0,0,0,0 diff --git a/libc/sysv/consts/WRITE_SAME.S b/libc/sysv/consts/WRITE_SAME.S index 7ed5916b..175f4989 100644 --- a/libc/sysv/consts/WRITE_SAME.S +++ b/libc/sysv/consts/WRITE_SAME.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,WRITE_SAME,65,0,0,0,0,0 +.syscon scsi,WRITE_SAME,65,0,0,0,0,0 diff --git a/libc/sysv/consts/WRITE_VERIFY.S b/libc/sysv/consts/WRITE_VERIFY.S index d06004a3..80fcc36d 100644 --- a/libc/sysv/consts/WRITE_VERIFY.S +++ b/libc/sysv/consts/WRITE_VERIFY.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,WRITE_VERIFY,46,0,0,0,0,0 +.syscon scsi,WRITE_VERIFY,46,0,0,0,0,0 diff --git a/libc/sysv/consts/WRITE_VERIFY_12.S b/libc/sysv/consts/WRITE_VERIFY_12.S index 8b350e2a..47d70f13 100644 --- a/libc/sysv/consts/WRITE_VERIFY_12.S +++ b/libc/sysv/consts/WRITE_VERIFY_12.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,WRITE_VERIFY_12,174,0,0,0,0,0 +.syscon scsi,WRITE_VERIFY_12,174,0,0,0,0,0 diff --git a/libc/sysv/consts/XCASE.S b/libc/sysv/consts/XCASE.S index 307c411e..5e711bf4 100644 --- a/libc/sysv/consts/XCASE.S +++ b/libc/sysv/consts/XCASE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,XCASE,0b0000000000000100,0,0,16777216,16777216,0b0000000000000100 +.syscon termios,XCASE,0b0000000000000100,0,0,16777216,0,0b0000000000000100 diff --git a/libc/sysv/consts/XTABS.S b/libc/sysv/consts/XTABS.S index f0b7db65..d6e186fe 100644 --- a/libc/sysv/consts/XTABS.S +++ b/libc/sysv/consts/XTABS.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon termios,XTABS,0b0001100000000000,0b000000000000000000,0b000000110000000000,0,0,0b0001100000000000 +.syscon termios,XTABS,0b0001100000000000,0b000000110000000000,0b000000110000000000,0,0b000000110000000000,0b0001100000000000 diff --git a/libc/sysv/consts/ai.h b/libc/sysv/consts/ai.h deleted file mode 100644 index 21b63740..00000000 --- a/libc/sysv/consts/ai.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_AI_H_ -#define COSMOPOLITAN_LIBC_SYSV_CONSTS_AI_H_ -#include "libc/runtime/symbolic.h" -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ - -extern const long AI_ADDRCONFIG; -extern const long AI_ALL; -extern const long AI_CANONNAME; -extern const long AI_NUMERICHOST; -extern const long AI_NUMERICSERV; -extern const long AI_PASSIVE; -extern const long AI_V4MAPPED; - -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ - -#define AI_ADDRCONFIG SYMBOLIC(AI_ADDRCONFIG) -#define AI_ALL SYMBOLIC(AI_ALL) -#define AI_CANONNAME LITERALLY(2) -#define AI_NUMERICHOST LITERALLY(4) -#define AI_NUMERICSERV SYMBOLIC(AI_NUMERICSERV) -#define AI_PASSIVE LITERALLY(1) -#define AI_V4MAPPED SYMBOLIC(AI_V4MAPPED) - -#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_AI_H_ */ diff --git a/libc/sysv/consts/blk.h b/libc/sysv/consts/blk.h deleted file mode 100644 index d1159ac8..00000000 --- a/libc/sysv/consts/blk.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_BLK_H_ -#define COSMOPOLITAN_LIBC_SYSV_CONSTS_BLK_H_ -#include "libc/runtime/symbolic.h" - -#define BLK_BYTECOUNT SYMBOLIC(BLK_BYTECOUNT) -#define BLK_EOF SYMBOLIC(BLK_EOF) -#define BLK_EOR SYMBOLIC(BLK_EOR) -#define BLK_ERRORS SYMBOLIC(BLK_ERRORS) -#define BLK_RESTART SYMBOLIC(BLK_RESTART) - -#define BLKBSZGET SYMBOLIC(BLKBSZGET) -#define BLKBSZSET SYMBOLIC(BLKBSZSET) -#define BLKFLSBUF SYMBOLIC(BLKFLSBUF) -#define BLKFRAGET SYMBOLIC(BLKFRAGET) -#define BLKFRASET SYMBOLIC(BLKFRASET) -#define BLKGETSIZE SYMBOLIC(BLKGETSIZE) -#define BLKGETSIZE64 SYMBOLIC(BLKGETSIZE64) -#define BLKRAGET SYMBOLIC(BLKRAGET) -#define BLKRASET SYMBOLIC(BLKRASET) -#define BLKROGET SYMBOLIC(BLKROGET) -#define BLKROSET SYMBOLIC(BLKROSET) -#define BLKRRPART SYMBOLIC(BLKRRPART) -#define BLKSECTGET SYMBOLIC(BLKSECTGET) -#define BLKSECTSET SYMBOLIC(BLKSECTSET) -#define BLKSSZGET SYMBOLIC(BLKSSZGET) -#define BLKTYPE SYMBOLIC(BLKTYPE) - -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ - -extern const long BLK_BYTECOUNT; -extern const long BLK_EOF; -extern const long BLK_EOR; -extern const long BLK_ERRORS; -extern const long BLK_RESTART; - -extern const long BLKBSZGET; -extern const long BLKBSZSET; -extern const long BLKFLSBUF; -extern const long BLKFRAGET; -extern const long BLKFRASET; -extern const long BLKGETSIZE64; -extern const long BLKGETSIZE; -extern const long BLKRAGET; -extern const long BLKRASET; -extern const long BLKROGET; -extern const long BLKROSET; -extern const long BLKRRPART; -extern const long BLKSECTGET; -extern const long BLKSECTSET; -extern const long BLKSSZGET; -extern const long BLKTYPE; - -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_BLK_H_ */ diff --git a/libc/sysv/consts/inaddr.h b/libc/sysv/consts/inaddr.h index cf826005..08773d6f 100644 --- a/libc/sysv/consts/inaddr.h +++ b/libc/sysv/consts/inaddr.h @@ -1,40 +1,22 @@ #ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_INADDR_H_ #define COSMOPOLITAN_LIBC_SYSV_CONSTS_INADDR_H_ -#include "libc/runtime/symbolic.h" -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ /** * @fileoverview Well-known Internet addresses. * These need to be hard-coded as little-endian, so htonl() is needed. */ -extern const long INADDR_ALLHOSTS_GROUP; -extern const long INADDR_ALLRTRS_GROUP; -extern const long INADDR_ANY; -extern const long INADDR_BROADCAST; -extern const long INADDR_LOOPBACK; -extern const long INADDR_MAX_LOCAL_GROUP; -extern const long INADDR_NONE; -extern const long INADDR_TESTNET1; -extern const long INADDR_TESTNET2; -extern const long INADDR_TESTNET3; -extern const long INADDR_UNSPEC_GROUP; +#define INADDR_ANY 0x00000000u /* 0.0.0.0 */ +#define INADDR_BROADCAST 0xFFFFFFFFu /* 255.255.255.255 */ +#define INADDR_NONE 0xFFFFFFFFu /* 255.255.255.255 */ +#define INADDR_LOOPBACK 0x7F000001u /* 127.0.0.1 */ +#define INADDR_TESTNET1 0xC0000200u /* 192.0.2.0/24 (RFC5737§3) */ +#define INADDR_TESTNET2 0xC6336400u /* 198.51.100.0/24 */ +#define INADDR_TESTNET3 0xCB007100u /* 203.0.113.0/24 */ -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ - -#define INADDR_ANY LITERALLY(0x00000000u) /* 0.0.0.0 */ -#define INADDR_BROADCAST LITERALLY(0xffffffffu) /* 255.255.255.255 */ -#define INADDR_NONE LITERALLY(0xffffffffu) /* 255.255.255.255 */ -#define INADDR_LOOPBACK LITERALLY(0x7f000001u) /* 127.0.0.1 */ -#define INADDR_TESTNET1 LITERALLY(0xc0000200u) /* 192.0.2.0/24 (RFC5737§3) */ -#define INADDR_TESTNET2 LITERALLY(0xc6336400u) /* 198.51.100.0/24 */ -#define INADDR_TESTNET3 LITERALLY(0xcb007100u) /* 203.0.113.0/24 */ - -#define INADDR_ALLHOSTS_GROUP SYMBOLIC(INADDR_ALLHOSTS_GROUP) -#define INADDR_ALLRTRS_GROUP SYMBOLIC(INADDR_ALLRTRS_GROUP) -#define INADDR_MAX_LOCAL_GROUP SYMBOLIC(INADDR_MAX_LOCAL_GROUP) -#define INADDR_UNSPEC_GROUP SYMBOLIC(INADDR_UNSPEC_GROUP) +#define INADDR_ALLHOSTS_GROUP 0xE0000001u +#define INADDR_ALLRTRS_GROUP 0xE0000002u +#define INADDR_MAX_LOCAL_GROUP 0xE00000FFu +#define INADDR_UNSPEC_GROUP 0xE0000000u #endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_INADDR_H_ */ diff --git a/libc/sysv/consts/map.h b/libc/sysv/consts/map.h index 9748e3b3..05d65680 100644 --- a/libc/sysv/consts/map.h +++ b/libc/sysv/consts/map.h @@ -21,7 +21,7 @@ extern const long MAP_NORESERVE; extern const long MAP_POPULATE; extern const long MAP_PRIVATE; extern const long MAP_SHARED; -extern const long MAP_TYPE; +extern const long MAP_CONCEAL; COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ @@ -29,6 +29,7 @@ COSMOPOLITAN_C_END_ #define MAP_FILE 0 #define MAP_SHARED 1 #define MAP_PRIVATE 2 +#define MAP_TYPE 15 #define MAP_FIXED 16 #define MAP_32BIT SYMBOLIC(MAP_32BIT) @@ -44,7 +45,7 @@ COSMOPOLITAN_C_END_ #define MAP_NONBLOCK SYMBOLIC(MAP_NONBLOCK) #define MAP_NORESERVE SYMBOLIC(MAP_NORESERVE) #define MAP_POPULATE SYMBOLIC(MAP_POPULATE) -#define MAP_TYPE SYMBOLIC(MAP_TYPE) +#define MAP_CONCEAL SYMBOLIC(MAP_CONCEAL) #define MAP_ANON MAP_ANONYMOUS #define MAP_NOCORE MAP_CONCEAL diff --git a/libc/sysv/syscalls.sh b/libc/sysv/syscalls.sh index 09976cca..7acd419c 100755 --- a/libc/sysv/syscalls.sh +++ b/libc/sysv/syscalls.sh @@ -112,7 +112,7 @@ scall msgget 0x0e10e10e12103044 globl # won't polyfill for windows scall msgsnd 0x0e20e20e22104045 globl # won't polyfill for windows scall msgrcv 0x0e30e30e32105046 globl # won't polyfill for windows scall msgctl 0x1bc1291ff2102047 globl # won't polyfill for windows -scall sys_fcntl 0x05c05c05c205c048 globl hidden +scall __sys_fcntl 0x05c05c05c205c048 globl hidden scall sys_flock 0x0830830832083049 globl hidden scall sys_fsync 0x05f05f05f205f04a globl hidden scall sys_fdatasync 0x0f105f22620bb04b globl hidden # fsync() on openbsd diff --git a/libc/sysv/systemfive.S b/libc/sysv/systemfive.S index 019339aa..8d896440 100644 --- a/libc/sysv/systemfive.S +++ b/libc/sysv/systemfive.S @@ -108,13 +108,13 @@ __systemfive: systemfive_linux: and $0xfff,%eax cmp $0xfff,%eax - je systemfive_enosys + je systemfive_enosys # never taken branches cost nothing mov %rcx,%r10 # syscall instruction clobbers %rcx push %rbp # linux never reads args from stack mov %rsp,%rbp # having frame will help backtraces syscall # this is known as a context switch pop %rbp # next we check to see if it failed - cmp $-4095,%rax # system five nexgen32e abi § A.2.1 + cmp $-4095,%rax # system five nexgen32e abi § a.2.1 jae systemfive_error # encodes errno as neg return value ret .endfn systemfive_linux,globl,hidden @@ -374,7 +374,7 @@ _init_systemfive_stack: # determinism ftw! mov %rsp,%rbp // 𝑠𝑙𝑖𝑑𝑒 _init_systemfive_syscall: -/* mov __NR_msyscall,%eax # syscall origin protect + mov __NR_msyscall,%eax # syscall origin protect cmp $0xfff,%ax # openbsd is pretty cool jae _init_systemfive_done push %rdi @@ -385,7 +385,7 @@ _init_systemfive_syscall: mov $__privileged_size,%esi syscall pop %rsi - pop %rdi*/ + pop %rdi // 𝑠𝑙𝑖𝑑𝑒 #endif /* TINY */ _init_systemfive_done: diff --git a/libc/testlib/testlib.mk b/libc/testlib/testlib.mk index 85ccc3c6..f609b80c 100644 --- a/libc/testlib/testlib.mk +++ b/libc/testlib/testlib.mk @@ -165,6 +165,7 @@ LIBC_TESTMAIN_DIRECTDEPS = \ LIBC_CALLS \ LIBC_INTRIN \ LIBC_LOG \ + LIBC_MEM \ LIBC_NEXGEN32E \ LIBC_RUNTIME \ LIBC_STDIO \ diff --git a/libc/testlib/testmain.c b/libc/testlib/testmain.c index 3220673d..8f18af35 100644 --- a/libc/testlib/testmain.c +++ b/libc/testlib/testmain.c @@ -21,6 +21,7 @@ #include "libc/calls/internal.h" #include "libc/log/log.h" #include "libc/nexgen32e/x86feature.h" +#include "libc/runtime/symbols.internal.h" #include "libc/stdio/stdio.h" #include "libc/sysv/consts/ex.h" #include "libc/sysv/consts/exit.h" @@ -70,9 +71,13 @@ static testonly void GetOpts(int argc, char *argv[]) { * Generic test program main function. */ testonly int main(int argc, char *argv[]) { + const char *comdbg; __log_level = kLogInfo; GetOpts(argc, argv); showcrashreports(); + if ((comdbg = FindDebugBinary())) { + setenv("COMDBG", comdbg, true); + } g_testlib_shoulddebugbreak = IsDebuggerPresent(false); sys_getpid(); /* make strace easier to read */ testlib_clearxmmregisters(); diff --git a/libc/testlib/testrunner.c b/libc/testlib/testrunner.c index 50bf8d8a..d7a5ca9c 100644 --- a/libc/testlib/testrunner.c +++ b/libc/testlib/testrunner.c @@ -25,6 +25,7 @@ #include "libc/macros.internal.h" #include "libc/nt/process.h" #include "libc/runtime/runtime.h" +#include "libc/runtime/symbols.internal.h" #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" diff --git a/libc/time/strftime.c b/libc/time/strftime.c index 5a610e6d..fce7fb70 100644 --- a/libc/time/strftime.c +++ b/libc/time/strftime.c @@ -19,6 +19,7 @@ #include "libc/assert.h" #include "libc/calls/calls.h" #include "libc/fmt/fmt.h" +#include "libc/fmt/itoa.h" #include "libc/macros.internal.h" #include "libc/nexgen32e/nexgen32e.h" #include "libc/time/struct/tm.h" @@ -31,24 +32,24 @@ Copyright 1989 The Regents of the University of California\""); asm(".include \"libc/disclaimer.inc\""); static char *strftime_add(char *p, const char *pe, const char *str) { - while (p < pe && (*p = *str++) != '\0') ++p; + while (p < pe && (*p = *str++)) ++p; return p; } static char *strftime_conv(char *p, const char *pe, int n, const char *format) { - char buf[INT_STRLEN_MAXIMUM(int) + 1]; + char buf[22]; (snprintf)(buf, sizeof(buf), format, n); return strftime_add(p, pe, buf); } static char *strftime_secs(char *p, const char *pe, const struct tm *t) { - static char buf[INT_STRLEN_MAXIMUM(int) + 1]; + char ibuf[21]; struct tm tmp; int64_t s; tmp = *t; /* Make a copy, mktime(3) modifies the tm struct. */ s = mktime(&tmp); - (snprintf)(buf, sizeof(buf), "%ld", s); - return strftime_add(p, pe, buf); + int64toarray_radix10(s, ibuf); + return strftime_add(p, pe, ibuf); } static char *strftime_timefmt(char *p, const char *pe, const char *format, diff --git a/libc/zip.h b/libc/zip.h index 79ae60b9..359a5298 100644 --- a/libc/zip.h +++ b/libc/zip.h @@ -49,8 +49,10 @@ #define kZipCdirHdrLinkableSize \ ROUNDUP(kZipCfileHdrMinSize + PATH_MAX, kZipCdirAlign) -#define kZipCdir64HdrMagic 0x06064b50 /* PK♣♠ "PK\6\6" */ -#define kZipCdir64HdrMinSize 56 +#define kZipCdir64HdrMagic 0x06064b50 /* PK♣♠ "PK\6\6" */ +#define kZipCdir64HdrMinSize 56 +#define kZipCdir64LocatorMagic 0x07064b50 /* PK♠• "PK\6\7" */ +#define kZipCdir64LocatorSize 20 #define kZipCfileHdrMagic 0x02014b50 /* PK☺☻ "PK\1\2" */ #define kZipCfileHdrMinSize 46 @@ -112,7 +114,11 @@ #define ZIP_CDIR64_OFFSET(P) READ64LE((P) + 48) #define ZIP_CDIR64_COMMENTSIZE(P) \ (ZIP_CDIR64_HDRSIZE(P) >= 56 ? ZIP_CDIR64_HDRSIZE(P) - 56 : 0) -#define ZIP_CDIR64_COMMENT(P) ((P) + 56) /* recommend stopping at nul */ +#define ZIP_CDIR64_COMMENT(P) ((P) + 56) /* recommend stopping at nul */ +#define ZIP_LOCATE64_MAGIC(P) READ32LE(P) +#define ZIP_LOCATE64_STARTINGDISK(P) READ32LE((P) + 4) +#define ZIP_LOCATE64_OFFSET(P) READ64LE((P) + 8) +#define ZIP_LOCATE64_TOTALDISKS(P) READ32LE((P) + 12) /* central directory file header */ #define ZIP_CFILE_MAGIC(P) READ32LE(P) @@ -178,7 +184,7 @@ #define ZIP_EXTRA_CONTENT(P) ((P) + 4) #define ZIP_EXTRA_SIZE(P) (ZIP_EXTRA_CONTENTSIZE(P) + kZipExtraHdrSize) -uint8_t *GetZipCdir(const uint8_t *, size_t); +void *GetZipCdir(const uint8_t *, size_t); bool IsZipCdir32(const uint8_t *, size_t, size_t); bool IsZipCdir64(const uint8_t *, size_t, size_t); int GetZipCfileMode(const uint8_t *); diff --git a/net/http/escapejsstringliteral.c b/net/http/escapejsstringliteral.c index ca8cf274..a5b49d59 100644 --- a/net/http/escapejsstringliteral.c +++ b/net/http/escapejsstringliteral.c @@ -16,11 +16,23 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/bits/likely.h" #include "libc/str/thompike.h" #include "libc/str/utf16.h" #include "libc/x/x.h" #include "net/http/escape.h" +static const char kEscapeLiteral[128] = { + 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 2, 9, 4, 3, 9, 9, // 0x00 + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, // 0x10 + 0, 0, 7, 0, 0, 0, 9, 8, 0, 0, 0, 0, 0, 0, 0, 6, // 0x20 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 0, // 0x30 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x40 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, // 0x50 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, // 0x70 +}; + /** * Escapes UTF-8 data for JavaScript or JSON string literal. * @@ -66,141 +78,51 @@ char *EscapeJsStringLiteral(const char *p, size_t n, size_t *z) { } } } - switch (x) { - case ' ': - case '!': - case '#': - case '$': - case '%': - case '(': - case ')': - case '*': - case '+': - case ',': - case '-': - case '.': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case ';': - case '?': - case '@': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '[': - case ']': - case '^': - case '_': - case '`': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': - case '{': - case '|': - case '}': - case '~': + switch (0 <= x && x <= 127 ? kEscapeLiteral[x] : 9) { + case 0: *q++ = x; break; - case '\t': + case 1: q[0] = '\\'; q[1] = 't'; q += 2; break; - case '\n': + case 2: q[0] = '\\'; q[1] = 'n'; q += 2; break; - case '\r': + case 3: q[0] = '\\'; q[1] = 'r'; q += 2; break; - case '\f': + case 4: q[0] = '\\'; q[1] = 'f'; q += 2; break; - case '\\': + case 5: q[0] = '\\'; q[1] = '\\'; q += 2; break; - case '/': + case 6: q[0] = '\\'; q[1] = '/'; q += 2; break; - case '"': + case 7: q[0] = '\\'; q[1] = '"'; q += 2; break; - case '\'': + case 8: q[0] = '\\'; q[1] = '\''; q += 2; break; - case '<': - case '>': - case '&': - case '=': - default: + case 9: w = EncodeUtf16(x); do { q[0] = '\\'; @@ -212,6 +134,8 @@ char *EscapeJsStringLiteral(const char *p, size_t n, size_t *z) { q += 6; } while ((w >>= 16)); break; + default: + unreachable; } } if (z) *z = q - r; diff --git a/net/http/geturischeme.gperf b/net/http/geturischeme.gperf deleted file mode 100644 index 8c70ccb6..00000000 --- a/net/http/geturischeme.gperf +++ /dev/null @@ -1,24 +0,0 @@ -%{ -#include "libc/str/str.h" -#include "net/http/uri.h" -#define GPERF_DOWNCASE -%} -%compare-strncmp -%ignore-case -%language=ANSI-C -%pic -%readonly-tables -%struct-type -struct UriSchemeSlot { unsigned char name; unsigned char code; }; -%% -http,kUriSchemeHttp -https,kUriSchemeHttps -file,kUriSchemeFile -data,kUriSchemeData -zip,kUriSchemeZip -sip,kUriSchemeSip -sips,kUriSchemeSips -tel,kUriSchemeTel -ssh,kUriSchemeSsh -gs,kUriSchemeGs -s3,kUriSchemeS3 diff --git a/net/http/geturischeme.inc b/net/http/geturischeme.inc deleted file mode 100644 index b02cce37..00000000 --- a/net/http/geturischeme.inc +++ /dev/null @@ -1,213 +0,0 @@ -/* ANSI-C code produced by gperf version 3.0.4 */ -/* Command-line: gperf net/http/geturischeme.gperf */ -/* Computed positions: -k'1-2' */ - -#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ - && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ - && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ - && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ - && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ - && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ - && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ - && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ - && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ - && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ - && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ - && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ - && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ - && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ - && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ - && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ - && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ - && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ - && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ - && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ - && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ - && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ - && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) -/* The character set is not based on ISO-646. */ -#error "gperf generated tables don't work with this execution character set. Please report a bug to ." -#endif - -#line 1 "net/http/geturischeme.gperf" - -#include "libc/str/str.h" -#include "net/http/uri.h" -#define GPERF_DOWNCASE -#line 12 "net/http/geturischeme.gperf" -struct UriSchemeSlot { unsigned char name; unsigned char code; }; - -#define TOTAL_KEYWORDS 11 -#define MIN_WORD_LENGTH 2 -#define MAX_WORD_LENGTH 5 -#define MIN_HASH_VALUE 2 -#define MAX_HASH_VALUE 19 -/* maximum key range = 18, duplicates = 0 */ - -#ifndef GPERF_DOWNCASE -#define GPERF_DOWNCASE 1 -static unsigned char gperf_downcase[256] = - { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, - 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, - 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, - 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, - 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, - 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, - 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, - 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, - 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, - 255 - }; -#endif - -#ifndef GPERF_CASE_STRNCMP -#define GPERF_CASE_STRNCMP 1 -static int -gperf_case_strncmp (register const char *s1, register const char *s2, register unsigned int n) -{ - for (; n > 0;) - { - unsigned char c1 = gperf_downcase[(unsigned char)*s1++]; - unsigned char c2 = gperf_downcase[(unsigned char)*s2++]; - if (c1 != 0 && c1 == c2) - { - n--; - continue; - } - return (int)c1 - (int)c2; - } - return 0; -} -#endif - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static unsigned int -hash (register const char *str, register unsigned int len) -{ - static const unsigned char asso_values[] = - { - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 5, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 10, 20, 20, 5, 15, - 5, 0, 0, 5, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 0, 0, 20, 20, 20, 20, 20, - 5, 20, 20, 20, 20, 20, 20, 10, 20, 20, - 5, 15, 5, 0, 0, 5, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 0, 0, 20, 20, 20, - 20, 20, 5, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20 - }; - return len + asso_values[(unsigned char)str[1]] + asso_values[(unsigned char)str[0]]; -} - -struct stringpool_t - { - char stringpool_str2[sizeof("gs")]; - char stringpool_str3[sizeof("ssh")]; - char stringpool_str4[sizeof("http")]; - char stringpool_str5[sizeof("https")]; - char stringpool_str7[sizeof("s3")]; - char stringpool_str8[sizeof("sip")]; - char stringpool_str9[sizeof("sips")]; - char stringpool_str13[sizeof("zip")]; - char stringpool_str14[sizeof("file")]; - char stringpool_str18[sizeof("tel")]; - char stringpool_str19[sizeof("data")]; - }; -static const struct stringpool_t stringpool_contents = - { - "gs", - "ssh", - "http", - "https", - "s3", - "sip", - "sips", - "zip", - "file", - "tel", - "data" - }; -#define stringpool ((const char *) &stringpool_contents) -const struct UriSchemeSlot * -in_word_set (register const char *str, register unsigned int len) -{ - static const struct UriSchemeSlot wordlist[] = - { - {-1}, {-1}, -#line 23 "net/http/geturischeme.gperf" - {(int)(long)&((struct stringpool_t *)0)->stringpool_str2,kUriSchemeGs}, -#line 22 "net/http/geturischeme.gperf" - {(int)(long)&((struct stringpool_t *)0)->stringpool_str3,kUriSchemeSsh}, -#line 14 "net/http/geturischeme.gperf" - {(int)(long)&((struct stringpool_t *)0)->stringpool_str4,kUriSchemeHttp}, -#line 15 "net/http/geturischeme.gperf" - {(int)(long)&((struct stringpool_t *)0)->stringpool_str5,kUriSchemeHttps}, - {-1}, -#line 24 "net/http/geturischeme.gperf" - {(int)(long)&((struct stringpool_t *)0)->stringpool_str7,kUriSchemeS3}, -#line 19 "net/http/geturischeme.gperf" - {(int)(long)&((struct stringpool_t *)0)->stringpool_str8,kUriSchemeSip}, -#line 20 "net/http/geturischeme.gperf" - {(int)(long)&((struct stringpool_t *)0)->stringpool_str9,kUriSchemeSips}, - {-1}, {-1}, {-1}, -#line 18 "net/http/geturischeme.gperf" - {(int)(long)&((struct stringpool_t *)0)->stringpool_str13,kUriSchemeZip}, -#line 16 "net/http/geturischeme.gperf" - {(int)(long)&((struct stringpool_t *)0)->stringpool_str14,kUriSchemeFile}, - {-1}, {-1}, {-1}, -#line 21 "net/http/geturischeme.gperf" - {(int)(long)&((struct stringpool_t *)0)->stringpool_str18,kUriSchemeTel}, -#line 17 "net/http/geturischeme.gperf" - {(int)(long)&((struct stringpool_t *)0)->stringpool_str19,kUriSchemeData} - }; - - if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) - { - register int key = hash (str, len); - - if (key <= MAX_HASH_VALUE && key >= 0) - { - register int o = wordlist[key].name; - if (o >= 0) - { - register const char *s = o + stringpool; - - if ((((unsigned char)*str ^ (unsigned char)*s) & ~32) == 0 && !gperf_case_strncmp (str, s, len) && s[len] == '\0') - return &wordlist[key]; - } - } - } - return 0; -} diff --git a/net/http/parseurl.c b/net/http/parseurl.c index cc75a4b4..fd1767bb 100644 --- a/net/http/parseurl.c +++ b/net/http/parseurl.c @@ -24,21 +24,21 @@ #include "net/http/url.h" struct UrlParser { - int i; + unsigned i; int c; const char *data; - int size; - bool isform; - bool islatin1; - bool isopaque; + size_t size; + char isform; + char islatin1; + char isopaque; char *p; char *q; }; -static void EmitLatin1(struct UrlParser *u, int c) { - u->p[0] = 0300 | c >> 6; - u->p[1] = 0200 | c & 077; - u->p += 2; +static void EmitLatin1(char **p, int c) { + (*p)[0] = 0300 | c >> 6; + (*p)[1] = 0200 | c & 077; + *p += 2; } static bool EmitKey(struct UrlParser *u, struct UrlParams *h) { @@ -115,16 +115,18 @@ static bool ParseScheme(struct UrlParser *u, struct Url *h) { ParseEscape(u); return false; } else if (u->c >= 0200 && u->islatin1) { - EmitLatin1(u, u->c); + EmitLatin1(&u->p, u->c); return false; } else { *u->p++ = u->c; if (u->i == 1) { - if (!isalpha(u->c)) { + if (!(('A' <= u->c && u->c <= 'Z') || ('a' <= u->c && u->c <= 'z'))) { return false; } } else { - if (!isalnum(u->c) && u->c != '+' && u->c != '-' && u->c != '.') { + if (!(('0' <= u->c && u->c <= '9') || ('A' <= u->c && u->c <= 'Z') || + ('a' <= u->c && u->c <= 'z') || u->c == '+' || u->c == '-' || + u->c == '.')) { return false; } } @@ -134,17 +136,17 @@ static bool ParseScheme(struct UrlParser *u, struct Url *h) { } static void ParseAuthority(struct UrlParser *u, struct Url *h) { - int t = 0; + unsigned t = 1; const char *c = NULL; while (u->i < u->size) { u->c = u->data[u->i++] & 0xff; if (u->c == '/' || u->c == '#' || u->c == '?') { break; } else if (u->c == '[') { - t = -1; - } else if (u->c == ']') { t = 0; - } else if (u->c == ':' && t >= 0) { + } else if (u->c == ']') { + t = 1; + } else if (u->c == ':' && t > 0) { *u->p++ = ':'; c = u->p; ++t; @@ -155,7 +157,7 @@ static void ParseAuthority(struct UrlParser *u, struct Url *h) { h->pass.p = c; h->pass.n = u->p - c; c = NULL; - t = 0; + t = 1; } else { h->user.p = u->q; h->user.n = u->p - u->q; @@ -164,12 +166,12 @@ static void ParseAuthority(struct UrlParser *u, struct Url *h) { } else if (u->c == '%') { ParseEscape(u); } else if (u->c >= 0200 && u->islatin1) { - EmitLatin1(u, u->c); + EmitLatin1(&u->p, u->c); } else { *u->p++ = u->c; } } - if (t == 1) { + if (t == 2) { h->host.p = u->q; h->host.n = c - 1 - u->q; h->port.p = c; @@ -195,7 +197,7 @@ static void ParsePath(struct UrlParser *u, struct UrlView *h) { } else if (u->c == '%') { ParseEscape(u); } else if (u->c >= 0200 && u->islatin1) { - EmitLatin1(u, u->c); + EmitLatin1(&u->p, u->c); } else { *u->p++ = u->c; } @@ -226,7 +228,7 @@ static void ParseQuery(struct UrlParser *u, struct UrlParams *h) { *u->p++ = '='; } } else if (u->c >= 0200 && u->islatin1) { - EmitLatin1(u, u->c); + EmitLatin1(&u->p, u->c); } else { *u->p++ = u->c; } @@ -240,7 +242,7 @@ static void ParseFragment(struct UrlParser *u, struct UrlView *h) { if (u->c == '%') { ParseEscape(u); } else if (u->c >= 0200 && u->islatin1) { - EmitLatin1(u, u->c); + EmitLatin1(&u->p, u->c); } else { *u->p++ = u->c; } @@ -258,8 +260,8 @@ static char *ParseUrlImpl(const char *data, size_t size, struct Url *h, u.i = 0; u.c = 0; u.isform = false; - u.islatin1 = latin1; u.isopaque = false; + u.islatin1 = latin1; u.data = data; u.size = size; memset(h, 0, sizeof(*h)); diff --git a/test/libc/calls/writev_test.c b/test/libc/calls/writev_test.c index 0c712743..ac7c9998 100644 --- a/test/libc/calls/writev_test.c +++ b/test/libc/calls/writev_test.c @@ -18,9 +18,12 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/struct/iovec.h" +#include "libc/dce.h" #include "libc/errno.h" #include "libc/macros.internal.h" +#include "libc/runtime/runtime.h" #include "libc/sock/sock.h" +#include "libc/sysv/consts/auxv.h" #include "libc/sysv/consts/o.h" #include "libc/testlib/testlib.h" @@ -59,6 +62,29 @@ TEST(writev, big_fullCompletion) { EXPECT_NE(-1, close(fd)); } +TEST(writev, asanError_efaults) { + if (!IsAsan()) return; + void *malloc_(size_t) asm("malloc"); + void free_(void *) asm("free"); + void *p; + int fd; + p = malloc_(32); + EXPECT_NE(-1, (fd = open("asan", O_RDWR | O_CREAT | O_TRUNC, 0644))); + EXPECT_EQ(32, write(fd, p, 32)); + EXPECT_NE(-1, lseek(fd, 0, SEEK_SET)); + EXPECT_EQ(32, read(fd, p, 32)); + EXPECT_EQ(-1, write(fd, p, 33)); + EXPECT_EQ(EFAULT, errno); + EXPECT_EQ(-1, write(fd, p, -1)); + EXPECT_EQ(EFAULT, errno); + free_(p); + EXPECT_EQ(-1, write(fd, p, 32)); + EXPECT_EQ(EFAULT, errno); + EXPECT_EQ(-1, read(fd, p, 32)); + EXPECT_EQ(EFAULT, errno); + close(fd); +} + TEST(writev, empty_stillPerformsIoOperation) { int fd; struct iovec iov[] = {{"", 0}, {NULL, 0}}; diff --git a/test/libc/fmt/fmt_test.c b/test/libc/fmt/fmt_test.c index 644a76cf..f35670f9 100644 --- a/test/libc/fmt/fmt_test.c +++ b/test/libc/fmt/fmt_test.c @@ -276,3 +276,8 @@ TEST(fmt, p) { EXPECT_STREQ("0xffff800000031337", gc(xasprintf("% 10p", 0xffff800000031337))); } + +/* TEST(fmt, funchar) { */ +/* /\* TODO(jart): fix this *\/ */ +/* ASSERT_STREQ("'\\200'", gc(xasprintf("%`'c", 0200))); */ +/* } */ diff --git a/test/libc/intrin/asan_test.c b/test/libc/intrin/asan_test.c new file mode 100644 index 00000000..4cb34740 --- /dev/null +++ b/test/libc/intrin/asan_test.c @@ -0,0 +1,42 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2021 Justine Alexandra Roberts Tunney │ +│ │ +│ Permission to use, copy, modify, and/or distribute this software for │ +│ any purpose with or without fee is hereby granted, provided that the │ +│ above copyright notice and this permission notice appear in all copies. │ +│ │ +│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ +│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ +│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ +│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ +│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ +│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ +│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ +│ PERFORMANCE OF THIS SOFTWARE. │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/dce.h" +#include "libc/intrin/asan.internal.h" +#include "libc/mem/mem.h" +#include "libc/testlib/testlib.h" + +TEST(asan, test) { + char *p; + if (!IsAsan()) return; + p = gc(malloc(3)); + EXPECT_TRUE(__asan_is_valid(p, 3)); + EXPECT_FALSE(__asan_is_valid(p, 4)); + EXPECT_TRUE(__asan_is_valid(p + 1, 2)); + EXPECT_FALSE(__asan_is_valid(p + 1, 3)); + p = gc(malloc(8 + 3)); + EXPECT_TRUE(__asan_is_valid(p, 8 + 3)); + EXPECT_FALSE(__asan_is_valid(p, 8 + 4)); + EXPECT_TRUE(__asan_is_valid(p + 1, 8 + 2)); + EXPECT_FALSE(__asan_is_valid(p + 1, 8 + 3)); + p = gc(malloc(64 + 3)); + EXPECT_TRUE(__asan_is_valid(p, 64 + 3)); + EXPECT_FALSE(__asan_is_valid(p, 64 + 4)); + EXPECT_TRUE(__asan_is_valid(p + 1, 64 + 2)); + EXPECT_FALSE(__asan_is_valid(p + 1, 64 + 3)); +} diff --git a/test/libc/intrin/test.mk b/test/libc/intrin/test.mk index cfe41817..a36d3189 100644 --- a/test/libc/intrin/test.mk +++ b/test/libc/intrin/test.mk @@ -26,6 +26,7 @@ TEST_LIBC_INTRIN_DIRECTDEPS = \ LIBC_FMT \ LIBC_INTRIN \ LIBC_LOG \ + LIBC_MEM \ LIBC_NEXGEN32E \ LIBC_RAND \ LIBC_RUNTIME \ diff --git a/test/libc/str/regex_test.c b/test/libc/str/regex_test.c index 9cfc55c1..ab92eb74 100644 --- a/test/libc/str/regex_test.c +++ b/test/libc/str/regex_test.c @@ -154,4 +154,17 @@ BENCH(regex, bench) { EZBENCH2("precompiled nosub match", donothing, D(&rx, m)); free(m); regfree(&rx); + EXPECT_EQ(REG_OK, regcomp(&rx, "^[a-z]*$", REG_EXTENDED | REG_NOSUB)); + m = calloc(rx.re_nsub + 1, sizeof(regmatch_t)); + EZBENCH2("precompiled alpha", donothing, + regexec(&rx, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0, 0, 0)); + free(m); + regfree(&rx); + EXPECT_EQ(REG_OK, + regcomp(&rx, "^[a-z]*$", REG_EXTENDED | REG_NOSUB | REG_ICASE)); + m = calloc(rx.re_nsub + 1, sizeof(regmatch_t)); + EZBENCH2("precompiled alpha icase", donothing, + regexec(&rx, "aaaaaaaaaaaaaaaAAAAAAAAAAAAAA", 0, 0, 0)); + free(m); + regfree(&rx); } diff --git a/third_party/zlib/internal.h b/third_party/zlib/internal.h index 3888cfc0..2ef2a672 100644 --- a/third_party/zlib/internal.h +++ b/third_party/zlib/internal.h @@ -18,7 +18,7 @@ void crc_fold_copy(struct DeflateState *const, unsigned char *, const unsigned char *, long) hidden; unsigned crc_fold_512to32(struct DeflateState *const) hidden; void fill_window_sse(struct DeflateState *) hidden; -void *zcalloc(void *, unsigned, unsigned) hidden; +void *zcalloc(void *, uInt, uInt) hidden; void zcfree(void *, void *) hidden; COSMOPOLITAN_C_END_ diff --git a/third_party/zlib/zalloc.c b/third_party/zlib/zalloc.c index e791f50e..6007da99 100644 --- a/third_party/zlib/zalloc.c +++ b/third_party/zlib/zalloc.c @@ -20,7 +20,7 @@ #include "libc/mem/mem.h" #include "third_party/zlib/zutil.internal.h" -void *zcalloc(void *opaque, unsigned items, unsigned size) { +void *zcalloc(void *opaque, uInt items, uInt size) { return weaken(malloc)(items * size); } diff --git a/third_party/zlib/zconf.h b/third_party/zlib/zconf.h index 9147e264..5a7d7272 100644 --- a/third_party/zlib/zconf.h +++ b/third_party/zlib/zconf.h @@ -5,12 +5,12 @@ #define STDC99 #define MAX_MEM_LEVEL 9 #define DEF_MEM_LEVEL 8 -#define MAX_WBITS 15 /* 32K LZ77 window */ +#define MAX_WBITS 15 /* 32K LZ77 window */ #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef unsigned char Byte; -typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uInt; /* 16 bits or more */ typedef unsigned long uLong; /* 32 bits or more */ typedef Byte Bytef; typedef char charf; diff --git a/tool/build/compile.c b/tool/build/compile.c index b52435c5..43709fbe 100644 --- a/tool/build/compile.c +++ b/tool/build/compile.c @@ -91,6 +91,9 @@ bool wantpg; bool wantrecord; bool wantubsan; bool touchtarget; +bool no_sanitize_null; +bool no_sanitize_alignment; +bool no_sanitize_pointer_overflow; char *cmd; char *comdbg; @@ -400,6 +403,12 @@ int main(int argc, char *argv[]) { } else if (!strcmp(argv[i], "-fno-sanitize=all")) { wantasan = false; wantubsan = false; + } else if (!strcmp(argv[i], "-fno-sanitize=null")) { + if (isgcc && ccversion >= 6) no_sanitize_null = true; + } else if (!strcmp(argv[i], "-fno-sanitize=alignment")) { + if (isgcc && ccversion >= 6) no_sanitize_alignment = true; + } else if (!strcmp(argv[i], "-fno-sanitize=pointer-overflow")) { + if (isgcc && ccversion >= 6) no_sanitize_pointer_overflow = true; } else if (startswith(argv[i], "-fsanitize=implicit") && strstr(argv[i], "integer")) { if (isgcc) AddArg(argv[i]); @@ -470,6 +479,15 @@ int main(int argc, char *argv[]) { AddArg("-fsanitize=undefined"); AddArg("-fno-data-sections"); } + if (no_sanitize_null) { + AddArg("-fno-sanitize=null"); + } + if (no_sanitize_alignment) { + AddArg("-fno-sanitize=alignment"); + } + if (no_sanitize_pointer_overflow) { + AddArg("-fno-sanitize=pointer-overflow"); + } if (wantframe) { AddArg("-fno-omit-frame-pointer"); } diff --git a/tool/build/lib/errnos.S b/tool/build/lib/errnos.S index e55c7d25..d665d880 100644 --- a/tool/build/lib/errnos.S +++ b/tool/build/lib/errnos.S @@ -21,14 +21,14 @@ .macro .errno local:req linux:req .globl \local .long \local-kLinuxErrnos - .long \linux + .byte \linux .endm // Lookup table translating errnos between systems. // // @see libc/sysv/systemfive.S .rodata - .align 8 + .align 4 kLinuxErrnos: .errno EPERM,1 .errno ENOENT,2 @@ -85,47 +85,18 @@ kLinuxErrnos: .errno EAFNOSUPPORT,97 .errno EADDRINUSE,98 .errno EADDRNOTAVAIL,99 - .errno ECHRNG,44 .errno EL2NSYNC,45 .errno EL3HLT,46 .errno EL3RST,47 .errno ELNRNG,48 - .errno EUNATCH,49 - .errno ENOCSI,50 - .errno EL2HLT,51 - .errno EBADE,52 - .errno EBADR,53 - .errno EXFULL,54 - .errno ENOANO,55 - .errno EBADRQC,56 - .errno EBADSLT,57 - .errno ENOSTR,60 - .errno ENODATA,61 .errno ETIME,62 - .errno ENOSR,63 .errno ENONET,64 - .errno ENOPKG,65 .errno EREMOTE,66 - .errno ENOLINK,67 - .errno EADV,68 - .errno ESRMNT,69 - .errno ECOMM,70 .errno EPROTO,71 - .errno EMULTIHOP,72 - .errno EDOTDOT,73 .errno EBADMSG,74 .errno EOVERFLOW,75 - .errno ENOTUNIQ,76 - .errno EBADFD,77 - .errno EREMCHG,78 - .errno ELIBACC,79 - .errno ELIBBAD,80 - .errno ELIBSCN,81 - .errno ELIBMAX,82 - .errno ELIBEXEC,83 .errno EILSEQ,84 .errno ERESTART,85 - .errno ESTRPIPE,86 .errno ENETDOWN,100 .errno ENETUNREACH,101 .errno ENETRESET,102 @@ -143,23 +114,10 @@ kLinuxErrnos: .errno EALREADY,114 .errno EINPROGRESS,115 .errno ESTALE,116 - .errno EUCLEAN,117 - .errno ENOTNAM,118 - .errno ENAVAIL,119 - .errno EISNAM,120 - .errno EREMOTEIO,121 .errno EDQUOT,122 - .errno ENOMEDIUM,123 - .errno EMEDIUMTYPE,124 .errno ECANCELED,125 - .errno ENOKEY,126 - .errno EKEYEXPIRED,127 - .errno EKEYREVOKED,128 - .errno EKEYREJECTED,129 .errno EOWNERDEAD,130 .errno ENOTRECOVERABLE,131 - .errno ERFKILL,132 - .errno EHWPOISON,133 + .long 0 + .byte 0 .endobj kLinuxErrnos,globl - kLinuxErrnosLength = (.-kLinuxErrnos)/8 - .globl kLinuxErrnosLength diff --git a/tool/build/lib/xlaterrno.c b/tool/build/lib/xlaterrno.c index a13e2405..8e91c246 100644 --- a/tool/build/lib/xlaterrno.c +++ b/tool/build/lib/xlaterrno.c @@ -21,42 +21,21 @@ #include "libc/runtime/carsort.h" #include "tool/build/lib/xlaterrno.h" -struct LinuxErrno { +struct thatispacked LinuxErrno { int32_t local; - int32_t linux; + uint8_t linux; }; -extern const char kLinuxErrnosLength[]; extern const struct LinuxErrno kLinuxErrnos[]; -static struct LinuxErrno *errnos; /** * Turns local errno into Linux errno. */ int XlatErrno(int local) { - static bool once; - long i, n, m, l, r; - n = (uintptr_t)kLinuxErrnosLength; - if (!once) { - errnos = malloc(sizeof(struct LinuxErrno) * n); - for (i = 0; i < n; ++i) { - errnos[i].local = - *(int *)((intptr_t)kLinuxErrnos + kLinuxErrnos[i].local); - errnos[i].linux = kLinuxErrnos[i].linux; - } - carsort100(n, (void *)errnos); - once = true; - } - l = 0; - r = n - 1; - while (l <= r) { - m = (l + r) / 2; - if (errnos[m].local < local) { - l = m + 1; - } else if (errnos[m].local > local) { - r = m - 1; - } else { - return errnos[m].linux; + int i; + for (i = 0; kLinuxErrnos[i].local; ++i) { + if (local == *(int *)((intptr_t)kLinuxErrnos + kLinuxErrnos[i].local)) { + return kLinuxErrnos[i].linux; } } return ENOSYS; diff --git a/tool/build/runit.c b/tool/build/runit.c index 99a8f86b..cdf58e52 100644 --- a/tool/build/runit.c +++ b/tool/build/runit.c @@ -42,7 +42,6 @@ #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/af.h" -#include "libc/sysv/consts/ai.h" #include "libc/sysv/consts/ex.h" #include "libc/sysv/consts/exit.h" #include "libc/sysv/consts/f.h" diff --git a/tool/decode/lib/socknames.c b/tool/decode/lib/socknames.c index 810db2af..f595987d 100644 --- a/tool/decode/lib/socknames.c +++ b/tool/decode/lib/socknames.c @@ -19,7 +19,6 @@ #include "libc/dns/dns.h" #include "libc/sock/sock.h" #include "libc/sysv/consts/af.h" -#include "libc/sysv/consts/ai.h" #include "libc/sysv/consts/ipproto.h" #include "libc/sysv/consts/sock.h" #include "tool/decode/lib/socknames.h" diff --git a/tool/decode/zip.c b/tool/decode/zip.c index 151f74bd..a9187e05 100644 --- a/tool/decode/zip.c +++ b/tool/decode/zip.c @@ -390,6 +390,13 @@ void ShowCentralDirHeader64(uint8_t *cd) { printf("0:"); disassemblehex(ZIP_CDIR64_COMMENT(cd), ZIP_CDIR64_COMMENTSIZE(cd), stdout); printf("1:\n"); + cd += ZIP_CDIR64_HDRSIZE(cd); + printf("\n/\t%s (%zu %s)\n", "zip64 end of central directory locator", + kZipCdir64LocatorSize, "bytes"); + show(".ascii", format(b1, "%`'.*s", 4, cd), "magic"); + show(".long", format(b1, "%d", READ32LE(cd + 4)), "startingdisk"); + show(".quad", format(b1, "%lu", READ64LE(cd + 4 + 4)), "eocd64 offset"); + show(".long", format(b1, "%d", READ32LE(cd + 4 + 4 + 8)), "totaldisks"); } uint8_t *GetZipCdir32(const uint8_t *p, size_t n) { @@ -406,12 +413,13 @@ uint8_t *GetZipCdir32(const uint8_t *p, size_t n) { } uint8_t *GetZipCdir64(const uint8_t *p, size_t n) { - size_t i; - if (n >= kZipCdir64HdrMinSize) { - i = n - kZipCdir64HdrMinSize; + uint64_t i, j; + if (n >= kZipCdir64LocatorSize) { + i = n - kZipCdir64LocatorSize; do { - if (READ32LE(p + i) == kZipCdir64HdrMagic && IsZipCdir64(p, n, i)) { - return (/*unconst*/ uint8_t *)(p + i); + if (READ32LE(p + i) == kZipCdir64LocatorMagic && + (j = ZIP_LOCATE64_OFFSET(p + i)) + kZipCdir64HdrMinSize <= n) { + return p + j; } } while (i--); } @@ -451,6 +459,7 @@ void DisassembleZip(const char *path, uint8_t *p, size_t n) { ShowCentralFileHeader(cf); pos = (cf - p) + ZIP_CFILE_HDRSIZE(cf); } + /* TODO(jart): This is absurd. */ if (eocd32 && eocd64) { if (eocd32 < eocd64) { ShowCentralDirHeader32(eocd32); @@ -458,8 +467,12 @@ void DisassembleZip(const char *path, uint8_t *p, size_t n) { ShowCentralDirHeader64(eocd64); AdvancePosition(p, &pos, eocd64 - p); } else { + /* pos = eocd64 - p + ZIP_CDIR_HDRSIZE(eocd64); */ + /* AdvancePosition(p, &pos, n); */ ShowCentralDirHeader64(eocd64); AdvancePosition(p, &pos, eocd64 - p); + /* pos = eocd32 - p + ZIP_CDIR_HDRSIZE(eocd32); */ + /* AdvancePosition(p, &pos, n); */ ShowCentralDirHeader32(eocd32); AdvancePosition(p, &pos, eocd32 - p); } @@ -470,11 +483,7 @@ void DisassembleZip(const char *path, uint8_t *p, size_t n) { ShowCentralDirHeader64(eocd64); AdvancePosition(p, &pos, eocd64 - p); } - if (!eocd64 || eocd32 > eocd64) { - pos = eocd32 - p + ZIP_CDIR_HDRSIZE(eocd32); - } else { - pos = eocd64 - p + ZIP_CDIR_HDRSIZE(eocd64); - } + pos = n; AdvancePosition(p, &pos, n); } diff --git a/tool/emacs/cosmo-stuff.el b/tool/emacs/cosmo-stuff.el index 27aa4227..2843afa1 100644 --- a/tool/emacs/cosmo-stuff.el +++ b/tool/emacs/cosmo-stuff.el @@ -440,7 +440,10 @@ (interactive "P") (setq arg (or arg 2)) ;; -ffast-math -funsafe-math-optimizations -fsched2-use-superblocks -fjump-tables - (cond ((not (eq 0 (logand 8 arg))) + (cond ((eq arg 9) + (cosmo--assembly 1 + "V=1 OVERRIDE_COPTS='-fverbose-asm -fsanitize=undefined -fno-sanitize=null -fno-sanitize=alignment -fno-sanitize=pointer-overflow'")) + ((not (eq 0 (logand 8 arg))) (cosmo--assembly (setq arg (logand (lognot 8))) "V=1 OVERRIDE_COPTS='-fverbose-asm -fsanitize=address'")) (t (cosmo--assembly arg "V=1 OVERRIDE_COPTS='' CPPFLAGS='-DSTACK_FRAME_UNLIMITED'")))) diff --git a/tool/net/.help.txt b/tool/net/.help.txt new file mode 100644 index 00000000..5ec858a2 --- /dev/null +++ b/tool/net/.help.txt @@ -0,0 +1,158 @@ +SYNOPSIS + + redbean.com [-hvduzmbagf] [-p PORT] [-- SCRIPTARGS...] + +DESCRIPTION + + redbean - single-file distributable web server + +FLAGS + + -h help + -s increase silence [repeat] + -v increase verbosity [repeat] + -d daemonize + -u uniprocess + -z print port + -m log messages + -b log message body + -a log resource usage + -g log handler latency + -f log worker function calls + -H K:V sets http header globally [repeat] + -D DIR serve assets from local directory [repeat] + -t MS tunes read and write timeouts [default 30000] + -M INT tunes max message payload size [default 65536] + -c SEC configures static asset cache-control headers + -r /X=/Y redirect X to Y [repeat] + -R /X=/Y rewrites X to Y [repeat] + -l ADDR listen ip [default 0.0.0.0] + -p PORT listen port [default 8080] + -L PATH log file location + -P PATH pid file location + -U INT daemon set user id + -G INT daemon set group id + +FEATURES + + - Lua v5.4 + - HTTP v0.9 + - HTTP v1.0 + - HTTP v1.1 + - Pipelining + - Accounting + - Content-Encoding + - Range / Content-Range + - Last-Modified / If-Modified-Since + +USAGE + + This executable is also a ZIP file that contains static assets. + You can run redbean interactively in your terminal as follows: + + ./redbean.com -vvvmbag # starts server verbosely + open http://127.0.0.1:8080/ # shows zip listing page + CTRL-C # 1x: graceful shutdown + CTRL-C # 2x: forceful shutdown + + You can override the default listing page by adding: + + zip redbean.com index.lua # lua server pages take priority + zip redbean.com index.html # default page for directory + + The listing page only applies to the root directory. However the + default index page applies to subdirectories too. In order for it + to work, there needs to be an empty directory entry in the zip. + That should already be the default practice of your zip editor. + + wget \ + --mirror \ + --convert-links \ + --adjust-extension \ + --page-requisites \ + --no-parent \ + --no-if-modified-since \ + http://a.example/index.html + zip -r redbean.com a.example/ # default page for directory + + redbean normalizes the trailing slash for you automatically: + + $ printf 'GET /a.example HTTP/1.0\n\n' | nc 127.0.0.1 8080 + HTTP/1.0 307 Temporary Redirect + Location: /a.example/ + + Virtual hosting is accomplished this way too. The Host is simply + prepended to the path, and if it doesn't exist, it gets removed. + + $ printf 'GET / HTTP/1.1\nHost:a.example\n\n' | nc 127.0.0.1 8080 + HTTP/1.1 200 OK + Link: ; rel="canonical" + + If you mirror a lot of websites within your redbean then you can + actually tell your browser that redbean is your proxy server, in + which redbean will act as your private version of the Internet. + + $ printf 'GET http://a.example HTTP/1.0\n\n' | nc 127.0.0.1 8080 + HTTP/1.0 200 OK + Link: ; rel="canonical" + + If you use a reverse proxy, then redbean recognizes the following + provided that the proxy forwards requests over the local network: + + X-Forwarded-For: 203.0.113.42:31337 + X-Forwarded-Host: foo.example:80 + + There's a text/plain statistics page called /statusz that makes + it easy to track and monitor the health of your redbean: + + printf 'GET /statusz\n\n' | nc 127.0.0.1 8080 + + redbean will display an error page using the /redbean.png logo + by default, embedded as a bas64 data uri. You can override the + custom page for various errors by adding files to the zip root. + + zip redbean.com 404.html # custom not found page + + Audio video content should not be compressed in your ZIP files. + Uncompressed assets enable browsers to send Range HTTP request. + On the other hand compressed assets are best for gzip encoding. + + zip redbean.com index.html # adds file + zip -0 redbean.com video.mp4 # adds without compression + + You can have redbean run as a daemon by doing the following: + + redbean.com -vv -d -L redbean.log -P redbean.pid + kill -TERM $(cat redbean.pid) # 1x: graceful shutdown + kill -TERM $(cat redbean.pid) # 2x: forceful shutdown + + redbean currently has a 32kb limit on request messages and 64kb + including the payload. redbean will grow to whatever the system + limits allow. Should fork() or accept() fail redbean will react + by going into "meltdown mode" which closes lingering workers. + You can trigger this at any time using: + + kill -USR2 $(cat redbean.pid) + + Another failure condition is running out of disk space in which + case redbean reacts by truncating the log file. Lastly, redbean + does the best job possible reporting on resource usage when the + logger is in debug mode noting that NetBSD is the best at this. + + Your redbean is an actually portable executable, that's able to + run on six different operating systems. To do that, it needs to + overwrite its own MZ header at startup, with ELF or Mach-O, and + then puts the original back once the program loads. If you want + your redbean to follow the platform-local executable convention + then delete the /.ape file from zip. + + redbean contains software licensed ISC, MIT, BSD-2, BSD-3, zlib + which makes it a permissively licensed gift to anyone who might + find it useful. The transitive closure of legalese can be found + inside the binary. redbean also respects your privacy and won't + phone home because your computer is its home. + +SEE ALSO + + https://justine.lol/redbean/index.html + https://news.ycombinator.com/item?id=26271117 diff --git a/tool/net/demo/redbean.lua b/tool/net/demo/redbean.lua index 43fd7e63..be999620 100644 --- a/tool/net/demo/redbean.lua +++ b/tool/net/demo/redbean.lua @@ -164,7 +164,7 @@ local function main() Write(EscapeHtml(VisualizeControlCodes(GetFragment()))) Write('\r\n') end - Write('
GetRemoteAddr() (from Bekeley Sockets or X-Forwarded-For header)\r\n') + Write('
GetRemoteAddr() (from Berkeley Sockets or X-Forwarded-For header)\r\n') Write('
') ip, port = GetRemoteAddr() Write(string.format('%s, %d', FormatIp(ip), port)) diff --git a/tool/net/dig.c b/tool/net/dig.c index ab56fa11..2c734bbf 100644 --- a/tool/net/dig.c +++ b/tool/net/dig.c @@ -23,7 +23,6 @@ #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/af.h" -#include "libc/sysv/consts/ai.h" #include "libc/sysv/consts/ipproto.h" #include "libc/sysv/consts/sock.h" #include "tool/decode/lib/flagger.h" @@ -44,7 +43,8 @@ void lookup(const char *name) { perror("getaddrinfo"); exit(1); default: - fprintf(stderr, "getaddrinfo failed: %d (EAI_%s)\n", rc, gai_strerror(rc)); + fprintf(stderr, "getaddrinfo failed: %d (EAI_%s)\n", rc, + gai_strerror(rc)); exit(1); } if (addrs) { diff --git a/tool/net/net.mk b/tool/net/net.mk index 8750ca00..c61ee0bb 100644 --- a/tool/net/net.mk +++ b/tool/net/net.mk @@ -72,12 +72,13 @@ o/$(MODE)/tool/net/redbean.com.dbg: \ o/$(MODE)/tool/net/redbean.com: \ o/$(MODE)/tool/net/redbean.com.dbg \ tool/net/net.mk \ + tool/net/.help.txt \ tool/net/.init.lua \ tool/net/favicon.ico \ tool/net/redbean.png @$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@ @$(COMPILE) -ADD -T$@ dd if=$@ of=o/$(MODE)/tool/net/.ape bs=64 count=11 conv=notrunc 2>/dev/null - @$(COMPILE) -AZIP -T$@ zip -qj $@ o/$(MODE)/tool/net/.ape tool/net/.init.lua tool/net/favicon.ico tool/net/redbean.png + @$(COMPILE) -AZIP -T$@ zip -qj $@ o/$(MODE)/tool/net/.ape tool/net/.help.txt tool/net/.init.lua tool/net/favicon.ico tool/net/redbean.png o/$(MODE)/tool/net/redbean-demo.com.dbg: \ o/$(MODE)/tool/net/redbean.com.dbg @@ -88,6 +89,7 @@ o/$(MODE)/tool/net/redbean-demo.com: \ tool/net/net.mk \ tool/net/favicon.ico \ tool/net/redbean.png \ + tool/net/.help.txt \ tool/net/demo/.init.lua \ tool/net/demo/.reload.lua \ tool/net/demo/404.html \ @@ -108,7 +110,7 @@ o/$(MODE)/tool/net/redbean-demo.com: \ @$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@ @$(COMPILE) -AMKDIR -T$@ mkdir -p o/$(MODE)/tool/net/.redbean-demo @$(COMPILE) -ADD -T$@ dd if=$@ of=o/$(MODE)/tool/net/.redbean-demo/.ape bs=64 count=11 conv=notrunc 2>/dev/null - @$(COMPILE) -AZIP -T$@ zip -qj $@ o/$(MODE)/tool/net/.redbean-demo/.ape tool/net/demo/.init.lua tool/net/demo/.reload.lua tool/net/demo/hello.lua + @$(COMPILE) -AZIP -T$@ zip -qj $@ o/$(MODE)/tool/net/.redbean-demo/.ape tool/net/.help.txt tool/net/demo/.init.lua tool/net/demo/.reload.lua tool/net/demo/hello.lua @echo "<-- check out this lua server page" | $(COMPILE) -AZIP -T$@ zip -cqj $@ tool/net/demo/redbean.lua @$(COMPILE) -AZIP -T$@ zip -qj $@ tool/net/demo/404.html tool/net/favicon.ico tool/net/redbean.png tool/net/demo/redbean-form.lua tool/net/demo/redbean-xhr.lua @echo Uncompressed for HTTP Range requests | $(COMPILE) -AZIP -T$@ zip -cqj0 $@ tool/net/demo/seekable.txt diff --git a/tool/net/redbean.c b/tool/net/redbean.c index fc45334d..ff459ff9 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -22,6 +22,7 @@ #include "libc/bits/safemacros.internal.h" #include "libc/calls/calls.h" #include "libc/calls/sigbits.h" +#include "libc/calls/struct/flock.h" #include "libc/calls/struct/itimerval.h" #include "libc/calls/struct/rusage.h" #include "libc/calls/struct/sigaction.h" @@ -30,9 +31,11 @@ #include "libc/errno.h" #include "libc/fmt/conv.h" #include "libc/fmt/itoa.h" +#include "libc/intrin/asan.internal.h" #include "libc/log/check.h" #include "libc/log/log.h" #include "libc/math.h" +#include "libc/mem/alloca.h" #include "libc/mem/fmt.h" #include "libc/nexgen32e/bsf.h" #include "libc/nexgen32e/bsr.h" @@ -49,6 +52,7 @@ #include "libc/sysv/consts/auxv.h" #include "libc/sysv/consts/ex.h" #include "libc/sysv/consts/exit.h" +#include "libc/sysv/consts/f.h" #include "libc/sysv/consts/inaddr.h" #include "libc/sysv/consts/ipproto.h" #include "libc/sysv/consts/itimer.h" @@ -212,8 +216,11 @@ struct Buffer { }; struct Strings { - size_t n; - char **p; + size_t n, c; + struct String { + size_t n; + const char *s; + } * p; }; static struct Freelist { @@ -234,9 +241,8 @@ static struct Redirects { size_t n; struct Redirect { int code; - const char *path; - size_t pathlen; - const char *location; + struct String path; + struct String location; } * p; } redirects; @@ -250,7 +256,7 @@ static struct Assets { int64_t lastmodified; char *lastmodifiedstr; struct File { - char *path; + struct String path; struct stat st; } * file; } * p; @@ -303,7 +309,6 @@ static bool loggednetworkorigin; static bool hasluaglobalhandler; static int zfd; -static int zprot; static int frags; static int gmtoff; static int server; @@ -319,6 +324,7 @@ static lua_State *L; static size_t zsize; static char *content; static uint8_t *zmap; +static uint8_t *zbase; static uint8_t *zcdir; static size_t hdrsize; static size_t msgsize; @@ -364,178 +370,6 @@ static char *HandleAsset(struct Asset *, const char *, size_t); static char *ServeAsset(struct Asset *, const char *, size_t); static char *SetStatus(unsigned, const char *); -static wontreturn void PrintUsage(FILE *f, int rc) { - /* clang-format off */ - fprintf(f, "\ -SYNOPSIS\n\ -\n\ - %s [-hvduzmbagf] [-p PORT] [-- SCRIPTARGS...]\n\ -\n\ -DESCRIPTION\n\ -\n\ - redbean - single-file distributable web server\n\ -\n\ -FLAGS\n\ -\n\ - -h help\n\ - -s increase silence [repeat]\n\ - -v increase verbosity [repeat]\n\ - -d daemonize\n\ - -u uniprocess\n\ - -z print port\n\ - -m log messages\n\ - -b log message body\n\ - -a log resource usage\n\ - -g log handler latency\n" -#ifndef TINY -" -f log worker function calls\n" -#endif -" -H K:V sets http header globally [repeat]\n\ - -D DIR serve assets from local directory [repeat]\n\ - -t MS tunes read and write timeouts [default 30000]\n\ - -M INT tunes max message payload size [default 65536]\n\ - -c SEC configures static asset cache-control headers\n\ - -r /X=/Y redirect X to Y [repeat]\n\ - -R /X=/Y rewrites X to Y [repeat]\n\ - -l ADDR listen ip [default 0.0.0.0]\n\ - -p PORT listen port [default 8080]\n\ - -L PATH log file location\n\ - -P PATH pid file location\n\ - -U INT daemon set user id\n\ - -G INT daemon set group id\n\ -\n\ -FEATURES\n\ -\n" -#ifndef STATIC -" - Lua v5.4\n" -#endif -" - HTTP v0.9\n\ - - HTTP v1.0\n\ - - HTTP v1.1\n\ - - Pipelining\n\ - - Accounting\n\ - - Content-Encoding\n\ - - Range / Content-Range\n\ - - Last-Modified / If-Modified-Since\n\ -\n\ -USAGE\n\ -\n\ - This executable is also a ZIP file that contains static assets.\n\ - You can run redbean interactively in your terminal as follows:\n\ -\n\ - ./redbean.com -vvvmbag # starts server verbosely\n\ - open http://127.0.0.1:8080/ # shows zip listing page\n\ - CTRL-C # 1x: graceful shutdown\n\ - CTRL-C # 2x: forceful shutdown\n\ -\n\ - You can override the default listing page by adding:\n\ -\n" -#ifndef STATIC -" zip redbean.com index.lua # lua server pages take priority\n" -#endif -" zip redbean.com index.html # default page for directory\n\ -\n\ - The listing page only applies to the root directory. However the\n\ - default index page applies to subdirectories too. In order for it\n\ - to work, there needs to be an empty directory entry in the zip.\n\ - That should already be the default practice of your zip editor.\n\ -\n\ - wget \\\n\ - --mirror \\\n\ - --convert-links \\\n\ - --adjust-extension \\\n\ - --page-requisites \\\n\ - --no-parent \\\n\ - --no-if-modified-since \\\n\ - http://a.example/index.html\n\ - zip -r redbean.com a.example/ # default page for directory\n\ -\n\ - redbean normalizes the trailing slash for you automatically:\n\ -\n\ - $ printf 'GET /a.example HTTP/1.0\\n\\n' | nc 127.0.0.1 8080\n\ - HTTP/1.0 307 Temporary Redirect\n\ - Location: /a.example/\n\ -\n\ - Virtual hosting is accomplished this way too. The Host is simply\n\ - prepended to the path, and if it doesn't exist, it gets removed.\n\ -\n\ - $ printf 'GET / HTTP/1.1\\nHost:a.example\\n\\n' | nc 127.0.0.1 8080\n\ - HTTP/1.1 200 OK\n\ - Link: ; rel=\"canonical\"\n\ -\n\ - If you mirror a lot of websites within your redbean then you can\n\ - actually tell your browser that redbean is your proxy server, in\n\ - which redbean will act as your private version of the Internet.\n\ -\n\ - $ printf 'GET http://a.example HTTP/1.0\\n\\n' | nc 127.0.0.1 8080\n\ - HTTP/1.0 200 OK\n\ - Link: ; rel=\"canonical\"\n\ -\n\ - If you use a reverse proxy, then redbean recognizes the following\n\ - provided that the proxy forwards requests over the local network:\n\ -\n\ - X-Forwarded-For: 203.0.113.42:31337\n\ - X-Forwarded-Host: foo.example:80\n\ -\n\ - There's a text/plain statistics page called /statusz that makes\n\ - it easy to track and monitor the health of your redbean:\n\ -\n\ - printf 'GET /statusz\\n\\n' | nc 127.0.0.1 8080\n\ -\n\ - redbean will display an error page using the /redbean.png logo\n\ - by default, embedded as a bas64 data uri. You can override the\n\ - custom page for various errors by adding files to the zip root.\n\ -\n\ - zip redbean.com 404.html # custom not found page\n\ -\n\ - Audio video content should not be compressed in your ZIP files.\n\ - Uncompressed assets enable browsers to send Range HTTP request.\n\ - On the other hand compressed assets are best for gzip encoding.\n\ -\n\ - zip redbean.com index.html # adds file\n\ - zip -0 redbean.com video.mp4 # adds without compression\n\ -\n\ - You can have redbean run as a daemon by doing the following:\n\ -\n\ - redbean.com -vv -d -L redbean.log -P redbean.pid\n\ - kill -TERM $(cat redbean.pid) # 1x: graceful shutdown\n\ - kill -TERM $(cat redbean.pid) # 2x: forceful shutdown\n\ -\n\ - redbean currently has a 32kb limit on request messages and 64kb\n\ - including the payload. redbean will grow to whatever the system\n\ - limits allow. Should fork() or accept() fail redbean will react\n\ - by going into \"meltdown mode\" which closes lingering workers.\n\ - You can trigger this at any time using:\n\ -\n\ - kill -USR2 $(cat redbean.pid)\n\ -\n\ - Another failure condition is running out of disk space in which\n\ - case redbean reacts by truncating the log file. Lastly, redbean\n\ - does the best job possible reporting on resource usage when the\n\ - logger is in debug mode noting that NetBSD is the best at this.\n\ -\n\ - Your redbean is an actually portable executable, that's able to\n\ - run on six different operating systems. To do that, it needs to\n\ - overwrite its own MZ header at startup, with ELF or Mach-O, and\n\ - then puts the original back once the program loads. If you want\n\ - your redbean to follow the platform-local executable convention\n\ - then delete the /.ape file from zip.\n\ -\n\ - redbean contains software licensed ISC, MIT, BSD-2, BSD-3, zlib\n\ - which makes it a permissively licensed gift to anyone who might\n\ - find it useful. The transitive closure of legalese can be found\n\ - inside the binary. redbean also respects your privacy and won't\n\ - phone home because your computer is its home.\n\ -\n\ -SEE ALSO\n\ -\n\ - https://justine.lol/redbean/index.html\n\ - https://news.ycombinator.com/item?id=26271117\n\ -\n", program_invocation_name); - /* clang-format on */ - exit(rc); -} - static void OnChld(void) { zombied = true; } @@ -601,8 +435,7 @@ static int CompareSlicesCase(const char *a, size_t n, const char *b, size_t m) { static void *FreeLater(void *p) { if (p) { if (++freelist.n > freelist.c) { - freelist.c = freelist.n + 2; - freelist.c += freelist.c >> 1; + freelist.c = freelist.n + (freelist.n >> 1); freelist.p = xrealloc(freelist.p, freelist.c * sizeof(*freelist.p)); } freelist.p[freelist.n - 1] = p; @@ -612,8 +445,7 @@ static void *FreeLater(void *p) { static void UnmapLater(int f, void *p, size_t n) { if (++unmaplist.n > unmaplist.c) { - unmaplist.c = unmaplist.n + 2; - unmaplist.c += unmaplist.c >> 1; + unmaplist.c = unmaplist.n + (unmaplist.n >> 1); unmaplist.p = xrealloc(unmaplist.p, unmaplist.c * sizeof(*unmaplist.p)); } unmaplist.p[unmaplist.n - 1].f = f; @@ -698,13 +530,13 @@ static char *MergePaths(const char *p, size_t n, const char *q, size_t m, return r; } -static long FindRedirect(const char *path, size_t n) { +static long FindRedirect(const char *s, size_t n) { int c, m, l, r, z; l = 0; r = redirects.n - 1; while (l <= r) { m = (l + r) >> 1; - c = CompareSlices(redirects.p[m].path, redirects.p[m].pathlen, path, n); + c = CompareSlices(redirects.p[m].path.s, redirects.p[m].path.n, s, n); if (c < 0) { l = m + 1; } else if (c > 0) { @@ -716,7 +548,8 @@ static long FindRedirect(const char *path, size_t n) { return -1; } -static void ProgramRedirect(int code, const char *src, const char *dst) { +static void ProgramRedirect(int code, const char *sp, size_t sn, const char *dp, + size_t dn) { long i, j; struct Redirect r; if (code && code != 301 && code != 302 && code != 307 && code != 308) { @@ -724,17 +557,18 @@ static void ProgramRedirect(int code, const char *src, const char *dst) { exit(1); } r.code = code; - r.path = strdup(src); - r.pathlen = strlen(src); - r.location = strdup(dst); - if ((i = FindRedirect(r.path, r.pathlen)) != -1) { + r.path.s = sp; + r.path.n = sn; + r.location.s = dp; + r.location.n = dn; + if ((i = FindRedirect(r.path.s, r.path.n)) != -1) { redirects.p[i] = r; } else { i = redirects.n; redirects.p = xrealloc(redirects.p, (i + 1) * sizeof(*redirects.p)); for (j = i; j; --j) { - if (CompareSlices(r.path, r.pathlen, redirects.p[j - 1].path, - redirects.p[j - 1].pathlen) < 0) { + if (CompareSlices(r.path.s, r.path.n, redirects.p[j - 1].path.s, + redirects.p[j - 1].path.n) < 0) { redirects.p[j] = redirects.p[j - 1]; } else { break; @@ -745,15 +579,15 @@ static void ProgramRedirect(int code, const char *src, const char *dst) { } } -static void ProgramRedirectArg(int code, const char *arg) { - char *s; +static void ProgramRedirectArg(int code, const char *s) { + size_t n; const char *p; - if (!(p = strchr(arg, '='))) { + n = strlen(s); + if (!(p = memchr(s, '=', n))) { fprintf(stderr, "error: redirect arg missing '='\n"); exit(1); } - ProgramRedirect(code, (s = strndup(arg, p - arg)), p + 1); - free(s); + ProgramRedirect(code, s, p - s, p + 1, n - (p - s + 1)); } static void DescribeAddress(char buf[32], uint32_t addr, uint16_t port) { @@ -862,36 +696,33 @@ static void SetDefaults(void) { if (IsWindows()) uniprocess = true; } -static char *RemoveTrailingSlashes(char *s) { - size_t n; - n = strlen(s); - while (n && (s[n - 1] == '/' || s[n - 1] == '\\')) s[--n] = '\0'; - return s; +static void AddString(struct Strings *l, const char *s, size_t n) { + if (++l->n > l->c) { + l->c = l->n + (l->n >> 1); + l->p = xrealloc(l->p, l->c * sizeof(*l->p)); + } + l->p[l->n - 1].s = s; + l->p[l->n - 1].n = n; } -static void AddString(struct Strings *l, char *s) { - l->p = xrealloc(l->p, ++l->n * sizeof(*l->p)); - l->p[l->n - 1] = s; -} - -static bool HasString(struct Strings *l, char *s) { +static bool HasString(struct Strings *l, const char *s, size_t n) { size_t i; for (i = 0; i < l->n; ++i) { - if (!strcmp(l->p[i], s)) { + if (SlicesEqual(l->p[i].s, l->p[i].n, s, n)) { return true; } } return false; } -static void AddStagingDirectory(const char *dirpath) { - char *s; - s = RemoveTrailingSlashes(strdup(dirpath)); - if (isempty(s) || !isdirectory(s)) { +static void AddStagingDirectory(char *s) { + size_t n = strlen(s); + while (n && (s[n - 1] == '/' || s[n - 1] == '\\')) s[--n] = 0; + if (!n || !isdirectory(s)) { fprintf(stderr, "error: not a directory: %`'s\n", s); exit(1); } - AddString(&stagedirs, s); + AddString(&stagedirs, s, n); } static void ProgramHeader(const char *s) { @@ -922,102 +753,10 @@ static void ProgramHeader(const char *s) { } } -static void GetOpts(int argc, char *argv[]) { - int opt; - while ((opt = getopt(argc, argv, - "azhdugvsmbfl:p:r:R:H:c:L:P:U:G:B:D:t:M:")) != -1) { - switch (opt) { - case 'v': - __log_level++; - break; - case 's': - __log_level--; - break; - case 'd': - daemonize = true; - break; - case 'a': - logrusage = true; - break; - case 'u': - uniprocess = true; - break; - case 'g': - loglatency = true; - break; - case 'm': - logmessages = true; - break; - case 'b': - logbodies = true; - break; - case 'z': - printport = true; - break; - case 'f': - funtrace = true; - break; - case 'k': - encouragekeepalive = true; - break; - case 't': - ProgramTimeout(strtol(optarg, NULL, 0)); - break; - case 'r': - ProgramRedirectArg(307, optarg); - break; - case 'R': - ProgramRedirectArg(0, optarg); - break; - case 'D': - AddStagingDirectory(optarg); - break; - case 'c': - ProgramCache(strtol(optarg, NULL, 0)); - break; - case 'p': - ProgramPort(strtol(optarg, NULL, 0)); - break; - case 'M': - maxpayloadsize = atoi(optarg); - maxpayloadsize = MAX(1450, maxpayloadsize); - break; - case 'l': - CHECK_EQ(1, inet_pton(AF_INET, optarg, &serveraddr.sin_addr)); - break; - case 'B': - ProgramBrand(optarg); - break; - case 'H': - ProgramHeader(optarg); - break; - case 'L': - logpath = optarg; - break; - case 'P': - pidpath = optarg; - break; - case 'U': - daemonuid = atoi(optarg); - break; - case 'G': - daemongid = atoi(optarg); - break; - case 'h': - PrintUsage(stdout, EXIT_SUCCESS); - default: - PrintUsage(stderr, EX_USAGE); - } - } - if (logpath) { - CHECK_NOTNULL(freopen(logpath, "a", stderr)); - } -} - static void Daemonize(void) { char ibuf[21]; int i, fd, pid; - for (i = 3; i < 128; ++i) { + for (i = 0; i < 128; ++i) { if (i != server) { close(i); } @@ -1032,9 +771,9 @@ static void Daemonize(void) { close(fd); } if (!logpath) logpath = "/dev/null"; - freopen("/dev/null", "r", stdin); - freopen(logpath, "a", stdout); - freopen(logpath, "a", stderr); + open("/dev/null", O_RDONLY); + open(logpath, O_APPEND | O_WRONLY | O_CREAT, 0640); + dup2(1, 2); LOGIFNEG1(setgid(daemongid)); LOGIFNEG1(setuid(daemonuid)); } @@ -1259,11 +998,11 @@ static int64_t GetZipCfileLastModified(const uint8_t *zcf) { for (p = ZIP_CFILE_EXTRA(zcf), pe = p + ZIP_CFILE_EXTRASIZE(zcf); p + 4 <= pe; p += ZIP_EXTRA_SIZE(p)) { if (ZIP_EXTRA_HEADERID(p) == kZipExtraNtfs && - ZIP_EXTRA_CONTENTSIZE(p) >= 4 + 4 + 8 * 3 && + ZIP_EXTRA_CONTENTSIZE(p) >= 4 + 4 + 8 && READ16LE(ZIP_EXTRA_CONTENT(p) + 4) == 1 && - READ16LE(ZIP_EXTRA_CONTENT(p) + 6) == 24) { + READ16LE(ZIP_EXTRA_CONTENT(p) + 6) >= 8) { return READ64LE(ZIP_EXTRA_CONTENT(p) + 8) / HECTONANOSECONDS - - MODERNITYSECONDS; + MODERNITYSECONDS; /* TODO(jart): update access time */ } } for (p = ZIP_CFILE_EXTRA(zcf), pe = p + ZIP_CFILE_EXTRASIZE(zcf); p + 4 <= pe; @@ -1284,13 +1023,38 @@ static int64_t GetZipCfileLastModified(const uint8_t *zcf) { ZIP_CFILE_LASTMODIFIEDTIME(zcf))); } +static int64_t GetZipCfileCreation(const uint8_t *zcf) { + const uint8_t *p, *pe; + for (p = ZIP_CFILE_EXTRA(zcf), pe = p + ZIP_CFILE_EXTRASIZE(zcf); p + 4 <= pe; + p += ZIP_EXTRA_SIZE(p)) { + if (ZIP_EXTRA_HEADERID(p) == kZipExtraNtfs && + ZIP_EXTRA_CONTENTSIZE(p) >= 4 + 4 + 8 * 3 && + READ16LE(ZIP_EXTRA_CONTENT(p) + 4) == 1 && + READ16LE(ZIP_EXTRA_CONTENT(p) + 6) >= 24) { + return READ64LE(ZIP_EXTRA_CONTENT(p) + 8 + 8 + 8) / HECTONANOSECONDS - + MODERNITYSECONDS; + } + } + for (p = ZIP_CFILE_EXTRA(zcf), pe = p + ZIP_CFILE_EXTRASIZE(zcf); p + 4 <= pe; + p += ZIP_EXTRA_SIZE(p)) { + if (ZIP_EXTRA_HEADERID(p) == kZipExtraExtendedTimestamp && + ZIP_EXTRA_CONTENTSIZE(p) >= 1 && (*ZIP_EXTRA_CONTENT(p) & 4) && + ZIP_EXTRA_CONTENTSIZE(p) >= + 1 + popcnt((*ZIP_EXTRA_CONTENT(p) & 7)) * 4) { + return (int32_t)READ32LE(ZIP_EXTRA_CONTENT(p) + 1 + + popcnt((*ZIP_EXTRA_CONTENT(p) & 3)) * 4); + } + } + return GetZipCfileLastModified(zcf); +} + forceinline bool IsCompressed(struct Asset *a) { return !a->file && - ZIP_LFILE_COMPRESSIONMETHOD(zmap + a->lf) == kZipCompressionDeflate; + ZIP_LFILE_COMPRESSIONMETHOD(zbase + a->lf) == kZipCompressionDeflate; } forceinline int GetMode(struct Asset *a) { - return a->file ? a->file->st.st_mode : GetZipCfileMode(zmap + a->cf); + return a->file ? a->file->st.st_mode : GetZipCfileMode(zbase + a->cf); } static char *FormatUnixHttpDateTime(char *s, int64_t t) { @@ -1318,31 +1082,33 @@ static void IndexAssets(void) { uint64_t cf; struct Asset *p; uint32_t i, n, m, step, hash; + DEBUGF("indexing assets"); CHECK_GE(HASH_LOAD_FACTOR, 2); CHECK(READ32LE(zcdir) == kZipCdir64HdrMagic || READ32LE(zcdir) == kZipCdirHdrMagic); n = GetZipCdirRecords(zcdir); m = roundup2pow(MAX(1, n) * HASH_LOAD_FACTOR); p = xcalloc(m, sizeof(struct Asset)); - for (cf = GetZipCdirOffset(zcdir); n--; cf += ZIP_CFILE_HDRSIZE(zmap + cf)) { - CHECK_EQ(kZipCfileHdrMagic, ZIP_CFILE_MAGIC(zmap + cf)); - if (!IsCompressionMethodSupported(ZIP_CFILE_COMPRESSIONMETHOD(zmap + cf))) { + for (cf = GetZipCdirOffset(zcdir); n--; cf += ZIP_CFILE_HDRSIZE(zbase + cf)) { + CHECK_EQ(kZipCfileHdrMagic, ZIP_CFILE_MAGIC(zbase + cf)); + if (!IsCompressionMethodSupported( + ZIP_CFILE_COMPRESSIONMETHOD(zbase + cf))) { LOGF("don't understand zip compression method %d used by %`'.*s", - ZIP_CFILE_COMPRESSIONMETHOD(zmap + cf), - ZIP_CFILE_NAMESIZE(zmap + cf), ZIP_CFILE_NAME(zmap + cf)); + ZIP_CFILE_COMPRESSIONMETHOD(zbase + cf), + ZIP_CFILE_NAMESIZE(zbase + cf), ZIP_CFILE_NAME(zbase + cf)); continue; } - hash = Hash(ZIP_CFILE_NAME(zmap + cf), ZIP_CFILE_NAMESIZE(zmap + cf)); + hash = Hash(ZIP_CFILE_NAME(zbase + cf), ZIP_CFILE_NAMESIZE(zbase + cf)); step = 0; do { i = (hash + (step * (step + 1)) >> 1) & (m - 1); ++step; } while (p[i].hash); - lm = GetZipCfileLastModified(zmap + cf); + lm = GetZipCfileLastModified(zbase + cf); p[i].hash = hash; p[i].cf = cf; - p[i].lf = GetZipCfileOffset(zmap + cf); - p[i].istext = !!(ZIP_CFILE_INTERNALATTRIBUTES(zmap + cf) & kZipIattrText); + p[i].lf = GetZipCfileOffset(zbase + cf); + p[i].istext = !!(ZIP_CFILE_INTERNALATTRIBUTES(zbase + cf) & kZipIattrText); p[i].lastmodified = lm; p[i].lastmodifiedstr = FormatUnixHttpDateTime(xmalloc(30), lm); } @@ -1350,32 +1116,54 @@ static void IndexAssets(void) { assets.n = m; } -static bool ZipCdirChanged(void) { +static bool OpenZip(bool force) { + int fd; + size_t n; struct stat st; - if (!IsZipCdir32(zmap, zsize, zcdir - zmap) && - !IsZipCdir64(zmap, zsize, zcdir - zmap)) { - return true; - } - if (stat(zpath, &st) != -1 && st.st_ino != zst.st_ino) { - return true; + uint8_t *m, *b, *d, *p; + if (stat(zpath, &st) != -1) { + if (force || st.st_ino != zst.st_ino || st.st_size > zst.st_size) { + if (st.st_ino == zst.st_ino) { + fd = zfd; + } else if ((fd = open(zpath, O_RDWR)) == -1) { + WARNF("open() failed w/ %m"); + return false; + } + if ((m = mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0)) != + MAP_FAILED) { + n = st.st_size; + if (endswith(zpath, ".com.dbg") && (p = memmem(m, n, "MZqFpD", 6))) { + b = p; + n -= p - m; + } else { + b = m; + } + if ((d = GetZipCdir(b, n))) { + if (zmap) { + LOGIFNEG1(munmap(zmap, zbase + zsize - zmap)); + } + zmap = m; + zbase = b; + zsize = n; + zcdir = d; + DCHECK(IsZipCdir32(zbase, zsize, zcdir - zbase) || + IsZipCdir64(zbase, zsize, zcdir - zbase)); + memcpy(&zst, &st, sizeof(st)); + IndexAssets(); + return true; + } else { + WARNF("couldn't locate central directory"); + } + } else { + WARNF("mmap() failed w/ %m"); + } + } + } else { + WARNF("stat() failed w/ %m"); } return false; } -static void OpenZip(void) { - uint8_t *p; - if (zmap) munmap(zmap, zsize); - CHECK_NE(-1, fstat(zfd, &zst)); - CHECK((zsize = zst.st_size)); - CHECK_NE(MAP_FAILED, (zmap = mmap((void *)0x0000300000000000, zsize, zprot, - MAP_FIXED | MAP_SHARED, zfd, 0))); - CHECK_NOTNULL((zcdir = GetZipCdir(zmap, zsize))); - if (endswith(zpath, ".com.dbg") && (p = memmem(zmap, zsize, "MZqFpD", 6))) { - zsize -= p - zmap; - zmap = p; - } -} - static struct Asset *GetAssetZip(const char *path, size_t pathlen) { uint32_t i, step, hash; if (pathlen > 1 && path[0] == '/') ++path, --pathlen; @@ -1384,8 +1172,8 @@ static struct Asset *GetAssetZip(const char *path, size_t pathlen) { i = (hash + (step * (step + 1)) >> 1) & (assets.n - 1); if (!assets.p[i].hash) return NULL; if (hash == assets.p[i].hash && - pathlen == ZIP_CFILE_NAMESIZE(zmap + assets.p[i].cf) && - memcmp(path, ZIP_CFILE_NAME(zmap + assets.p[i].cf), pathlen) == 0) { + pathlen == ZIP_CFILE_NAMESIZE(zbase + assets.p[i].cf) && + memcmp(path, ZIP_CFILE_NAME(zbase + assets.p[i].cf), pathlen) == 0) { return &assets.p[i]; } } @@ -1399,9 +1187,9 @@ static struct Asset *GetAssetFile(const char *path, size_t pathlen) { a->file = FreeLater(xmalloc(sizeof(struct File))); for (i = 0; i < stagedirs.n; ++i) { LockInc(&shared->c.stats); - a->file->path = FreeLater( - MergePaths(stagedirs.p[i], strlen(stagedirs.p[i]), path, pathlen, 0)); - if (stat(a->file->path, &a->file->st) != -1) { + a->file->path.s = FreeLater(MergePaths(stagedirs.p[i].s, stagedirs.p[i].n, + path, pathlen, &a->file->path.n)); + if (stat(a->file->path.s, &a->file->st) != -1) { a->lastmodifiedstr = FormatUnixHttpDateTime( FreeLater(xmalloc(30)), (a->lastmodified = a->file->st.st_mtim.tv_sec)); @@ -1488,6 +1276,7 @@ static char *AppendContentRange(char *p, long a, long b, long c) { } static bool Inflate(void *dp, size_t dn, const void *sp, size_t sn) { + int rc; z_stream zs; LockInc(&shared->c.inflates); zs.next_in = sp; @@ -1499,7 +1288,7 @@ static bool Inflate(void *dp, size_t dn, const void *sp, size_t sn) { zs.zfree = Z_NULL; zs.zalloc = Z_NULL; CHECK_EQ(Z_OK, inflateInit2(&zs, -MAX_WBITS)); - switch (inflate(&zs, Z_NO_FLUSH)) { + switch ((rc = inflate(&zs, Z_NO_FLUSH))) { case Z_STREAM_END: CHECK_EQ(Z_OK, inflateEnd(&zs)); return true; @@ -1514,7 +1303,10 @@ static bool Inflate(void *dp, size_t dn, const void *sp, size_t sn) { case Z_MEM_ERROR: FATALF("Z_MEM_ERROR"); default: - abort(); + FATALF("inflate()→%d dn=%ld sn=%ld " + "next_in=%ld avail_in=%ld next_out=%ld avail_out=%ld", + rc, dn, sn, (char *)zs.next_in - (char *)sp, zs.avail_in, + (char *)zs.next_out - (char *)dp, zs.avail_out); } } @@ -1556,18 +1348,18 @@ static void *LoadAsset(struct Asset *a, size_t *out_size) { return NULL; } if (!a->file) { - size = GetZipLfileUncompressedSize(zmap + a->lf); + size = GetZipLfileUncompressedSize(zbase + a->lf); if (size == SIZE_MAX || !(data = malloc(size + 1))) return NULL; if (IsCompressed(a)) { - if (!Inflate(data, size, ZIP_LFILE_CONTENT(zmap + a->lf), - GetZipCfileCompressedSize(zmap + a->cf))) { + if (!Inflate(data, size, ZIP_LFILE_CONTENT(zbase + a->lf), + GetZipCfileCompressedSize(zbase + a->cf))) { free(data); return NULL; } } else { - memcpy(data, ZIP_LFILE_CONTENT(zmap + a->lf), size); + memcpy(data, ZIP_LFILE_CONTENT(zbase + a->lf), size); } - if (!Verify(data, size, ZIP_LFILE_CRC32(zmap + a->lf))) { + if (!Verify(data, size, ZIP_LFILE_CRC32(zbase + a->lf))) { free(data); return NULL; } @@ -1576,7 +1368,110 @@ static void *LoadAsset(struct Asset *a, size_t *out_size) { return data; } else { LockInc(&shared->c.slurps); - return xslurp(a->file->path, out_size); + return xslurp(a->file->path.s, out_size); + } +} + +static wontreturn void PrintUsage(FILE *f, int rc) { + size_t n; + const char *p; + struct Asset *a; + if ((a = GetAssetZip("/.help.txt", 10)) && (p = LoadAsset(a, &n))) { + fwrite(p, 1, n, f); + free(p); + } + exit(rc); +} + +static void GetOpts(int argc, char *argv[]) { + int opt; + while ((opt = getopt(argc, argv, + "azhdugvsmbfl:p:r:R:H:c:L:P:U:G:B:D:t:M:")) != -1) { + switch (opt) { + case 'v': + __log_level++; + break; + case 's': + __log_level--; + break; + case 'd': + daemonize = true; + break; + case 'a': + logrusage = true; + break; + case 'u': + uniprocess = true; + break; + case 'g': + loglatency = true; + break; + case 'm': + logmessages = true; + break; + case 'b': + logbodies = true; + break; + case 'z': + printport = true; + break; + case 'f': + funtrace = true; + break; + case 'k': + encouragekeepalive = true; + break; + case 't': + ProgramTimeout(strtol(optarg, NULL, 0)); + break; + case 'r': + ProgramRedirectArg(307, optarg); + break; + case 'R': + ProgramRedirectArg(0, optarg); + break; + case 'D': + AddStagingDirectory(optarg); + break; + case 'c': + ProgramCache(strtol(optarg, NULL, 0)); + break; + case 'p': + ProgramPort(strtol(optarg, NULL, 0)); + break; + case 'M': + maxpayloadsize = atoi(optarg); + maxpayloadsize = MAX(1450, maxpayloadsize); + break; + case 'l': + CHECK_EQ(1, inet_pton(AF_INET, optarg, &serveraddr.sin_addr)); + break; + case 'B': + ProgramBrand(optarg); + break; + case 'H': + ProgramHeader(optarg); + break; + case 'L': + logpath = optarg; + break; + case 'P': + pidpath = optarg; + break; + case 'U': + daemonuid = atoi(optarg); + break; + case 'G': + daemongid = atoi(optarg); + break; + case 'h': + PrintUsage(stdout, EXIT_SUCCESS); + default: + PrintUsage(stderr, EX_USAGE); + } + } + if (logpath) { + CHECK_NOTNULL(freopen(logpath, "a", stderr)); } } @@ -1671,13 +1566,13 @@ static char *ServeErrorImpl(unsigned code, const char *reason) { return ServeDefaultErrorPage(p, code, reason); } else if (a->file) { LockInc(&shared->c.slurps); - content = FreeLater(xslurp(a->file->path, &contentlength)); + content = FreeLater(xslurp(a->file->path.s, &contentlength)); return AppendContentType(p, "text/html; charset=utf-8"); } else { - content = (char *)ZIP_LFILE_CONTENT(zmap + a->lf); - contentlength = GetZipCfileCompressedSize(zmap + a->cf); + content = (char *)ZIP_LFILE_CONTENT(zbase + a->lf); + contentlength = GetZipCfileCompressedSize(zbase + a->cf); if (IsCompressed(a)) { - n = GetZipLfileUncompressedSize(zmap + a->lf); + n = GetZipLfileUncompressedSize(zbase + a->lf); if ((s = FreeLater(malloc(n))) && Inflate(s, n, content, contentlength)) { content = s; contentlength = n; @@ -1685,7 +1580,7 @@ static char *ServeErrorImpl(unsigned code, const char *reason) { return ServeDefaultErrorPage(p, code, reason); } } - if (Verify(content, contentlength, ZIP_LFILE_CRC32(zmap + a->lf))) { + if (Verify(content, contentlength, ZIP_LFILE_CRC32(zbase + a->lf))) { return AppendContentType(p, "text/html; charset=utf-8"); } else { return ServeDefaultErrorPage(p, code, reason); @@ -1713,27 +1608,37 @@ static char *ServeAssetCompressed(struct Asset *a) { LockInc(&shared->c.compressedresponses); DEBUGF("ServeAssetCompressed()"); gzipped = true; - crc = crc32_z(0, content, contentlength); - WRITE32LE(gzip_footer + 0, crc); - WRITE32LE(gzip_footer + 4, contentlength); - content = FreeLater(Deflate(content, contentlength, &contentlength)); + if (msg.method == kHttpHead) { + content = 0; + } else { + crc = crc32_z(0, content, contentlength); + WRITE32LE(gzip_footer + 0, crc); + WRITE32LE(gzip_footer + 4, contentlength); + content = FreeLater(Deflate(content, contentlength, &contentlength)); + } return SetStatus(200, "OK"); } static char *ServeAssetDecompressed(struct Asset *a) { char *buf; size_t size; - DEBUGF("ServeAssetDecompressed()"); - size = GetZipCfileUncompressedSize(zmap + a->cf); LockInc(&shared->c.decompressedresponses); - if ((buf = FreeLater(malloc(size))) && - Inflate(buf, size, content, contentlength) && - Verify(buf, size, ZIP_CFILE_CRC32(zmap + a->cf))) { - content = buf; + size = GetZipCfileUncompressedSize(zbase + a->cf); + DEBUGF("ServeAssetDecompressed(%ld) -> %ld", contentlength, size); + if (msg.method == kHttpHead) { + content = 0; contentlength = size; return SetStatus(200, "OK"); } else { - return ServeError(500, "Internal Server Error"); + if ((buf = FreeLater(malloc(size))) && + Inflate(buf, size, content, contentlength) && + Verify(buf, size, ZIP_CFILE_CRC32(zbase + a->cf))) { + content = buf; + contentlength = size; + return SetStatus(200, "OK"); + } else { + return ServeError(500, "Internal Server Error"); + } } } @@ -1749,8 +1654,8 @@ static inline char *ServeAssetPrecompressed(struct Asset *a) { DEBUGF("ServeAssetPrecompressed()"); LockInc(&shared->c.precompressedresponses); gzipped = true; - crc = ZIP_CFILE_CRC32(zmap + a->cf); - size = GetZipCfileUncompressedSize(zmap + a->cf); + crc = ZIP_CFILE_CRC32(zbase + a->cf); + size = GetZipCfileUncompressedSize(zbase + a->cf); WRITE32LE(gzip_footer + 0, crc); WRITE32LE(gzip_footer + 4, size); return SetStatus(200, "OK"); @@ -1781,11 +1686,11 @@ static char *ServeAssetRange(struct Asset *a) { } } -static char *GetAssetPath(uint64_t cf, size_t *out_size) { +static char *GetAssetPath(uint8_t *zcf, size_t *out_size) { char *p1, *p2; size_t n1, n2; - p1 = ZIP_CFILE_NAME(zmap + cf); - n1 = ZIP_CFILE_NAMESIZE(zmap + cf); + p1 = ZIP_CFILE_NAME(zcf); + n1 = ZIP_CFILE_NAMESIZE(zcf); p2 = xmalloc(1 + n1 + 1); n2 = 1 + n1 + 1; p2[0] = '/'; @@ -1795,10 +1700,11 @@ static char *GetAssetPath(uint64_t cf, size_t *out_size) { return p2; } -static bool IsHiddenPath(const char *s) { +static bool IsHiddenPath(const char *s, size_t n) { size_t i; for (i = 0; i < hidepaths.n; ++i) { - if (startswith(s, hidepaths.p[i])) { + if (n >= hidepaths.p[i].n && + !memcmp(s, hidepaths.p[i].s, hidepaths.p[i].n)) { return true; } } @@ -1808,8 +1714,12 @@ static bool IsHiddenPath(const char *s) { static char *GetBasicAuthorization(size_t *z) { size_t n; const char *p, *q; - p = inbuf.p + msg.headers[kHttpAuthorization].a; - n = msg.headers[kHttpAuthorization].b - msg.headers[kHttpAuthorization].a; + struct HttpRequestSlice *g; + g = msg.headers + (HasHeader(kHttpProxyAuthorization) + ? kHttpProxyAuthorization + : kHttpAuthorization); + p = inbuf.p + g->a; + n = g->b - g->a; if ((q = memchr(p, ' ', n)) && SlicesEqualCase(p, q - p, "Basic", 5)) { return DecodeBase64(q + 1, n - (q + 1 - p), z); } else { @@ -1879,7 +1789,7 @@ static char *BadMethod(void) { return stpcpy(ServeError(405, "Method Not Allowed"), "Allow: GET, HEAD\r\n"); } -static int GetDecimalWidth(int x) { +static int GetDecimalWidth(long x) { int w = x ? ceil(log10(x)) : 1; return w + (w - 1) / 3; } @@ -1888,13 +1798,13 @@ static int GetOctalWidth(int x) { return !x ? 1 : x < 8 ? 2 : 1 + bsr(x) / 3; } -static const char *DescribeCompressionRatio(char rb[8], uint64_t cf) { +static const char *DescribeCompressionRatio(char rb[8], uint8_t *zcf) { long percent; - if (ZIP_CFILE_COMPRESSIONMETHOD(zmap + cf) == kZipCompressionNone) { + if (ZIP_CFILE_COMPRESSIONMETHOD(zcf) == kZipCompressionNone) { return "n/a"; } else { - percent = lround(100 - (double)GetZipCfileCompressedSize(zmap + cf) / - GetZipCfileUncompressedSize(zmap + cf) * 100); + percent = lround(100 - (double)GetZipCfileCompressedSize(zcf) / + GetZipCfileUncompressedSize(zcf) * 100); sprintf(rb, "%ld%%", MIN(999, MAX(-999, percent))); return rb; } @@ -1904,10 +1814,10 @@ static char *ServeListing(void) { long x; ldiv_t y; int w[3]; + uint8_t *zcf; struct tm tm; const char *and; int64_t lastmod; - uint64_t cf, lf; struct rusage ru; char *p, *q, *path; char rb[8], tb[64], *rp[6]; @@ -1942,46 +1852,43 @@ td { padding-right: 3em; }\r\n\ GetZipCdirComment(zcdir)); memset(w, 0, sizeof(w)); n = GetZipCdirRecords(zcdir); - for (cf = GetZipCdirOffset(zcdir); n--; cf += ZIP_CFILE_HDRSIZE(zmap + cf)) { - CHECK_EQ(kZipCfileHdrMagic, ZIP_CFILE_MAGIC(zmap + cf)); - lf = GetZipCfileOffset(zmap + cf); - path = GetAssetPath(cf, &pathlen); - if (!IsHiddenPath(path)) { + for (zcf = zbase + GetZipCdirOffset(zcdir); n--; + zcf += ZIP_CFILE_HDRSIZE(zcf)) { + CHECK_EQ(kZipCfileHdrMagic, ZIP_CFILE_MAGIC(zcf)); + path = GetAssetPath(zcf, &pathlen); + if (!IsHiddenPath(path, pathlen)) { w[0] = min(80, max(w[0], strwidth(path, 0) + 2)); - w[1] = max(w[1], GetOctalWidth(GetZipCfileMode(zmap + cf))); - w[2] = max(w[2], GetDecimalWidth(GetZipCfileUncompressedSize(zmap + cf))); + w[1] = max(w[1], GetOctalWidth(GetZipCfileMode(zcf))); + w[2] = max(w[2], GetDecimalWidth(GetZipCfileUncompressedSize(zcf))); } free(path); } n = GetZipCdirRecords(zcdir); - for (cf = GetZipCdirOffset(zcdir); n--; cf += ZIP_CFILE_HDRSIZE(zmap + cf)) { - CHECK_EQ(kZipCfileHdrMagic, ZIP_CFILE_MAGIC(zmap + cf)); - lf = GetZipCfileOffset(zmap + cf); - path = GetAssetPath(cf, &pathlen); - if (!IsHiddenPath(path)) { + for (zcf = zbase + GetZipCdirOffset(zcdir); n--; + zcf += ZIP_CFILE_HDRSIZE(zcf)) { + CHECK_EQ(kZipCfileHdrMagic, ZIP_CFILE_MAGIC(zcf)); + path = GetAssetPath(zcf, &pathlen); + if (!IsHiddenPath(path, pathlen)) { rp[0] = VisualizeControlCodes(path, pathlen, &rn[0]); rp[1] = EscapePath(path, pathlen, &rn[1]); rp[2] = EscapeHtml(rp[1], rn[1], &rn[2]); - rp[3] = VisualizeControlCodes(ZIP_CFILE_COMMENT(zmap + cf), - strnlen(ZIP_CFILE_COMMENT(zmap + cf), - ZIP_CFILE_COMMENTSIZE(zmap + cf)), - &rn[3]); + rp[3] = VisualizeControlCodes( + ZIP_CFILE_COMMENT(zcf), + strnlen(ZIP_CFILE_COMMENT(zcf), ZIP_CFILE_COMMENTSIZE(zcf)), &rn[3]); rp[4] = EscapeHtml(rp[0], rn[0], &rn[4]); - lastmod = GetZipCfileLastModified(zmap + cf); + lastmod = GetZipCfileLastModified(zcf); localtime_r(&lastmod, &tm); strftime(tb, sizeof(tb), "%Y-%m-%d %H:%M:%S %Z", &tm); - if (IsCompressionMethodSupported( - ZIP_CFILE_COMPRESSIONMETHOD(zmap + cf)) && + if (IsCompressionMethodSupported(ZIP_CFILE_COMPRESSIONMETHOD(zcf)) && IsAcceptablePath(path, pathlen)) { Append("%-*.*s %s %0*o %4s %,*ld %'s\r\n", - rn[2], rp[2], w[0], rn[4], rp[4], tb, w[1], - GetZipCfileMode(zmap + cf), DescribeCompressionRatio(rb, cf), - w[2], GetZipCfileUncompressedSize(zmap + cf), rp[3]); + rn[2], rp[2], w[0], rn[4], rp[4], tb, w[1], GetZipCfileMode(zcf), + DescribeCompressionRatio(rb, zcf), w[2], + GetZipCfileUncompressedSize(zcf), rp[3]); } else { Append("%-*.*s %s %0*o %4s %,*ld %'s\r\n", w[0], rn[4], rp[4], tb, - w[1], GetZipCfileMode(zmap + cf), - DescribeCompressionRatio(rb, cf), w[2], - GetZipCfileUncompressedSize(zmap + cf), rp[3]); + w[1], GetZipCfileMode(zcf), DescribeCompressionRatio(rb, zcf), + w[2], GetZipCfileUncompressedSize(zcf), rp[3]); } free(rp[4]); free(rp[3]); @@ -2168,12 +2075,12 @@ static char *ServeLua(struct Asset *a, const char *s, size_t n) { static char *HandleRedirect(struct Redirect *r) { int code; struct Asset *a; - if (!r->code && (a = GetAsset(r->location, strlen(r->location)))) { + if (!r->code && (a = GetAsset(r->location.s, r->location.n))) { LockInc(&shared->c.rewrites); - DEBUGF("rewriting to %`'s", r->location); - if (!HasString(&loops, r->location)) { - AddString(&loops, r->location); - return RoutePath(r->location, strlen(r->location)); + DEBUGF("rewriting to %`'s", r->location.s); + if (!HasString(&loops, r->location.s, r->location.n)) { + AddString(&loops, r->location.s, r->location.n); + return RoutePath(r->location.s, r->location.n); } else { LockInc(&shared->c.loops); return SetStatus(508, "Loop Detected"); @@ -2185,8 +2092,9 @@ static char *HandleRedirect(struct Redirect *r) { code = r->code; if (!code) code = 307; DEBUGF("%d redirecting %`'s", code, r->location); - return AppendHeader(SetStatus(code, GetHttpReason(code)), "Location", - FreeLater(EncodeHttpHeaderValue(r->location, -1, 0))); + return AppendHeader( + SetStatus(code, GetHttpReason(code)), "Location", + FreeLater(EncodeHttpHeaderValue(r->location.s, r->location.n, 0))); } } @@ -2205,11 +2113,13 @@ static char *HandleFolder(const char *path, size_t pathlen) { } } -static void Reindex(void) { - LockInc(&shared->c.reindexes); - DEBUGF("reindexing"); - OpenZip(); - IndexAssets(); +static bool Reindex(void) { + if (OpenZip(false)) { + LockInc(&shared->c.reindexes); + return true; + } else { + return false; + } } static const char *LuaCheckPath(lua_State *L, int idx, size_t *pathlen) { @@ -2344,9 +2254,9 @@ static int LuaLoadAsset(lua_State *L) { if ((a = GetAsset(path, pathlen))) { if (!a->file && !IsCompressed(a)) { /* fast path: this avoids extra copy */ - data = ZIP_LFILE_CONTENT(zmap + a->lf); - size = GetZipLfileUncompressedSize(zmap + a->lf); - if (Verify(data, size, ZIP_LFILE_CRC32(zmap + a->lf))) { + data = ZIP_LFILE_CONTENT(zbase + a->lf); + size = GetZipLfileUncompressedSize(zbase + a->lf); + if (Verify(data, size, ZIP_LFILE_CRC32(zbase + a->lf))) { lua_pushlstring(L, data, size); return 1; } @@ -2391,66 +2301,80 @@ static bool IsText(const void *data, size_t size) { return true; } -static int LuaStoreAsset(lua_State *L) { - int mode; +int LuaStoreAsset(lua_State *L) { int64_t ft; - uint8_t era; + int i, mode; uint32_t crc; + char *comp, *p; long double now; - char *comp, *p, *q; + struct Asset *a; + struct iovec v[13]; + uint8_t *cdir, era; const char *path, *data, *use; uint16_t gflags, iattrs, mtime, mdate, dosmode, method, disk; - size_t newlfileoffset, newcdiroffset, neweocdoffset, oldcdirrecords; - size_t pathlen, datalen, complen, uselen, oldcdirsize, moar, extralen; + size_t oldcdirsize, oldcdiroffset, records, cdiroffset, cdirsize, pathlen, + datalen, complen, uselen; if (IsOpenbsd() || IsNetbsd() || IsWindows()) { luaL_error(L, "StoreAsset() not available on Windows/NetBSD/OpenBSD yet"); unreachable; } - now = nowl(); path = LuaCheckPath(L, 1, &pathlen); + DCHECK(__asan_is_valid(path, pathlen)); + if (pathlen > 0xffff) { + luaL_argerror(L, 1, "path too long"); + unreachable; + } data = luaL_checklstring(L, 2, &datalen); - mode = luaL_optinteger(L, 3, 0644); - if (!(mode & S_IFMT)) mode |= S_IFREG; - if (pathlen > 1 && path[0] == '/') ++path, --pathlen; + disk = gflags = iattrs = 0; + if (IsUtf8(path, pathlen)) gflags |= kZipGflagUtf8; + if (IsText(data, datalen)) iattrs |= kZipIattrText; crc = crc32_z(0, data, datalen); if (datalen < 100) { method = kZipCompressionNone; - comp = NULL; + comp = 0; use = data; uselen = datalen; + era = kZipEra1989; } else { comp = Deflate(data, datalen, &complen); if (complen < datalen) { method = kZipCompressionDeflate; use = comp; uselen = complen; + era = kZipEra1993; } else { method = kZipCompressionNone; use = data; uselen = datalen; + era = kZipEra1989; } } - disk = gflags = iattrs = 0; - era = method ? kZipEra1993 : kZipEra1989; - ft = (now + MODERNITYSECONDS) * HECTONANOSECONDS; + ////////////////////////////////////////////////////////////////////////////// + CHECK_NE(-1, fcntl(zfd, F_SETLKW, &(struct flock){F_WRLCK})); + OpenZip(false); + + now = nowl(); + a = GetAsset(path, pathlen); + mode = luaL_optinteger(L, 3, a ? GetMode(a) : 0644); + if (!(mode & S_IFMT)) mode |= S_IFREG; + if (pathlen > 1 && path[0] == '/') ++path, --pathlen; dosmode = !(mode & 0200) ? kNtFileAttributeReadonly : 0; + ft = (now + MODERNITYSECONDS) * HECTONANOSECONDS; GetDosLocalTime(now, &mtime, &mdate); - if (IsUtf8(path, pathlen)) gflags |= kZipGflagUtf8; - if (IsText(data, datalen)) iattrs |= kZipIattrText; - CHECK_NE(-1, flock(zfd, LOCK_EX)); - if (ZipCdirChanged()) Reindex(); - oldcdirrecords = GetZipCdirRecords(zcdir); - oldcdirsize = GetZipCdirSize(zcdir); - extralen = 36; - moar = kZipLfileHdrMinSize + pathlen + datalen + oldcdirsize + - kZipCfileHdrMinSize + pathlen + extralen + kZipCdirHdrMinSize; - CHECK_NE(-1, ftruncate(zfd, zsize + moar)); - CHECK_NE(MAP_FAILED, (zmap = mmap((void *)0x0000300000000000, zsize + moar, - PROT_READ | PROT_WRITE, - MAP_FIXED | MAP_SHARED, zfd, 0))); - p = q = (char *)zmap; - p += zsize; - newlfileoffset = p - q; + + // local file header + if (uselen >= 0xffffffff || datalen >= 0xffffffff) { + era = kZipEra2001; + v[2].iov_base = p = alloca((v[2].iov_len = 2 + 2 + 8 + 8)); + p = WRITE16LE(p, kZipExtraZip64); + p = WRITE16LE(p, 8 + 8); + p = WRITE64LE(p, uselen); + p = WRITE64LE(p, datalen); + } else { + v[2].iov_len = 0; + v[2].iov_base = 0; + } + v[0].iov_base = p = alloca((v[0].iov_len = kZipLfileHdrMinSize)); p = WRITE32LE(p, kZipLfileHdrMagic); *p++ = era; *p++ = kZipOsDos; @@ -2459,14 +2383,55 @@ static int LuaStoreAsset(lua_State *L) { p = WRITE16LE(p, mtime); p = WRITE16LE(p, mdate); p = WRITE32LE(p, crc); - p = WRITE32LE(p, uselen); - p = WRITE32LE(p, datalen); + p = WRITE32LE(p, MIN(uselen, 0xffffffff)); + p = WRITE32LE(p, MIN(datalen, 0xffffffff)); p = WRITE16LE(p, pathlen); - p = WRITE16LE(p, 0); - p = mempcpy(p, path, pathlen); - p = mempcpy(p, data, datalen); - newcdiroffset = p - q; - p = mempcpy(p, zmap + GetZipCdirOffset(zcdir), oldcdirsize); + p = WRITE16LE(p, v[2].iov_len); + v[1].iov_len = pathlen; + v[1].iov_base = path; + + // file data + v[3].iov_len = datalen; + v[3].iov_base = data; + + // old central directory entries + oldcdirsize = GetZipCdirSize(zcdir); + oldcdiroffset = GetZipCdirOffset(zcdir); + if (a) { + v[4].iov_base = zbase + oldcdiroffset; + v[4].iov_len = a->cf - oldcdiroffset; + v[5].iov_base = zbase + oldcdiroffset + ZIP_CFILE_HDRSIZE(zbase + a->cf); + v[5].iov_len = + oldcdirsize - v[4].iov_len - ZIP_CFILE_HDRSIZE(zbase + a->cf); + } else { + v[4].iov_base = zbase + oldcdiroffset; + v[4].iov_len = oldcdirsize; + v[5].iov_base = 0; + v[5].iov_len = 0; + } + + // new central directory entry + if (uselen >= 0xffffffff || datalen >= 0xffffffff || zsize >= 0xffffffff) { + v[8].iov_base = p = alloca((v[8].iov_len = 2 + 2 + 8 + 8 + 8)); + p = WRITE16LE(p, kZipExtraZip64); + p = WRITE16LE(p, 8 + 8 + 8); + p = WRITE64LE(p, uselen); + p = WRITE64LE(p, datalen); + p = WRITE64LE(p, zsize); + } else { + v[8].iov_len = 0; + v[8].iov_base = 0; + } + v[9].iov_base = p = alloca((v[9].iov_len = 2 + 2 + 4 + 2 + 2 + 8 + 8 + 8)); + p = WRITE16LE(p, kZipExtraNtfs); + p = WRITE16LE(p, 4 + 2 + 2 + 8 + 8 + 8); + p = WRITE32LE(p, 0); + p = WRITE16LE(p, 1); + p = WRITE16LE(p, 8 + 8 + 8); + p = WRITE64LE(p, ft); + p = WRITE64LE(p, ft); + p = WRITE64LE(p, ft); + v[6].iov_base = p = alloca((v[6].iov_len = kZipCfileHdrMinSize)); p = WRITE32LE(p, kZipCfileHdrMagic); *p++ = kZipCosmopolitanVersion; *p++ = kZipOsUnix; @@ -2477,37 +2442,65 @@ static int LuaStoreAsset(lua_State *L) { p = WRITE16LE(p, mtime); p = WRITE16LE(p, mdate); p = WRITE32LE(p, crc); - p = WRITE32LE(p, uselen); - p = WRITE32LE(p, datalen); + p = WRITE32LE(p, MIN(uselen, 0xffffffff)); + p = WRITE32LE(p, MIN(datalen, 0xffffffff)); p = WRITE16LE(p, pathlen); - p = WRITE16LE(p, extralen); + p = WRITE16LE(p, v[8].iov_len + v[9].iov_len); p = WRITE16LE(p, 0); p = WRITE16LE(p, disk); p = WRITE16LE(p, iattrs); p = WRITE16LE(p, dosmode); p = WRITE16LE(p, mode); - p = WRITE32LE(p, newlfileoffset); - p = mempcpy(p, path, pathlen); - p = WRITE16LE(p, kZipExtraNtfs); - p = WRITE16LE(p, 32); - p = WRITE32LE(p, 0); - p = WRITE16LE(p, 1); - p = WRITE16LE(p, 24); - p = WRITE64LE(p, ft); - p = WRITE64LE(p, ft); - p = WRITE64LE(p, ft); - neweocdoffset = p - q; + p = WRITE32LE(p, MIN(zsize, 0xffffffff)); + v[7].iov_len = pathlen; + v[7].iov_base = path; + + // zip64 end of central directory + cdiroffset = + zsize + v[0].iov_len + v[1].iov_len + v[2].iov_len + v[3].iov_len; + cdirsize = v[4].iov_len + v[5].iov_len + v[6].iov_len + v[7].iov_len + + v[8].iov_len + v[9].iov_len; + records = GetZipCdirRecords(zcdir) + !a; + if (records >= 0xffff || cdiroffset >= 0xffffffff || cdirsize >= 0xffffffff) { + v[10].iov_base = p = + alloca((v[10].iov_len = kZipCdir64HdrMinSize + kZipCdir64LocatorSize)); + p = WRITE32LE(p, kZipCdir64HdrMagic); + p = WRITE64LE(p, 2 + 2 + 4 + 4 + 8 + 8 + 8 + 8); + p = WRITE16LE(p, kZipCosmopolitanVersion); + p = WRITE16LE(p, kZipEra2001); + p = WRITE32LE(p, disk); + p = WRITE32LE(p, disk); + p = WRITE64LE(p, records); + p = WRITE64LE(p, records); + p = WRITE64LE(p, cdirsize); + p = WRITE64LE(p, cdiroffset); + p = WRITE32LE(p, kZipCdir64LocatorMagic); + p = WRITE32LE(p, disk); + p = WRITE64LE(p, cdiroffset + cdirsize); + p = WRITE32LE(p, disk); + } else { + v[10].iov_len = 0; + v[10].iov_base = 0; + } + + // end of central directory + v[12].iov_base = GetZipCdirComment(zcdir); + v[12].iov_len = GetZipCdirCommentSize(zcdir); + v[11].iov_base = p = alloca((v[11].iov_len = kZipCdirHdrMinSize)); p = WRITE32LE(p, kZipCdirHdrMagic); - p = WRITE16LE(p, 0); - p = WRITE16LE(p, 0); - p = WRITE16LE(p, oldcdirrecords + 1); - p = WRITE16LE(p, oldcdirrecords + 1); - p = WRITE32LE(p, neweocdoffset - newcdiroffset); - p = WRITE32LE(p, newcdiroffset); - p = WRITE16LE(p, 0); - zcdir[0] = 'J'; - zcdir[1] = 'T'; - CHECK_NE(-1, flock(zfd, LOCK_UN)); + p = WRITE16LE(p, disk); + p = WRITE16LE(p, disk); + p = WRITE16LE(p, MIN(records, 0xffff)); + p = WRITE16LE(p, MIN(records, 0xffff)); + p = WRITE32LE(p, MIN(cdirsize, 0xffffffff)); + p = WRITE32LE(p, MIN(cdiroffset, 0xffffffff)); + p = WRITE16LE(p, v[12].iov_len); + + CHECK_NE(-1, lseek(zfd, zbase + zsize - zmap, SEEK_SET)); + CHECK_NE(-1, WritevAll(zfd, v, 13)); + CHECK_NE(-1, fcntl(zfd, F_SETLK, &(struct flock){F_UNLCK})); + ////////////////////////////////////////////////////////////////////////////// + OpenZip(false); free(comp); return 0; } @@ -3053,19 +3046,19 @@ static int LuaIsAcceptablePort(lua_State *L) { } static noinline int LuaCoderImpl(lua_State *L, - char *Coder(const char *, size_t, size_t *)) { + char *C(const char *, size_t, size_t *)) { void *p; size_t n; p = luaL_checklstring(L, 1, &n); - p = Coder(p, n, &n); + p = C(p, n, &n); lua_pushlstring(L, p, n); free(p); return 1; } static noinline int LuaCoder(lua_State *L, - char *Coder(const char *, size_t, size_t *)) { - return LuaCoderImpl(L, Coder); + char *C(const char *, size_t, size_t *)) { + return LuaCoderImpl(L, C); } static int LuaUnderlong(lua_State *L) { @@ -3214,8 +3207,8 @@ static int LuaCrc32c(lua_State *L) { return LuaHash(L, crc32c); } -static noinline int LuaProgramInt(lua_State *L, void Program(long)) { - Program(luaL_checkinteger(L, 1)); +static noinline int LuaProgramInt(lua_State *L, void P(long)) { + P(luaL_checkinteger(L, 1)); return 0; } @@ -3241,16 +3234,18 @@ static int LuaProgramBrand(lua_State *L) { } static int LuaProgramHeader(lua_State *L) { - char *s; - s = xasprintf("%s: %s", luaL_checkstring(L, 1), luaL_checkstring(L, 2)); - ProgramHeader(s); - free(s); + ProgramHeader( + gc(xasprintf("%s: %s", luaL_checkstring(L, 1), luaL_checkstring(L, 2)))); return 0; } static int LuaProgramRedirect(lua_State *L) { - ProgramRedirect(luaL_checkinteger(L, 1), luaL_checkstring(L, 2), - luaL_checkstring(L, 3)); + int code; + const char *from, *to; + code = luaL_checkinteger(L, 1); + from = luaL_checkstring(L, 2); + to = luaL_checkstring(L, 3); + ProgramRedirect(code, strdup(from), strlen(from), strdup(to), strlen(to)); return 0; } @@ -3268,7 +3263,7 @@ static int LuaHidePath(lua_State *L) { size_t pathlen; const char *path; path = luaL_checklstring(L, 1, &pathlen); - AddString(&hidepaths, strndup(path, pathlen)); + AddString(&hidepaths, path, pathlen); return 0; } @@ -3294,20 +3289,24 @@ static int LuaLog(lua_State *L) { } static int LuaIsHiddenPath(lua_State *L) { - lua_pushboolean(L, IsHiddenPath(luaL_checkstring(L, 1))); + size_t n; + const char *s; + s = luaL_checklstring(L, 1, &n); + lua_pushboolean(L, IsHiddenPath(s, n)); return 1; } static int LuaGetZipPaths(lua_State *L) { char *path; - uint64_t cf; + uint8_t *zcf; size_t i, n, pathlen; lua_newtable(L); i = 0; n = GetZipCdirRecords(zcdir); - for (cf = GetZipCdirOffset(zcdir); n--; cf += ZIP_CFILE_HDRSIZE(zmap + cf)) { - CHECK_EQ(kZipCfileHdrMagic, ZIP_CFILE_MAGIC(zmap + cf)); - path = GetAssetPath(cf, &pathlen); + for (zcf = zbase + GetZipCdirOffset(zcdir); n--; + zcf += ZIP_CFILE_HDRSIZE(zcf)) { + CHECK_EQ(kZipCfileHdrMagic, ZIP_CFILE_MAGIC(zcf)); + path = GetAssetPath(zcf, &pathlen); lua_pushlstring(L, path, pathlen); lua_seti(L, -2, ++i); free(path); @@ -3337,7 +3336,7 @@ static int LuaGetLastModifiedTime(lua_State *L) { if (a->file) { lua_pushinteger(L, a->file->st.st_mtim.tv_sec); } else { - lua_pushinteger(L, GetZipCfileLastModified(zmap + a->cf)); + lua_pushinteger(L, GetZipCfileLastModified(zbase + a->cf)); } } else { lua_pushnil(L); @@ -3354,7 +3353,7 @@ static int LuaGetAssetSize(lua_State *L) { if (a->file) { lua_pushinteger(L, a->file->st.st_size); } else { - lua_pushinteger(L, GetZipLfileUncompressedSize(zmap + a->lf)); + lua_pushinteger(L, GetZipLfileUncompressedSize(zbase + a->lf)); } } else { lua_pushnil(L); @@ -3381,9 +3380,9 @@ static int LuaGetComment(lua_State *L) { size_t pathlen, m; path = LuaCheckPath(L, 1, &pathlen); if ((a = GetAssetZip(path, pathlen)) && - (m = strnlen(ZIP_CFILE_COMMENT(zmap + a->cf), - ZIP_CFILE_COMMENTSIZE(zmap + a->cf)))) { - lua_pushlstring(L, ZIP_CFILE_COMMENT(zmap + a->cf), m); + (m = strnlen(ZIP_CFILE_COMMENT(zbase + a->cf), + ZIP_CFILE_COMMENTSIZE(zbase + a->cf)))) { + lua_pushlstring(L, ZIP_CFILE_COMMENT(zbase + a->cf), m); } else { lua_pushnil(L); } @@ -3913,7 +3912,6 @@ static void HandleFrag(size_t got) { static void HandleReload(void) { LockInc(&shared->c.reloads); - DEBUGF("reloading"); Reindex(); LuaReload(); } @@ -3921,10 +3919,7 @@ static void HandleReload(void) { static void HandleHeartbeat(void) { if (nowl() - lastrefresh > 60 * 60) RefreshTime(); UpdateCurrentDate(nowl()); - if (ZipCdirChanged()) { - shared->lastreindex = nowl(); - kill(0, SIGUSR1); - } + Reindex(); getrusage(RUSAGE_SELF, &shared->server); #ifndef STATIC LuaRun("/.heartbeat.lua"); @@ -3937,21 +3932,26 @@ static char *OpenAsset(struct Asset *a) { size_t size; if (a->file->st.st_size) { size = a->file->st.st_size; - OpenAgain: - if ((fd = open(a->file->path, O_RDONLY)) != -1) { - data = mmap(0, size, PROT_READ, MAP_PRIVATE, fd, 0); - if (data != MAP_FAILED) { - LockInc(&shared->c.maps); - UnmapLater(fd, data, size); - content = data; - contentlength = size; - } else { - return HandleMapFailed(a, fd); - } - } else if (errno == EINTR) { - goto OpenAgain; + if (msg.method == kHttpHead) { + content = 0; + contentlength = size; } else { - return HandleOpenFail(a); + OpenAgain: + if ((fd = open(a->file->path.s, O_RDONLY)) != -1) { + data = mmap(0, size, PROT_READ, MAP_PRIVATE, fd, 0); + if (data != MAP_FAILED) { + LockInc(&shared->c.maps); + UnmapLater(fd, data, size); + content = data; + contentlength = size; + } else { + return HandleMapFailed(a, fd); + } + } else if (errno == EINTR) { + goto OpenAgain; + } else { + return HandleOpenFail(a); + } } } else { content = ""; @@ -4178,9 +4178,13 @@ static char *RouteHost(const char *host, size_t hostlen, const char *path, static inline bool IsLua(struct Asset *a) { size_t n; const char *p; - if (a->file) return endswith(a->file->path, ".lua"); - p = ZIP_CFILE_NAME(zmap + a->cf); - n = ZIP_CFILE_NAMESIZE(zmap + a->cf); + if (a->file && a->file->path.n >= 4 && + READ32LE(a->file->path.s + a->file->path.n - 4) == + ('.' | 'l' << 8 | 'u' << 16 | 'a' << 24)) { + return true; + } + p = ZIP_CFILE_NAME(zbase + a->cf); + n = ZIP_CFILE_NAMESIZE(zbase + a->cf); return n > 4 && READ32LE(p + n - 4) == ('.' | 'l' << 8 | 'u' << 16 | 'a' << 24); } @@ -4235,13 +4239,13 @@ static const char *FindContentType(const char *p, size_t n) { static const char *GetContentType(struct Asset *a, const char *path, size_t n) { const char *r; - if (a->file && (r = FindContentType(a->file->path, strlen(a->file->path)))) { + if (a->file && (r = FindContentType(a->file->path.s, a->file->path.n))) { return r; } return firstnonnull( FindContentType(path, n), - firstnonnull(FindContentType(ZIP_CFILE_NAME(zmap + a->cf), - ZIP_CFILE_NAMESIZE(zmap + a->cf)), + firstnonnull(FindContentType(ZIP_CFILE_NAME(zbase + a->cf), + ZIP_CFILE_NAMESIZE(zbase + a->cf)), a->istext ? "text/plain" : "application/octet-stream")); } @@ -4263,8 +4267,8 @@ static char *ServeAsset(struct Asset *a, const char *path, size_t pathlen) { p = SetStatus(304, "Not Modified"); } else { if (!a->file) { - content = (char *)ZIP_LFILE_CONTENT(zmap + a->lf); - contentlength = GetZipCfileCompressedSize(zmap + a->cf); + content = (char *)ZIP_LFILE_CONTENT(zbase + a->lf); + contentlength = GetZipCfileCompressedSize(zbase + a->cf); } else if ((p = OpenAsset(a))) { return p; } @@ -4279,7 +4283,7 @@ static char *ServeAsset(struct Asset *a, const char *path, size_t pathlen) { } else if (!a->file) { LockInc(&shared->c.identityresponses); DEBUGF("ServeAssetZipIdentity(%`'s)", ct); - if (Verify(content, contentlength, ZIP_LFILE_CRC32(zmap + a->lf))) { + if (Verify(content, contentlength, ZIP_LFILE_CRC32(zbase + a->lf))) { p = SetStatus(200, "OK"); } else { return ServeError(500, "Internal Server Error"); @@ -4653,9 +4657,6 @@ static void RestoreApe(void) { if ((a = GetAssetZip("/.ape", 5)) && (p = LoadAsset(a, &n))) { write(zfd, p, n); free(p); - zprot = PROT_READ | PROT_WRITE; - CHECK_NE(MAP_FAILED, (zmap = mmap((void *)0x0000300000000000, zsize, zprot, - MAP_FIXED | MAP_SHARED, zfd, 0))); } else { WARNF("/.ape not found"); } @@ -4669,11 +4670,10 @@ void RedBean(int argc, char *argv[]) { (shared = mmap(NULL, ROUNDUP(sizeof(struct Shared), FRAMESIZE), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0))); - zprot = PROT_READ; zpath = (const char *)getauxval(AT_EXECFN); CHECK_NE(-1, (zfd = open(zpath, O_RDONLY))); - OpenZip(); - IndexAssets(); + CHECK_NE(-1, fstat(zfd, &zst)); + OpenZip(true); RestoreApe(); SetDefaults(); GetOpts(argc, argv);