taskfs fix up, minor refactoring
[lunaix-os.git] / lunaix-os / includes / lunaix / fs / taskfs.h
index b96e0e5c5f33f15c685cdeab118702f66c92cdd2..f0ef85f4853eb4f3c86edd74a6c1ba1c537c9d7f 100644 (file)
@@ -3,21 +3,39 @@
 
 #include <lunaix/fs/api.h>
 #include <lunaix/fs/twimap.h>
+#include <lunaix/ds/list.h>
 
 struct task_attribute
 {
-    struct llist_header siblings;
+    struct list_node siblings;
     struct hlist_node attrs;
     struct hstr key;
-    struct twimap* map_file;
-    char key_val[32];
+    struct twimap_ops ops;
 };
 
+#define taskfs_export_attr(name)                            \
+    ({                                                      \
+        taskfs_export_attr_mapping(stringify(name),         \
+        (struct twimap_ops) {                               \
+            __task_read_##name,                             \
+            __twimap_default_gonext, __twimap_default_reset \
+        });                                                 \
+    })
+
+#define taskfs_export_list_attr(name)                       \
+    ({                                                      \
+        taskfs_export_attr_mapping(stringify(name),         \
+        (struct twimap_ops) {                               \
+            __task_read_##name,                             \
+            __task_gonext_##name, __task_reset_##name       \
+        });                                                 \
+    })
+
 void
 taskfs_init();
 
 void
-taskfs_export_attr(const char* key, struct twimap* attr_map_file);
+taskfs_export_attr_mapping(const char* key, struct twimap_ops ops);
 
 struct task_attribute*
 taskfs_get_attr(struct hstr* key);