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/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 +++++++++++++++++++++++ 10 files changed, 53 insertions(+), 54 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 (limited to 'src/user/lib') 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