diff options
author | dzwdz | 2023-08-14 18:51:07 +0200 |
---|---|---|
committer | dzwdz | 2023-08-14 18:51:07 +0200 |
commit | 642b5fb0007b64c77d186fcb018d571152ee1d47 (patch) | |
tree | 1c466461f3602d306be309a053edae558ef2568e /src/user/lib/sysstat.c | |
parent | 8050069c57b729c18c19b1a03ab6e4bf63b4735e (diff) |
reorganization: first steps
Diffstat (limited to 'src/user/lib/sysstat.c')
-rw-r--r-- | src/user/lib/sysstat.c | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/user/lib/sysstat.c b/src/user/lib/sysstat.c deleted file mode 100644 index 97bb50b..0000000 --- a/src/user/lib/sysstat.c +++ /dev/null @@ -1,50 +0,0 @@ -#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 - // TODO fopen-like wrapper that calls open() with a processed path - (void)mode; - size_t plen = strlen(path); - char *tmp = NULL; - /* ensure trailing slash */ - if (plen >= 1 && path[plen - 1] != '/') { - tmp = malloc(plen + 2); - memcpy(tmp, path, plen); - tmp[plen] = '/'; - tmp[plen + 1] = '\0'; - path = tmp; - } - FILE *f = fopen(path, "a"); /* sets errno */ - if (f) fclose(f); - free(tmp); - return f == NULL ? -1 : 0; -} |