Compare commits

..

2 Commits

Author SHA1 Message Date
424543cd99 Updated Makefile to use gcc instead of g++. 2024-11-18 18:46:30 +01:00
64aee2d9e5 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.
2024-11-18 18:42:52 +01:00
3 changed files with 39 additions and 25 deletions

View File

@ -15,10 +15,10 @@ SOURCES_DIR := ./sources
BUILD_DIR := ./build
build: $(SOURCES_DIR)/main.cpp
$(CXX) $(O_CFLAGS) $(I_CFLAGS) $(SOURCES_DIR)/main.cpp $(O_LDFLAGS) $(I_LDFLAGS) -o $(BUILD_DIR)/icfs
$(CC) $(O_CFLAGS) $(I_CFLAGS) $(SOURCES_DIR)/main.cpp $(O_LDFLAGS) $(I_LDFLAGS) -o $(BUILD_DIR)/icfs
dev-build: $(SOURCES_DIR)/main.cpp
$(CXX) $(O_CFLAGS_DEBUG) $(I_CFLAGS) $(SOURCES_DIR)/main.cpp $(O_LDFLAGS_DEBUG) $(I_LDFLAGS) -o $(BUILD_DIR)/icfs
$(CC) $(O_CFLAGS_DEBUG) $(I_CFLAGS) $(SOURCES_DIR)/main.cpp $(O_LDFLAGS_DEBUG) $(I_LDFLAGS) -o $(BUILD_DIR)/icfs
clean:
rm $(BUILD_DIR)/icfs

37
sources/main.c Normal file
View File

@ -0,0 +1,37 @@
#include <stdlib.h>
#define FUSE_USE_VERSION 31
#include "sourcefs.h"
#include <fuse3/fuse.h>
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;
}

View File

@ -1,23 +0,0 @@
#define FUSE_USE_VERSION 31
#include <fuse3/fuse.h>
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;
}