From 6b48e277cd249d0b5f7b5c7032457bb60dda46d6 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 1 May 2020 00:08:53 +0200 Subject: Some vfs fixes --- src/kernel/fs/ext2.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'src/kernel/fs/ext2.c') diff --git a/src/kernel/fs/ext2.c b/src/kernel/fs/ext2.c index 1d404f4..dcac20d 100644 --- a/src/kernel/fs/ext2.c +++ b/src/kernel/fs/ext2.c @@ -30,16 +30,38 @@ void ext2_init_fs() debug("Type & perms: 0x%x", root_inode.type_and_permissions); debug("Size: %d", root_inode.size); - debug("Files:"); + /* debug("Files:"); */ - struct ext2_file file; - ext2_open_inode(ROOT_INODE, &file); - struct ext2_dirent dirent; + /* struct ext2_file file; */ + /* ext2_open_inode(ROOT_INODE, &file); */ + /* struct ext2_dirent dirent; */ + + /* while (ext2_next_dirent(&file, &dirent)) */ + /* debug("Inode %d, name '%s'", dirent.inode_num, dirent.name); */ + + /* kfree(file.buf); */ - while (ext2_next_dirent(&file, &dirent)) - debug("Inode %d, name '%s'", dirent.inode_num, dirent.name); + fs_root = (struct fs_node *)kmalloc(sizeof(struct fs_node)); + strcpy(fs_root->name, "/"); + fs_root->type = DIR_NODE; + ext2_mount(fs_root); - kfree(file.buf); + // TODO: Fix file tree + struct fs_node *root = fs_root->node_ptr; + root->open(root); + struct dirent *dirent; + int i = 0; + int count = 0; + while ((dirent = fs_read_dir(root, i)) != NULL) { + struct fs_node *node = fs_find_dir(root, dirent->name); + log("%s", dirent->name); + + if (node->type == FILE_NODE) + count++; + + i++; + } + log("%d", count); } static void read_block(uint32_t block_num, void *buf) -- cgit v1.2.3