X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/77e7b21f117eecd04bb31257ee68dfc1f425a47e..6fefc6f5af83f316e18b0cb9dbbde1cea0b98add:/lunaix-os/kernel/fs/twifs.c diff --git a/lunaix-os/kernel/fs/twifs.c b/lunaix-os/kernel/fs/twifs.c index a50a657..ad226ca 100644 --- a/lunaix-os/kernel/fs/twifs.c +++ b/lunaix-os/kernel/fs/twifs.c @@ -59,18 +59,11 @@ twifs_init() struct twifs_node* __twifs_new_node(struct twifs_node* parent, const char* name, int name_len) { - struct hstr hname = HSTR(name, name_len); - hstr_rehash(&hname, HSTR_FULL_HASH); - - struct twifs_node* node = __twifs_get_node(parent, &hname); - if (node) { - return node; - } - - node = cake_grab(twi_pile); + struct twifs_node* node = cake_grab(twi_pile); memset(node, 0, sizeof(*node)); - node->name = hname; + node->name = HSTR(name, name_len); + hstr_rehash(&node->name, HSTR_FULL_HASH); llist_init_head(&node->children); if (parent) { @@ -95,6 +88,13 @@ twifs_file_node(struct twifs_node* parent, const char* name, int name_len) struct twifs_node* twifs_dir_node(struct twifs_node* parent, const char* name, int name_len) { + struct hstr hname = HSTR(name, name_len); + hstr_rehash(&hname, HSTR_FULL_HASH); + struct twifs_node* node = __twifs_get_node(parent, &hname); + if (node) { + return node; + } + struct twifs_node* twi_node = __twifs_new_node(parent, name, name_len); twi_node->itype = VFS_INODE_TYPE_DIR; twi_node->fops.readdir = __twifs_iterate_dir;