From 7d6835c0ddaaededb3feebde3095d196df95cea7 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Fri, 7 Oct 2022 03:41:50 -0700 Subject: [PATCH] Release pledge v1.8 --- libc/calls/read.c | 15 +++++++++++++++ libc/calls/write.c | 2 ++ tool/build/pledge.c | 4 ++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/libc/calls/read.c b/libc/calls/read.c index d6056da03d2..e250c3c1d77 100644 --- a/libc/calls/read.c +++ b/libc/calls/read.c @@ -35,12 +35,27 @@ * * This function changes the current file position. For documentation * on file position behaviors and gotchas, see the lseek() function. + * This function may be used on socket file descriptors, including on + * Windows. * * @param fd is something open()'d earlier * @param buf is copied into, cf. copy_file_range(), sendfile(), etc. * @param size in range [1..0x7ffff000] is reasonable * @return [1..size] bytes on success, 0 on EOF, or -1 w/ errno; with * exception of size==0, in which case return zero means no error + * @raise EBADF if `fd` is negative or not an open file descriptor + * @raise EBADF if `fd` is open in `O_WRONLY` mode + * @raise EFAULT if `size` is nonzero and `buf` points to bad memory + * @raise EPERM if pledge() is in play without the stdio promise + * @raise EIO if low-level i/o error happened + * @raise EINTR if signal was delivered instead + * @raise ENOTCONN if `fd` is a socket and it isn't connected + * @raise ECONNRESET if socket peer forcibly closed connection + * @raise ETIMEDOUT if socket transmission timeout occurred + * @raise EAGAIN if `O_NONBLOCK` is in play and read needs to block, + * or `SO_RCVTIMEO` is in play and the time interval elapsed + * @raise ENOBUFS is specified by POSIX + * @raise ENXIO is specified by POSIX * @asyncsignalsafe * @restartable * @vforksafe diff --git a/libc/calls/write.c b/libc/calls/write.c index 9606be55c3d..9b421b46005 100644 --- a/libc/calls/write.c +++ b/libc/calls/write.c @@ -33,6 +33,8 @@ * * This function changes the current file position. For documentation * on file position behaviors and gotchas, see the lseek() function. + * This function may be used on socket file descriptors, including on + * Windows. * * @param fd is open file descriptor * @param buf is copied from, cf. copy_file_range(), sendfile(), etc. diff --git a/tool/build/pledge.c b/tool/build/pledge.c index 4a0a33ea616..518f6d03f1a 100644 --- a/tool/build/pledge.c +++ b/tool/build/pledge.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" #include "libc/calls/calls.h" -#include "libc/mem/copyfd.internal.h" #include "libc/calls/landlock.h" #include "libc/calls/pledge.h" #include "libc/calls/pledge.internal.h" @@ -40,6 +39,7 @@ #include "libc/intrin/safemacros.internal.h" #include "libc/macros.internal.h" #include "libc/math.h" +#include "libc/mem/copyfd.internal.h" #include "libc/mem/gc.internal.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/kcpuids.h" @@ -115,7 +115,7 @@ usage: pledge.com [-hnN] PROG ARGS...\n\ - vminfo: allows /proc/stat, /proc/self/maps, etc.\n\ - tmppath: allows /tmp, $TMPPATH, lstat, unlink\n\ \n\ -pledge.com v1.7\n\ +pledge.com v1.8\n\ copyright 2022 justine alexandra roberts tunney\n\ https://twitter.com/justinetunney\n\ https://linkedin.com/in/jtunney\n\