X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/a5338b60e111972364a8bc6f07011c6defd213d2..11b423249f224e3c9b7d940862c3cae310f81a23:/lunaix-os/kernel/fs/fsm.c?ds=sidebyside diff --git a/lunaix-os/kernel/fs/fsm.c b/lunaix-os/kernel/fs/fsm.c index 10e766a..9505838 100644 --- a/lunaix-os/kernel/fs/fsm.c +++ b/lunaix-os/kernel/fs/fsm.c @@ -11,16 +11,23 @@ #include #include #include +#include + +#include +#include #define HASH_BUCKET_BITS 4 #define HASH_BUCKET_NUM (1 << HASH_BUCKET_BITS) +DEFINE_LLIST(fs_flatlist); DECLARE_HASHTABLE(fs_registry, HASH_BUCKET_NUM); void fsm_init() { hashtable_init(fs_registry); + + ldga_invoke_fn0(fs); } void @@ -28,6 +35,7 @@ fsm_register(struct filesystem* fs) { hstr_rehash(&fs->fs_name, HSTR_FULL_HASH); hashtable_hash_in(fs_registry, &fs->fs_list, fs->fs_name.hash); + llist_append(&fs_flatlist, &fs->fs_flat); } struct filesystem* @@ -45,4 +53,33 @@ fsm_get(const char* fs_name) } return NULL; -} \ No newline at end of file +} + +struct filesystem* +fsm_new_fs(char* name, size_t name_len) +{ + struct filesystem* fs = vzalloc(sizeof(*fs)); + if (name_len == (size_t)-1) { + name_len = strlen(name); + } + fs->fs_name = HHSTR(name, name_len, 0); + return fs; +} + +static void +read_fslist(struct twimap *mapping) +{ + struct filesystem *pos, *n; + llist_for_each(pos, n, &fs_flatlist, fs_flat) + { + twimap_printf(mapping, "%s %d\n", pos->fs_name.value, pos->types); + } +} + +static void +fstab_twifs_plugin() +{ + struct twimap* map = twifs_mapping(NULL, NULL, "fstab"); + map->read = read_fslist; +} +EXPORT_TWIFS_PLUGIN(fstab, fstab_twifs_plugin); \ No newline at end of file