agendafs
A filesystem for your calendar.
git clone git://mccd.space/agendafscommit 2cc5c4798900180da0cf7fc5a98e62d039db0a51
parent 14ea162e49946d1373923863a2dc78d64c2e8f27
Author: Marc Coquand <marc@coquand.email>
Date: Mon, 28 Jul 2025 09:36:16 +0200
Disallow hidden files
We will levarage those later.
Diffstat:
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/main.c b/main.c
@@ -177,7 +177,6 @@ fuse_read(const char *path, char *buf, size_t size, off_t offset,
description = "";
}
- // We now treat description as the full content
size_t content_len = strlen(description);
if (offset >= content_len) {
@@ -212,6 +211,11 @@ fuse_write(const char *path, const char *buf, size_t size, off_t offset,
pthread_mutex_lock(&entries_mutex);
int ret_i = 0;
+ if (pathIsHidden(path)) {
+ ret_i = -EPERM;
+ goto cleanup_return;
+ }
+
const struct tree_node *node = get_node_by_path(mreg, path);
if (!node) {
ret_i = -ENONET;
diff --git a/path.c b/path.c
@@ -2,6 +2,7 @@
#include "mregion.h"
#include <assert.h>
#include <errno.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -29,6 +30,12 @@ get_file_extension(memory_region *m, const path *p)
return last_dot;
}
+bool
+pathIsHidden(const path *p)
+{
+ return p[0] == '.';
+}
+
path *
append_path(memory_region *m, const path *parentp, const char *childp)
{
diff --git a/path.h b/path.h
@@ -4,6 +4,7 @@
#include "util.h"
#include <assert.h>
#include <errno.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -16,6 +17,9 @@ without_file_extension(memory_region *m, const path *p);
path *
append_path(memory_region *m, const path *parentp, const char *childp);
+bool
+pathIsHidden(const path *p);
+
const path *
get_filename(const char *full_path);