aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/kernel/fs/ext2.c36
-rw-r--r--src/kernel/fs/ext2.h2
-rw-r--r--src/kernel/fs/vfs.c4
-rw-r--r--src/kernel/fs/vfs.h4
-rw-r--r--src/kernel/kernel.c2
5 files changed, 36 insertions, 12 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
diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c
index 3f506d9..fb1a37e 100644
--- a/src/kernel/kernel.c
+++ b/src/kernel/kernel.c
@@ -8,6 +8,7 @@
#include <kernel/input/input.h>
#include <kernel/acpi/acpi.h>
#include <kernel/lib/lib.h>
+#include <kernel/lib/stdlib.h>
#include <kernel/syscall/syscall.h>
#include <kernel/pci/pci.h>
#include <kernel/net/network.h>
@@ -62,7 +63,6 @@ void kernel_main(uint32_t magic, uint32_t multiboot_address, uint32_t esp)
ata_init();
ext2_init_fs();
- ext2_mount(fs_root);
load_binaries();
set_optimal_resolution();