From 64aee2d9e508312774f5383acd5fdd92a5a00f0c Mon Sep 17 00:00:00 2001 From: fedir Date: Mon, 18 Nov 2024 18:42:52 +0100 Subject: [PATCH] Moved from C++ to C. After some consideration I decided to use C instead of C++ because: * `libfuse` is written in C. * C is simpler. * My original concerns with using C turned out to be BS. --- sources/main.c | 37 +++++++++++++++++++++++++++++++++++++ sources/main.cpp | 23 ----------------------- 2 files changed, 37 insertions(+), 23 deletions(-) create mode 100644 sources/main.c delete mode 100644 sources/main.cpp diff --git a/sources/main.c b/sources/main.c new file mode 100644 index 0000000..be7d438 --- /dev/null +++ b/sources/main.c @@ -0,0 +1,37 @@ +#include +#define FUSE_USE_VERSION 31 + +#include "sourcefs.h" +#include + +const char *mountpoint; + +/* + * #In this function we need to: + * + * * Open the folder we are mounting over (and remember it). + * * Initialize the process table. + */ +static void *icfs_init(struct fuse_conn_info *conn, struct fuse_config *cfg) { + (void)conn; /* Explicit way to tell we ignore these arguments. */ + (void)cfg; /* This also silences the compiler warnings. */ + + return NULL; +} + +static const struct fuse_operations icfs_oper = { + .init = icfs_init, +}; + +int main(int argc, char *argv[]) { + + int ret; + + // FUSE won't tell us the mountpoint on it's own, so we need to extract it + // ourselves. + mountpoint = realpath(argv[argc - 2], NULL); + + ret = fuse_main(argc, argv, &icfs_oper, NULL); + + return ret; +} diff --git a/sources/main.cpp b/sources/main.cpp deleted file mode 100644 index 8bab059..0000000 --- a/sources/main.cpp +++ /dev/null @@ -1,23 +0,0 @@ - -#define FUSE_USE_VERSION 31 - -#include - -static void *hello_init(struct fuse_conn_info *conn, struct fuse_config *cfg) { - (void)conn; - cfg->kernel_cache = 1; - return NULL; -} - -static const struct fuse_operations hello_oper = { - .init = hello_init, -}; - -int main(int argc, char *argv[]) { - - int ret; - - ret = fuse_main(argc, argv, &hello_oper, NULL); - - return ret; -}