Register path libc symbols in static builds
ober
9adf30b29b56ab76b94e6d75e6e00eeb662ea231
--- a/build-jcode-cross.ss +++ b/build-jcode-cross.ss @@ -353,7 +353,8 @@ "sysconf" "getpagesize" "getrlimit" "system" "getenv" "putenv" "_exit" "exit" "execvp" "execve" ;; files/directories/FIFOs — std/os/temp, std/os/posix - "access" "chdir" "stat" "fstat" "lstat" + "access" "chdir" "stat" "fstat" "lstat" "readlink" "realpath" + "mkdir" "fdopen" "mkstemp" "mkdtemp" "mkfifo" "umask" "unlink" "rmdir" ;; errno location + Linux sandboxing "__errno_location" "fcntl" "prctl" "syscall")) --- a/build-jcode-freebsd-cross.ss +++ b/build-jcode-freebsd-cross.ss @@ -342,7 +342,8 @@ "sysconf" "getpagesize" "getrlimit" "system" "getenv" "putenv" "_exit" "execvp" "execve" ;; files/directories/FIFOs — std/os/posix - "access" "chdir" "stat" "fstat" "lstat" "mkfifo" "umask" "unlink" + "access" "chdir" "stat" "fstat" "lstat" "readlink" "realpath" + "mkdir" "fdopen" "mkfifo" "umask" "unlink" "fcntl")) (define main-c-path (string-append output "-main.c")) --- a/build-jcode-musl.ss +++ b/build-jcode-musl.ss @@ -220,7 +220,8 @@ "sysconf" "getpagesize" "getrlimit" "system" "getenv" "putenv" "_exit" "exit" "execvp" "execve" ;; files/directories/FIFOs — std/os/temp, std/os/posix - "access" "chdir" "stat" "fstat" "lstat" + "access" "chdir" "stat" "fstat" "lstat" "readlink" "realpath" + "mkdir" "fdopen" "mkstemp" "mkdtemp" "mkfifo" "umask" "unlink" "rmdir" ;; errno location + Linux sandboxing "__errno_location" "fcntl" "prctl" "syscall")) --- a/support/debug-repl-socket-shim.c +++ b/support/debug-repl-socket-shim.c @@ -5,8 +5,10 @@ #include <netinet/in.h> #include <netdb.h> #include <signal.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/stat.h> #include <sys/file.h> #include <sys/mman.h> #include <sys/socket.h> @@ -42,6 +44,22 @@ int jcode_open(const char *path, int flags, int mode) { return open(path, flags, (mode_t)mode); } +void *jcode_fdopen(int fd, const char *mode) { + return fdopen(fd, mode); +} + +int jcode_mkdir(const char *path, int mode) { + return mkdir(path, (mode_t)mode); +} + +ssize_t jcode_readlink(const char *path, void *buf, size_t bufsiz) { + return readlink(path, (char *)buf, bufsiz); +} + +char *jcode_realpath(const char *path, void *resolved_path) { + return realpath(path, (char *)resolved_path); +} + int jcode_ftruncate(int fd, int64_t length) { return ftruncate(fd, (off_t)length); } --- a/support/ffi-symbols.list +++ b/support/ffi-symbols.list @@ -85,6 +85,10 @@ accept connect close open +fdopen +mkdir +readlink +realpath ftruncate mmap munmap @@ -116,6 +120,10 @@ jcode_accept jcode_connect jcode_close jcode_open +jcode_fdopen +jcode_mkdir +jcode_readlink +jcode_realpath jcode_ftruncate jcode_mmap jcode_munmap --- a/support/jcode-main.c +++ b/support/jcode-main.c @@ -31,6 +31,10 @@ #define connect jcode_connect #define close jcode_close #define open jcode_open +#define fdopen jcode_fdopen +#define mkdir jcode_mkdir +#define readlink jcode_readlink +#define realpath jcode_realpath #define ftruncate jcode_ftruncate #define mmap jcode_mmap #define munmap jcode_munmap @@ -65,6 +69,10 @@ #undef connect #undef close #undef open +#undef fdopen +#undef mkdir +#undef readlink +#undef realpath #undef ftruncate #undef mmap #undef munmap