aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/fs/ext2.c
diff options
context:
space:
mode:
authorMarvin Borner2020-05-01 00:08:53 +0200
committerMarvin Borner2020-05-01 00:08:53 +0200
commit6b48e277cd249d0b5f7b5c7032457bb60dda46d6 (patch)
treeb7634d9bdea49f91096a9e250536dcc1d320656c /src/kernel/fs/ext2.c
parent6c5e31b1e5534748f89233cdebf778247b040cbc (diff)
Some vfs fixes
Diffstat (limited to 'src/kernel/fs/ext2.c')
-rw-r--r--src/kernel/fs/ext2.c36
1 files changed, 29 insertions, 7 deletions
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)