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
fix: memory leakage in file descriptor allocation
[lunaix-os.git]
/
lunaix-os
/
kernel
/
fs
/
fsm.c
diff --git
a/lunaix-os/kernel/fs/fsm.c
b/lunaix-os/kernel/fs/fsm.c
index 95e12e3e003ec7ecbe2828df9d8bb6262e04bfff..bce983a1c2b51d3c3743cf9edcdca9e2ef43780d 100644
(file)
--- a/
lunaix-os/kernel/fs/fsm.c
+++ b/
lunaix-os/kernel/fs/fsm.c
@@
-11,6
+11,7
@@
#include <klibc/string.h>
#include <lunaix/ds/hashtable.h>
#include <lunaix/fs.h>
#include <klibc/string.h>
#include <lunaix/ds/hashtable.h>
#include <lunaix/fs.h>
+#include <lunaix/mm/valloc.h>
#define HASH_BUCKET_BITS 4
#define HASH_BUCKET_NUM (1 << HASH_BUCKET_BITS)
#define HASH_BUCKET_BITS 4
#define HASH_BUCKET_NUM (1 << HASH_BUCKET_BITS)
@@
-21,12
+22,14
@@
void
fsm_init()
{
hashtable_init(fs_registry);
fsm_init()
{
hashtable_init(fs_registry);
+
+ fsm_register_all();
}
void
fsm_register(struct filesystem* fs)
{
}
void
fsm_register(struct filesystem* fs)
{
- hstr_rehash(&fs->fs_name, H
ASH_BUCKET_BITS
);
+ hstr_rehash(&fs->fs_name, H
STR_FULL_HASH
);
hashtable_hash_in(fs_registry, &fs->fs_list, fs->fs_name.hash);
}
hashtable_hash_in(fs_registry, &fs->fs_list, fs->fs_name.hash);
}
@@
-35,7
+38,7
@@
fsm_get(const char* fs_name)
{
struct filesystem *pos, *next;
struct hstr str = HSTR(fs_name, 0);
{
struct filesystem *pos, *next;
struct hstr str = HSTR(fs_name, 0);
- hstr_rehash(&str, H
ASH_BUCKET_BITS
);
+ hstr_rehash(&str, H
STR_FULL_HASH
);
hashtable_hash_foreach(fs_registry, str.hash, pos, next, fs_list)
{
hashtable_hash_foreach(fs_registry, str.hash, pos, next, fs_list)
{
@@
-45,4
+48,12
@@
fsm_get(const char* fs_name)
}
return NULL;
}
return NULL;
+}
+
+struct filesystem*
+fsm_new_fs(char* name, size_t name_len)
+{
+ struct filesystem* fs = vzalloc(sizeof(*fs));
+ fs->fs_name = HHSTR(name, name_len, 0);
+ return fs;
}
\ No newline at end of file
}
\ No newline at end of file