agendafs
A filesystem for your calendar.
git clone git://mccd.space/agendafscommit 6ae0f55754e057cf2db7ba3c6538001d7c315440
parent d277c78f2c6873f751fa7cdad136b809b63a2da8
Author: Marc Coquand <marc@coquand.email>
Date: Thu, 10 Jul 2025 11:06:32 +0200
Add delete and list xattributes
Closes: https://todo.sr.ht/~marcc/agendafs/1
Diffstat:
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/journal_entry.c b/journal_entry.c
@@ -747,7 +747,7 @@ get_node_categories(const struct tree_node *node)
{
const struct journal_entry *entry = node->data;
if (!entry) {
- return "\0";
+ return "";
}
FILE *memstream = NULL;
@@ -778,7 +778,7 @@ get_node_categories(const struct tree_node *node)
if (fclose(memstream) == EOF) {
free(result_buffer);
- return NULL; // Error during close
+ return "";
}
return result_buffer;
diff --git a/main.c b/main.c
@@ -374,6 +374,34 @@ journal_setxattr(const char *path, const char *header,
}
static int
+journal_listxattr(const char *path, char *list, size_t size)
+{
+
+ 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);
+
+ if (strcmp("", cats) == 0) {
+ return 0;
+ }
+
+ const char *attr_name = "user.categories";
+ size_t attr_name_len = strlen(attr_name);
+ if (size > 0) {
+ strncpy(list, attr_name, size - 1);
+ list[size - 1] = '\0';
+ }
+ return attr_name_len;
+}
+
+static int
journal_getxattr(const char *path, const char *header, char *buf, size_t s)
{
LOG("GETXATTR '%s' '%s' '%zu'\n", path, header, s);
@@ -502,6 +530,8 @@ struct fuse_operations journal_oper = {.getattr = journal_getattr,
.unlink = journal_unlink,
.getxattr = journal_getxattr,
.setxattr = journal_setxattr,
+ .listxattr = journal_listxattr,
+ .removexattr = journal_removexattr,
.rmdir = journal_rmdir,
.readlink = journal_readlink,
.rename = journal_rename};