agendafs
A filesystem for your calendar.
git clone git://mccd.space/agendafscommit d277c78f2c6873f751fa7cdad136b809b63a2da8
parent 94f608109c357719f8016b33c4177b32f32731a3
Author: Marc Coquand <marc@coquand.email>
Date: Thu, 10 Jul 2025 10:49:07 +0200
Refactor
References: https://todo.sr.ht/~marcc/agendafs/1
Diffstat:
| M | main.c | | | 33 | +++++++++++++++++++++++++++++++++ |
1 file changed, 33 insertions(+), 0 deletions(-)
diff --git a/main.c b/main.c
@@ -327,6 +327,28 @@ journal_create(const char *filename, mode_t mode, struct fuse_file_info *info)
}
static int
+journal_removexattr(const char *path, const char *header)
+{
+ LOG("REMOVEXATTR '%s' '%s'", path, header);
+
+ if (strcmp(header, "user.categories") != 0) {
+ return -EINVAL;
+ }
+
+ pthread_mutex_lock(&entries_mutex);
+ struct tree_node *node = get_node_by_path(path);
+ if (!node) {
+ pthread_mutex_unlock(&entries_mutex);
+ return -ENONET;
+ }
+
+ int status = set_node_categories(node, "", 0);
+ pthread_mutex_unlock(&entries_mutex);
+
+ return status;
+}
+
+static int
journal_setxattr(const char *path, const char *header,
const char *new_attributes, size_t s, int flags)
{
@@ -339,6 +361,12 @@ journal_setxattr(const char *path, const char *header,
pthread_mutex_lock(&entries_mutex);
struct tree_node *node = get_node_by_path(path);
+ if (!node) {
+ pthread_mutex_unlock(&entries_mutex);
+
+ return -ENONET;
+ }
+
int status = set_node_categories(node, new_attributes, s);
pthread_mutex_unlock(&entries_mutex);
@@ -356,6 +384,11 @@ journal_getxattr(const char *path, const char *header, char *buf, size_t s)
pthread_mutex_lock(&entries_mutex);
struct tree_node *node = get_node_by_path(path);
+ if (!node) {
+ pthread_mutex_unlock(&entries_mutex);
+
+ return -ENONET;
+ }
const char *cats = get_node_categories(node);
pthread_mutex_unlock(&entries_mutex);