mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
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:
parent
f684e348d4
commit
281a0f2730
39 changed files with 2044 additions and 84 deletions
|
@ -116,16 +116,18 @@ struct dirent_netbsd {
|
|||
static textwindows DIR *opendir_nt_impl(char16_t *name, size_t len) {
|
||||
DIR *res;
|
||||
if (len + 2 + 1 <= PATH_MAX) {
|
||||
if (len > 1 && name[len - 1] != u'\\') {
|
||||
name[len++] = u'\\';
|
||||
if (len == 1 && name[0] == '.') {
|
||||
name[0] = '*';
|
||||
} else {
|
||||
if (len > 1 && name[len - 1] != u'\\') {
|
||||
name[len++] = u'\\';
|
||||
}
|
||||
name[len++] = u'*';
|
||||
}
|
||||
name[len++] = u'*';
|
||||
name[len] = u'\0';
|
||||
if ((res = calloc(1, sizeof(DIR)))) {
|
||||
if ((res->fd = FindFirstFile(name, &res->windata)) != -1) {
|
||||
return res;
|
||||
} else {
|
||||
__winerr();
|
||||
}
|
||||
free(res);
|
||||
}
|
||||
|
@ -342,6 +344,7 @@ struct dirent *readdir(DIR *dir) {
|
|||
if (dir->buf_pos >= dir->buf_end) {
|
||||
basep = dir->tell; /* TODO(jart): what does xnu do */
|
||||
rc = getdents(dir->fd, dir->buf, sizeof(dir->buf) - 256, &basep);
|
||||
STRACE("getdents(%d) → %d% m", dir->fd, rc);
|
||||
if (!rc || rc == -1) return NULL;
|
||||
dir->buf_pos = 0;
|
||||
dir->buf_end = rc;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue