X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/003db17f7a36a8098827f40df8fedc087b5a26f6..a4ec38a4c7ef61b04b92d34637c846a8e2e95f7f:/lunaix-os/includes/lunaix/fs/twifs.h diff --git a/lunaix-os/includes/lunaix/fs/twifs.h b/lunaix-os/includes/lunaix/fs/twifs.h index 8df3ddc..b194066 100644 --- a/lunaix-os/includes/lunaix/fs/twifs.h +++ b/lunaix-os/includes/lunaix/fs/twifs.h @@ -2,27 +2,76 @@ #define __LUNAIX_TWIFS_H #include +#include struct twifs_node { - struct v_inode* inode; struct hstr name; + inode_t ino_id; + void* data; uint32_t itype; + char name_val[VFS_NAME_MAXLEN]; struct llist_header children; struct llist_header siblings; - struct v_file_ops fops; + struct + { + int (*write)(struct v_inode* inode, + void* buffer, + size_t len, + size_t fpos); + int (*read)(struct v_inode* inode, + void* buffer, + size_t len, + size_t fpos); + } ops; }; +struct twimap +{ + void* index; + void* buffer; + void* data; + size_t size_acc; + void (*read)(struct twimap* mapping); + int (*go_next)(struct twimap* mapping); + void (*reset)(struct twimap* mapping); +}; + +#define twinode_getdata(inode, type) \ + ({ \ + struct twifs_node* twinode = (struct twifs_node*)(inode)->data; \ + assert(twinode); \ + (type) twinode->data; \ + }) + void twifs_init(); struct twifs_node* -twifs_file_node(struct twifs_node* parent, const char* name, int name_len); +twifs_file_node_vargs(struct twifs_node* parent, const char* fmt, va_list args); struct twifs_node* -twifs_dir_node(struct twifs_node* parent, const char* name, int name_len); +twifs_file_node(struct twifs_node* parent, const char* fmt, ...); struct twifs_node* -twifs_toplevel_node(const char* name, int name_len); +twifs_dir_node(struct twifs_node* parent, const char* fmt, ...); + +int +twifs_rm_node(struct twifs_node* node); + +#define twimap_index(twimap, type) ((type)((twimap)->index)) +#define twimap_data(twimap, type) ((type)((twimap)->data)) + +struct twimap* +twifs_mapping(struct twifs_node* parent, void* data, const char* fmt, ...); + +void +twimap_printf(struct twimap* mapping, const char* fmt, ...); + +int +twimap_memcpy(struct twimap* mapping, const void* src, const size_t len); + +int +twimap_memappend(struct twimap* mapping, const void* src, const size_t len); #endif /* __LUNAIX_TWIFS_H */