From 4ae57a7fb13e68c5e6f1c1246a867555dbd986db Mon Sep 17 00:00:00 2001 From: dzwdz Date: Mon, 29 Aug 2022 13:57:47 +0200 Subject: user/lua: implement the bare minimum for it to link and "run" --- src/user/lib/stdio/file.c | 16 +++++++++++++++- src/user/lib/stdio/misc.c | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) (limited to 'src/user/lib/stdio') diff --git a/src/user/lib/stdio/file.c b/src/user/lib/stdio/file.c index 63b004d..8c0fc57 100644 --- a/src/user/lib/stdio/file.c +++ b/src/user/lib/stdio/file.c @@ -1,11 +1,12 @@ #include "file.h" -#include #include +#include #include #include #include #include #include +#include static FILE _stdin_null = { .fd = STDIN_FILENO }; static FILE _stdout_null = { .fd = STDOUT_FILENO }; @@ -124,6 +125,13 @@ int pclose(FILE *f) { return -1; } +// TODO tmpfile() +FILE *tmpfile(void) { + errno = ENOSYS; + return NULL; +} + + int fextflags(FILE *f, int extflags) { int old = f->extflags; f->extflags = extflags; @@ -227,6 +235,12 @@ int fputc(int c, FILE *f) { } int putc(int c, FILE *f) { return fputc(c, f); } +// TODO ungetc +int ungetc(int c, FILE *f) { + (void)c; (void)f; + __libc_panic("unimplemented"); +} + int fseek(FILE *f, long offset, int whence) { return fseeko(f, offset, whence); } diff --git a/src/user/lib/stdio/misc.c b/src/user/lib/stdio/misc.c index 8f872ec..d74c197 100644 --- a/src/user/lib/stdio/misc.c +++ b/src/user/lib/stdio/misc.c @@ -1,5 +1,7 @@ #include #include +#include +#include void perror(const char *s) { if (s) fprintf(stderr, "%s: ", s); @@ -23,3 +25,22 @@ off_t lseek(int fd, off_t off, int whence) { errno = ENOSYS; return -1; } + +int remove(const char *path) { + return unlink(path); +} + +// TODO! VFSOP_MOVE +int rename(const char *old, const char *new) { + (void)old; (void)new; + errno = ENOSYS; + return -1; +} + +// TODO tmpnam +char *tmpnam(char *s) { + static char buf[L_tmpnam]; + if (!s) s = buf; + strcpy(s, "/tmp/tmpnam"); + return s; +} -- cgit v1.2.3