taskfs fix up, minor refactoring
[lunaix-os.git] / lunaix-os / includes / lunaix / fs / taskfs.h
1 #ifndef __LUNAIX_TASKFS_H
2 #define __LUNAIX_TASKFS_H
3
4 #include <lunaix/fs/api.h>
5 #include <lunaix/fs/twimap.h>
6 #include <lunaix/ds/list.h>
7
8 struct task_attribute
9 {
10     struct list_node siblings;
11     struct hlist_node attrs;
12     struct hstr key;
13     struct twimap_ops ops;
14 };
15
16 #define taskfs_export_attr(name)                            \
17     ({                                                      \
18         taskfs_export_attr_mapping(stringify(name),         \
19         (struct twimap_ops) {                               \
20             __task_read_##name,                             \
21             __twimap_default_gonext, __twimap_default_reset \
22         });                                                 \
23     })
24
25 #define taskfs_export_list_attr(name)                       \
26     ({                                                      \
27         taskfs_export_attr_mapping(stringify(name),         \
28         (struct twimap_ops) {                               \
29             __task_read_##name,                             \
30             __task_gonext_##name, __task_reset_##name       \
31         });                                                 \
32     })
33
34 void
35 taskfs_init();
36
37 void
38 taskfs_export_attr_mapping(const char* key, struct twimap_ops ops);
39
40 struct task_attribute*
41 taskfs_get_attr(struct hstr* key);
42
43 void
44 taskfs_invalidate(pid_t pid);
45
46 #endif /* __LUNAIX_TASKFS_H */