agendafs

A filesystem for your calendar.

git clone git://mccd.space/agendafs
commit 3c0bbcfa9e31e715669e9b1ac83c3713d5a74958
parent 0c64b6aed0d151d8c1989ef265d19e9f8b226dc1
Author: Marc Coquand <marc@coquand.email>
Date:   Fri,  1 Aug 2025 12:00:17 +0200

Add some checks to mkdir

Diffstat:
Mmain.c | 17+++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/main.c b/main.c
@@ -153,12 +153,25 @@ fuse_open(const char *path, struct fuse_file_info *fi)
 }
 
 static int
-fuse_mkdir(const char *path, mode_t mode)
+fuse_mkdir(const char *filepath, mode_t mode)
 {
 	FUSE_WRITE_BEGIN;
 
-	status = create_entry_from_fuse(mreg, path, ENTRY_DIRECTORY);
+	// Reserved
+	if (pathIsHidden(filepath)) {
+		status = -EPERM;
+		goto cleanup_return;
+	}
 
+	struct tree_node *node = get_node_by_path(mreg, filepath);
+	if (node) {
+		status = -EEXIST;
+		goto cleanup_return;
+	}
+
+	status = create_entry_from_fuse(mreg, filepath, ENTRY_DIRECTORY);
+
+cleanup_return:
 	FUSE_CLEANUP;
 	return status;
 }