From f6bc1ccf2462642383d1644321a101e62105c2a7 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 25 Dec 2022 21:47:23 +0100 Subject: user/lib: reorganize a few header files --- src/user/app/ext2fs/main.c | 4 ++-- src/user/app/init/driver/initctl.c | 2 +- src/user/app/init/driver/ps2.c | 2 +- src/user/app/init/init.c | 2 +- src/user/app/logfs/logfs.c | 2 +- src/user/app/login/login.c | 2 +- src/user/app/shell/builtins.c | 2 +- src/user/app/shell/shell.c | 2 +- src/user/app/tests/kernel/path.c | 4 ++-- src/user/app/tmpfs/tmpfs.c | 6 +++--- src/user/app/vterm/vterm.c | 2 +- src/user/bootstrap/main.c | 4 ++-- src/user/bootstrap/tar.c | 5 ++--- src/user/lib/compat.c | 2 +- src/user/lib/compat.h | 6 ------ src/user/lib/fs/dir.c | 2 +- src/user/lib/fs/dir.h | 17 ----------------- src/user/lib/fs/misc.c | 7 +++---- src/user/lib/fs/misc.h | 23 ----------------------- src/user/lib/fs/whitelist.c | 4 ++-- src/user/lib/include/camellia/compat.h | 6 ++++++ src/user/lib/include/camellia/fs/dir.h | 17 +++++++++++++++++ src/user/lib/include/camellia/fs/misc.h | 23 +++++++++++++++++++++++ 23 files changed, 72 insertions(+), 74 deletions(-) delete mode 100644 src/user/lib/compat.h delete mode 100644 src/user/lib/fs/dir.h delete mode 100644 src/user/lib/fs/misc.h create mode 100644 src/user/lib/include/camellia/compat.h create mode 100644 src/user/lib/include/camellia/fs/dir.h create mode 100644 src/user/lib/include/camellia/fs/misc.h diff --git a/src/user/app/ext2fs/main.c b/src/user/app/ext2fs/main.c index 24d1ab0..4fda57c 100644 --- a/src/user/app/ext2fs/main.c +++ b/src/user/app/ext2fs/main.c @@ -1,6 +1,8 @@ #include "ext2/ex_cache.h" #include "ext2/ext2.h" #include +#include +#include #include #include #include @@ -8,8 +10,6 @@ #include #include #include -#include -#include struct handle { uint32_t n; diff --git a/src/user/app/init/driver/initctl.c b/src/user/app/init/driver/initctl.c index b9fe1c9..76d1b1b 100644 --- a/src/user/app/init/driver/initctl.c +++ b/src/user/app/init/driver/initctl.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include void initctl_drv(handle_t killswitch) { struct ufs_request res; diff --git a/src/user/app/init/driver/ps2.c b/src/user/app/init/driver/ps2.c index 5e9aeac..1accbfc 100644 --- a/src/user/app/init/driver/ps2.c +++ b/src/user/app/init/driver/ps2.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include static const char keymap_lower[] = { diff --git a/src/user/app/init/init.c b/src/user/app/init/init.c index f89e407..10511b8 100644 --- a/src/user/app/init/init.c +++ b/src/user/app/init/init.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #define die(fmt, ...) do { fprintf(stderr, "init: " fmt, __VA_ARGS__); exit(1); } while (0) diff --git a/src/user/app/logfs/logfs.c b/src/user/app/logfs/logfs.c index ba25564..14a8f2a 100644 --- a/src/user/app/logfs/logfs.c +++ b/src/user/app/logfs/logfs.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include _Noreturn void fs(void) { const size_t buflen = 1024; diff --git a/src/user/app/login/login.c b/src/user/app/login/login.c index af6e19c..a348254 100644 --- a/src/user/app/login/login.c +++ b/src/user/app/login/login.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include static const char *shell = "/bin/shell"; diff --git a/src/user/app/shell/builtins.c b/src/user/app/shell/builtins.c index 6368633..4ea6c9a 100644 --- a/src/user/app/shell/builtins.c +++ b/src/user/app/shell/builtins.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #define DEFAULT_ARGV(...) \ char *_argv_default[] = {argv[0], __VA_ARGS__}; \ diff --git a/src/user/app/shell/shell.c b/src/user/app/shell/shell.c index 290102e..365e087 100644 --- a/src/user/app/shell/shell.c +++ b/src/user/app/shell/shell.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include int main(); diff --git a/src/user/app/tests/kernel/path.c b/src/user/app/tests/kernel/path.c index fd6eeec..2bce344 100644 --- a/src/user/app/tests/kernel/path.c +++ b/src/user/app/tests/kernel/path.c @@ -1,8 +1,8 @@ #include "../tests.h" #include #include -#include -#include +#include +#include static void test_path_simplify(void) { const char *testcases[][2] = { diff --git a/src/user/app/tmpfs/tmpfs.c b/src/user/app/tmpfs/tmpfs.c index 7614d92..3b4d7d5 100644 --- a/src/user/app/tmpfs/tmpfs.c +++ b/src/user/app/tmpfs/tmpfs.c @@ -1,14 +1,14 @@ +#include #include +#include #include #include #include -#include #include #include #include +#include #include -#include -#include struct node { const char *name; diff --git a/src/user/app/vterm/vterm.c b/src/user/app/vterm/vterm.c index bb60a34..76f6a17 100644 --- a/src/user/app/vterm/vterm.c +++ b/src/user/app/vterm/vterm.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include struct point cursor = {0}; diff --git a/src/user/bootstrap/main.c b/src/user/bootstrap/main.c index a0885dd..97b980b 100644 --- a/src/user/bootstrap/main.c +++ b/src/user/bootstrap/main.c @@ -1,9 +1,9 @@ #include #include -#include #include +#include #include -#include +#include #include "tar.h" diff --git a/src/user/bootstrap/tar.c b/src/user/bootstrap/tar.c index 2968995..2020fe0 100644 --- a/src/user/bootstrap/tar.c +++ b/src/user/bootstrap/tar.c @@ -2,12 +2,11 @@ #include #include #include -#include #include #include #include -#include -#include +#include +#include #define BUF_SIZE 64 diff --git a/src/user/lib/compat.c b/src/user/lib/compat.c index 63ae717..4634f57 100644 --- a/src/user/lib/compat.c +++ b/src/user/lib/compat.c @@ -1,6 +1,6 @@ #include #include -#include +#include #define eprintf(fmt, ...) fprintf(stderr, "user/lib/compat: "fmt"\n" __VA_OPT__(,) __VA_ARGS__) diff --git a/src/user/lib/compat.h b/src/user/lib/compat.h deleted file mode 100644 index a7c6f1f..0000000 --- a/src/user/lib/compat.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once -#include - -/* c0 - fs_wait returning a handle */ -long c0_fs_wait(char *buf, long len, struct ufs_request *res); -long c0_fs_respond(void *buf, long ret, int flags); diff --git a/src/user/lib/fs/dir.c b/src/user/lib/fs/dir.c index 4235ea6..71b2209 100644 --- a/src/user/lib/fs/dir.c +++ b/src/user/lib/fs/dir.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include void dir_start(struct dirbuild *db, long offset, char *buf, size_t buflen) { db->offset = offset; diff --git a/src/user/lib/fs/dir.h b/src/user/lib/fs/dir.h deleted file mode 100644 index c3bbfe7..0000000 --- a/src/user/lib/fs/dir.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include -#include -#include - -struct dirbuild { - long offset; - char *buf; - long bpos, blen; - long error; -}; - -void dir_start(struct dirbuild *db, long offset, char *buf, size_t buflen); -bool dir_append(struct dirbuild *db, const char *name); -bool dir_appendl(struct dirbuild *db, const char *name, size_t len); -bool dir_append_from(struct dirbuild *db, handle_t h); -long dir_finish(struct dirbuild *db); diff --git a/src/user/lib/fs/misc.c b/src/user/lib/fs/misc.c index 860b312..11428b8 100644 --- a/src/user/lib/fs/misc.c +++ b/src/user/lib/fs/misc.c @@ -1,15 +1,14 @@ #include #include #include -#include #include #include #include #include #include -#include -#include -#include +#include +#include +#include bool fork2_n_mount(const char *path) { handle_t h; diff --git a/src/user/lib/fs/misc.h b/src/user/lib/fs/misc.h deleted file mode 100644 index 35184e1..0000000 --- a/src/user/lib/fs/misc.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include -#include - -bool fork2_n_mount(const char *path); - -void forward_open(handle_t reqh, const char *path, long len, int flags); - -void fs_passthru(const char *prefix); -void fs_whitelist(const char **list); -void fs_union(const char **list); - -void fs_dir_inject(const char *path); - -bool mount_at_pred(const char *path); - -// TODO separate fs drivers and wrappers around syscalls - -/** like _syscall_fs_wait, but ensures *buf is a null terminated string on VFSOP_OPEN */ -handle_t ufs_wait(char *buf, size_t len, struct ufs_request *req); - -/** Mounts something and injects its path into the fs */ -#define MOUNT_AT(path) for (; mount_at_pred(path); exit(1)) diff --git a/src/user/lib/fs/whitelist.c b/src/user/lib/fs/whitelist.c index 571ebfb..5612d9a 100644 --- a/src/user/lib/fs/whitelist.c +++ b/src/user/lib/fs/whitelist.c @@ -3,8 +3,8 @@ #include #include #include -#include -#include +#include +#include static int dir_seglen2(const char *path, size_t len) { /* returns the length of the first segment of the path, including the trailing / (if any). */ diff --git a/src/user/lib/include/camellia/compat.h b/src/user/lib/include/camellia/compat.h new file mode 100644 index 0000000..a7c6f1f --- /dev/null +++ b/src/user/lib/include/camellia/compat.h @@ -0,0 +1,6 @@ +#pragma once +#include + +/* c0 - fs_wait returning a handle */ +long c0_fs_wait(char *buf, long len, struct ufs_request *res); +long c0_fs_respond(void *buf, long ret, int flags); diff --git a/src/user/lib/include/camellia/fs/dir.h b/src/user/lib/include/camellia/fs/dir.h new file mode 100644 index 0000000..c3bbfe7 --- /dev/null +++ b/src/user/lib/include/camellia/fs/dir.h @@ -0,0 +1,17 @@ +#pragma once +#include +#include +#include + +struct dirbuild { + long offset; + char *buf; + long bpos, blen; + long error; +}; + +void dir_start(struct dirbuild *db, long offset, char *buf, size_t buflen); +bool dir_append(struct dirbuild *db, const char *name); +bool dir_appendl(struct dirbuild *db, const char *name, size_t len); +bool dir_append_from(struct dirbuild *db, handle_t h); +long dir_finish(struct dirbuild *db); diff --git a/src/user/lib/include/camellia/fs/misc.h b/src/user/lib/include/camellia/fs/misc.h new file mode 100644 index 0000000..35184e1 --- /dev/null +++ b/src/user/lib/include/camellia/fs/misc.h @@ -0,0 +1,23 @@ +#pragma once +#include +#include + +bool fork2_n_mount(const char *path); + +void forward_open(handle_t reqh, const char *path, long len, int flags); + +void fs_passthru(const char *prefix); +void fs_whitelist(const char **list); +void fs_union(const char **list); + +void fs_dir_inject(const char *path); + +bool mount_at_pred(const char *path); + +// TODO separate fs drivers and wrappers around syscalls + +/** like _syscall_fs_wait, but ensures *buf is a null terminated string on VFSOP_OPEN */ +handle_t ufs_wait(char *buf, size_t len, struct ufs_request *req); + +/** Mounts something and injects its path into the fs */ +#define MOUNT_AT(path) for (; mount_at_pred(path); exit(1)) -- cgit v1.2.3