Implement raw system call for redbean lua code

You can now call functions like fork() from Lua and it'll work across
all supported platforms, including Windows. This gives you a level of
control of the system that Lua traditionally hasn't been able to have
due to its focus on old portable stdio rather modern POSIX APIs. Demo
code has been added to redbean-demo.com to show how it works.

This change also modifies Lua so that integer literals with a leading
zero will be interpreted as octal. That should help avoid shooting in
the foot with POSIX APIs that frequently use octal mode bits.

This change fixes a bug in opendir(".") on New Technology.

Lastly, redbean will now serve crash reports to private network IPs.
This is consistent with other frameworks. However that isn't served
to public IPs unless the -E flag is passed to redbean at startup.
This commit is contained in:
Justine Tunney 2022-04-13 08:49:17 -07:00
parent f684e348d4
commit 281a0f2730
39 changed files with 2044 additions and 84 deletions

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/macros.internal.inc"
.scall umask,0x03c03c03c203c05f,globl
.scall sys_umask,0x03c03c03c203c05f,globl

View file

@ -619,9 +619,9 @@ syscon clock CLOCK_REALTIME_COARSE 5 -1 -1 -1 -1 -1 # Linux 2.6.32
syscon clock CLOCK_MONOTONIC_COARSE 6 -1 -1 -1 -1 -1 # Linux 2.6.32+; bsd consensus; not available on RHEL5
syscon clock CLOCK_PROF -1 -1 2 -1 2 -1 #
syscon clock CLOCK_BOOTTIME 7 -1 -1 6 6 -1 #
syscon clock CLOCK_REALTIME_ALARM 8 -1 -1 -1 -1 -1 # bsd consensus
syscon clock CLOCK_BOOTTIME_ALARM 9 -1 -1 -1 -1 -1 # bsd consensus
syscon clock CLOCK_TAI 11 -1 -1 -1 -1 -1 # bsd consensus
syscon clock CLOCK_REALTIME_ALARM 8 -1 -1 -1 -1 -1 #
syscon clock CLOCK_BOOTTIME_ALARM 9 -1 -1 -1 -1 -1 #
syscon clock CLOCK_TAI 11 -1 -1 -1 -1 -1 #
# poll()
#

View file

@ -134,7 +134,7 @@ scall sys_fchmod 0x07c07c07c207c05b globl hidden
scall sys_chown 0x010010010201005c globl hidden # impl. w/ fchownat() @asyncsignalsafe
scall sys_fchown 0x07b07b07b207b05d globl hidden # @asyncsignalsafe
scall sys_lchown 0x1130fe0fe216c05e globl hidden # impl. w/ fchownat()
scall umask 0x03c03c03c203c05f globl
scall sys_umask 0x03c03c03c203c05f globl
scall sys_gettimeofday 0x1a20430742074060 globl hidden # xnu esi/edx=0
scall sys_getrlimit 0x0c20c20c220c2061 globl hidden
scall __sys_getrusage 0x1bd0130752075062 globl hidden