git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
feat: lseek(2), read(2), write(2) implementation
[lunaix-os.git]
/
lunaix-os
/
kernel
/
fs
/
twifs.c
diff --git
a/lunaix-os/kernel/fs/twifs.c
b/lunaix-os/kernel/fs/twifs.c
index a50a657b42867b9f3813c698f2320dc2c91ce81d..ad226ca8d74a2d0069808b7ffadd9a6bd342f11c 100644
(file)
--- 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 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));
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) {
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 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;
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;