diff options
author | Marvin Borner | 2020-05-01 00:08:53 +0200 |
---|---|---|
committer | Marvin Borner | 2020-05-01 00:08:53 +0200 |
commit | 6b48e277cd249d0b5f7b5c7032457bb60dda46d6 (patch) | |
tree | b7634d9bdea49f91096a9e250536dcc1d320656c /src/kernel/fs | |
parent | 6c5e31b1e5534748f89233cdebf778247b040cbc (diff) |
Some vfs fixes
Diffstat (limited to 'src/kernel/fs')
-rw-r--r-- | src/kernel/fs/ext2.c | 36 | ||||
-rw-r--r-- | src/kernel/fs/ext2.h | 2 | ||||
-rw-r--r-- | src/kernel/fs/vfs.c | 4 | ||||
-rw-r--r-- | src/kernel/fs/vfs.h | 4 |
4 files changed, 35 insertions, 11 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) diff --git a/src/kernel/fs/ext2.h b/src/kernel/fs/ext2.h index 88515a3..8747c19 100644 --- a/src/kernel/fs/ext2.h +++ b/src/kernel/fs/ext2.h @@ -4,6 +4,7 @@ #include <stdint.h> #include <stddef.h> #include <stdbool.h> +#include <kernel/fs/vfs.h> #define ROOT_INODE 2 @@ -138,5 +139,6 @@ uint32_t ext2_find_in_dir(uint32_t dir_inode, const char *name); uint32_t ext2_look_up_path(char *path); uint8_t *read_file(char *path); +void ext2_mount(struct fs_node *mountpoint); #endif
\ No newline at end of file diff --git a/src/kernel/fs/vfs.c b/src/kernel/fs/vfs.c index 98ec6fb..68944c7 100644 --- a/src/kernel/fs/vfs.c +++ b/src/kernel/fs/vfs.c @@ -32,7 +32,7 @@ void fs_close(struct fs_node *node) node->close(node); } -struct dirent *fs_read_directory(struct fs_node *node, uint32_t index) +struct dirent *fs_read_dir(struct fs_node *node, uint32_t index) { if ((node->type & DIR_NODE) != 0 && node->find_dir != NULL) return node->read_dir(node, index); @@ -40,7 +40,7 @@ struct dirent *fs_read_directory(struct fs_node *node, uint32_t index) return (struct dirent *)NULL; } -struct fs_node *fs_find_directory(struct fs_node *node, char *name) +struct fs_node *fs_find_dir(struct fs_node *node, char *name) { if ((node->type & DIR_NODE) != 0 && node->find_dir != NULL) return node->find_dir(node, name); diff --git a/src/kernel/fs/vfs.h b/src/kernel/fs/vfs.h index fe897cc..6a26c07 100644 --- a/src/kernel/fs/vfs.h +++ b/src/kernel/fs/vfs.h @@ -57,7 +57,7 @@ uint32_t fs_read(struct fs_node *node, uint32_t offset, uint32_t size, char *buf uint32_t fs_write(struct fs_node *node, uint32_t offset, uint32_t size, char *buf); void fs_open(struct fs_node *node); void fs_close(struct fs_node *node); -struct dirent *fs_read_directory(struct fs_node *node, uint32_t index); -struct fs_node *fs_find_directory(struct fs_node *node, char *name); +struct dirent *fs_read_dir(struct fs_node *node, uint32_t index); +struct fs_node *fs_find_dir(struct fs_node *node, char *name); #endif
\ No newline at end of file |