agendafs

A filesystem for your calendar.

git clone git://mccd.space/agendafs
commit b007ae8b1bc47cf56f4b0395eb1b4cb541a50fdd
parent efb6463b6e6ad131ae8d5d1501cba0b0afbfac9f
Author: Marc Coquand <marc@coquand.email>
Date:   Tue, 22 Jul 2025 15:24:05 +0200

Cleanup

Diffstat:
Mmain.c | 51+++++++++++----------------------------------------
1 file changed, 11 insertions(+), 40 deletions(-)
diff --git a/main.c b/main.c
@@ -117,60 +117,31 @@ journal_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
 	filler(buf, ".", NULL, 0, 0);
 	filler(buf, "..", NULL, 0, 0);
 
-	// If we are in the root directory, expose the "journal" directory
-	if (strcmp(path, "/") == 0) {
-		LOG("IS ROOT");
-
-		for (size_t i = 0; i < fuse_root->child_count; i++) {
-
-			const struct tree_node *node = fuse_root->children[i];
+	const struct tree_node *node = get_node_by_path(mreg, path);
+	if (node) {
+		for (size_t i = 0; i < node->child_count; i++) {
+			const struct tree_node *child = node->children[i];
 			icalcomponent *ic =
-			    get_icalcomponent_from_node(mreg, node);
+			    get_icalcomponent_from_node(mreg, child);
 
 			struct stat st = {0};
 			// TODO: Fix
 			st.st_ino = i + 1;
 			st.st_mode = S_IFREG | 0744;
 
-			st.st_uid = get_node_uid(node);
-			st.st_gid = get_node_gid(node);
+			st.st_uid = get_node_uid(child);
+			st.st_gid = get_node_gid(child);
 
-			if (node_is_directory(mreg, node, ic)) {
+			if (node_is_directory(mreg, child, ic)) {
 				st.st_mode = S_IFDIR | 0755;
 			}
 
-			filler(buf, get_node_filename(mreg, node), &st, 0, 0);
+			filler(buf, get_node_filename(mreg, child), &st, 0, 0);
 		}
 	}
 	else {
-		const struct tree_node *node = get_node_by_path(mreg, path);
-		if (node) {
-			for (size_t i = 0; i < node->child_count; i++) {
-				const struct tree_node *child =
-				    node->children[i];
-				icalcomponent *ic =
-				    get_icalcomponent_from_node(mreg, child);
-
-				struct stat st = {0};
-				// TODO: Fix
-				st.st_ino = i + 1;
-				st.st_mode = S_IFREG | 0744;
-
-				st.st_uid = get_node_uid(child);
-				st.st_gid = get_node_gid(child);
-
-				if (node_is_directory(mreg, child, ic)) {
-					st.st_mode = S_IFDIR | 0755;
-				}
-
-				filler(buf, get_node_filename(mreg, child), &st,
-				       0, 0);
-			}
-		}
-		else {
-			status = -ENOENT;
-			goto cleanup_return;
-		}
+		status = -ENOENT;
+		goto cleanup_return;
 	}
 
 cleanup_return: