refactor: add a simple ramfs for rootfs. Twifs should have more specific job in future.
[lunaix-os.git] / lunaix-os / includes / lunaix / fs / twifs.h
1 #ifndef __LUNAIX_TWIFS_H
2 #define __LUNAIX_TWIFS_H
3
4 #include <lunaix/fs.h>
5
6 struct twifs_node
7 {
8     struct hstr name;
9     inode_t ino_id;
10     void* data;
11     uint32_t itype;
12     struct llist_header children;
13     struct llist_header siblings;
14     struct
15     {
16         int (*write)(struct v_inode* inode,
17                      void* buffer,
18                      size_t len,
19                      size_t fpos);
20         int (*read)(struct v_inode* inode,
21                     void* buffer,
22                     size_t len,
23                     size_t fpos);
24     } ops;
25 };
26
27 void
28 twifs_init();
29
30 struct twifs_node*
31 twifs_file_node(struct twifs_node* parent,
32                 const char* name,
33                 int name_len,
34                 uint32_t itype);
35
36 struct twifs_node*
37 twifs_dir_node(struct twifs_node* parent,
38                const char* name,
39                int name_len,
40                uint32_t itype);
41
42 struct twifs_node*
43 twifs_toplevel_node(const char* name, int name_len, uint32_t itype);
44
45 int
46 twifs_rm_node(struct twifs_node* node);
47
48 #endif /* __LUNAIX_TWIFS_H */