1 #ifndef __LUNAIX_TWIFS_H
2 #define __LUNAIX_TWIFS_H
4 #include <lunaix/ds/ldga.h>
6 #include <lunaix/fs/twimap.h>
7 #include <lunaix/spike.h>
11 int (*write)(struct v_inode* inode,
15 int (*read)(struct v_inode* inode,
29 char name_val[VFS_NAME_MAXLEN];
30 struct llist_header children;
31 struct llist_header siblings;
46 struct twimap_ops ops;
49 #define twinode_getdata(inode, type) \
51 struct twifs_node* twinode = (struct twifs_node*)(inode)->data; \
53 (type) twinode->data; \
56 #define EXPORT_TWIFS_PLUGIN(label, plg_init) \
57 export_ldga_el(twiplugin_inits, label, ptr_t, plg_init)
59 #define __twifs_export_base(name_, acl_) \
60 .name=stringify(name_), .acl=(acl_)
62 #define twifs_node_ro(name_, acl_) \
63 struct twifs_export __twifs_exp_##name_ = \
64 { __twifs_export_base(name_, acl_), \
65 .ops = { .read = __twifs_read_##name_ }}
67 #define twifs_node_rw(name_, acl_) \
68 struct twifs_export __twifs_exp_##name_ = \
69 { __twifs_export_base(name_, acl_), \
70 .ops = { .read = __twifs_read_##name_, \
71 .write = __twifs_write_##name_ }}
73 #define twimap_value_export(name_, acl_) \
74 struct twimap_export __twimap_exp_##name_ = \
75 { __twifs_export_base(name_, acl_), \
76 .ops = { .read = __twimap_read_##name_ }}
78 #define twimap_list_export(name_, acl_) \
79 struct twimap_export __twimap_exp_##name_ = \
80 { __twifs_export_base(name_, acl_), \
81 .ops = { .read = __twimap_read_##name_, \
82 .go_next = __twimap_gonext_##name_, \
83 .reset = __twimap_reset_##name_, }}
85 #define twifs_export(parent, name_, data_) \
86 twifs_basic_node_from(parent, &__twifs_exp_##name_, data_)
88 #define twimap_export(parent, name_, data_) \
89 twifs_mapped_node_from(parent, &__twimap_exp_##name_, data_)
91 #define twifs_export_ro(parent, name_, acl_, data_) \
93 twifs_node_ro(name_, acl_); \
94 twifs_export(parent, name_, data_); \
97 #define twimap_export_value(parent, name_, acl_, data_) \
99 twimap_value_export(name_, acl_); \
100 twimap_export(parent, name_, data_); \
103 #define twimap_export_list(parent, name_, acl_, data_) \
105 twimap_list_export(name_, acl_); \
106 twimap_export(parent, name_, data_); \
110 twifs_register_plugins();
113 twifs_file_node_vargs(struct twifs_node* parent, const char* fmt, va_list args);
116 twifs_dir_node(struct twifs_node* parent, const char* fmt, ...);
119 twifs_rm_node(struct twifs_node* node);
122 twifs_basic_node_from(struct twifs_node* parent,
123 struct twifs_export* exp_def, void* data);
126 twifs_mapped_node_from(struct twifs_node* parent,
127 struct twimap_export* exp_def, void* data);
130 twifs_mapping(struct twifs_node* parent,
131 void* data, int acl, const char* fmt, ...);
133 #endif /* __LUNAIX_TWIFS_H */