summaryrefslogtreecommitdiff
path: root/src/user/lib/sysstat.c
diff options
context:
space:
mode:
authordzwdz2023-06-17 18:42:52 +0200
committerdzwdz2023-06-17 18:42:52 +0200
commit8929eb838bec8d3f5eb0d5a1c6b91a4f27d0baff (patch)
tree08f5c8df9ec8c87f724af189af2ae6548424d326 /src/user/lib/sysstat.c
parent657585026a375d2cb2d06ab400f9deb487d89a17 (diff)
libc: dumb stat() stubs to make dash's PATH search work
Diffstat (limited to 'src/user/lib/sysstat.c')
-rw-r--r--src/user/lib/sysstat.c26
1 files changed, 26 insertions, 0 deletions
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 <camellia.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#include <unistd.h>
+
+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