From 8929eb838bec8d3f5eb0d5a1c6b91a4f27d0baff Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 17 Jun 2023 18:42:52 +0200 Subject: libc: dumb stat() stubs to make dash's PATH search work --- src/user/lib/sysstat.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/user/lib/sysstat.c') diff --git a/src/user/lib/sysstat.c b/src/user/lib/sysstat.c index df192c5..97bb50b 100644 --- a/src/user/lib/sysstat.c +++ b/src/user/lib/sysstat.c @@ -1,7 +1,33 @@ +#include #include #include #include #include +#include + +int fstat(int fd, struct stat *sb) { + (void)fd; + memset(sb, 0, sizeof sb); + // TODO save info if it was a dir + sb->st_mode = 0777 | S_IFREG; + return 0; +} + +int stat(const char *restrict path, struct stat *restrict sb) { + int fd, ret; + fd = camellia_open(path, OPEN_READ); + if (fd < 0) { + return -1; + } + ret = fstat(fd, sb); + close(fd); + return ret; +} + +int lstat(const char *restrict path, struct stat *restrict sb) { + // TODO assumes no symlink support + return stat(path, sb); +} int mkdir(const char *path, mode_t mode) { // TODO error when directory already exits -- cgit v1.2.3