X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/a4ec38a4c7ef61b04b92d34637c846a8e2e95f7f..cb089e17fcc6bd4823bd919cce2b9e62631cd570:/lunaix-os/kernel/fs/twifs/twifs.c?ds=sidebyside diff --git a/lunaix-os/kernel/fs/twifs/twifs.c b/lunaix-os/kernel/fs/twifs/twifs.c index 4952e9d..437ab0b 100644 --- a/lunaix-os/kernel/fs/twifs/twifs.c +++ b/lunaix-os/kernel/fs/twifs/twifs.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -159,7 +160,7 @@ __twifs_iterate_dir(struct v_file* file, struct dir_context* dctx) if (counter++ >= dctx->index) { dctx->index = counter; dctx->read_complete_callback( - dctx, pos->name.value, pos->name.len, pos->itype); + dctx, pos->name.value, pos->name.len, vfs_get_dtype(pos->itype)); return 1; } } @@ -242,6 +243,30 @@ twifs_init() fs_root = twifs_dir_node(NULL, NULL, 0, 0); } +int +__twifs_twimap_file_read(struct v_inode* inode, + void* buf, + size_t len, + size_t fpos) +{ + struct twimap* map = twinode_getdata(inode, struct twimap*); + return twimap_read(map, buf, len, fpos); +} + +struct twimap* +twifs_mapping(struct twifs_node* parent, void* data, const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + + struct twimap* map = twimap_create(data); + struct twifs_node* node = twifs_file_node_vargs(parent, fmt, args); + node->ops.read = __twifs_twimap_file_read; + node->data = map; + + return map; +} + const struct v_file_ops twifs_file_ops = { .close = default_file_close, .read = __twifs_fread, .write = __twifs_fwrite,