X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/c6de44b989e9d7286337e4cbf4d82d919f9120e6..270869139db617e29a35bb9ded41087bb702f9ac:/lunaix-os/kernel/fs/fsm.c diff --git a/lunaix-os/kernel/fs/fsm.c b/lunaix-os/kernel/fs/fsm.c index a6a2be6..9505838 100644 --- a/lunaix-os/kernel/fs/fsm.c +++ b/lunaix-os/kernel/fs/fsm.c @@ -13,9 +13,13 @@ #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 @@ -23,7 +27,7 @@ fsm_init() { hashtable_init(fs_registry); - fsm_register_all(); + ldga_invoke_fn0(fs); } void @@ -31,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* @@ -59,4 +64,22 @@ fsm_new_fs(char* name, size_t name_len) } fs->fs_name = HHSTR(name, name_len, 0); return fs; -} \ No newline at end of file +} + +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