KraKern

C++ Kernel
Log | Files | Refs | README | LICENSE | git clone https://git.ne02ptzero.me/git/KraKern

commit 119ae69bc425acd9b77fe7bee7d5d30bdaf5bb6e
parent d79f75cb87ae54f1f0b668155715436935f14ea9
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Mon, 22 Feb 2016 11:10:07 +0100

Fix(Filesystem): Fix an issue on root-scan

Diffstat:
Mincludes/core/FileSystem.hpp | 1-
Mkernel/FileSystem.cpp | 7+++----
Mkernel/Kernel.cpp | 4++--
Mmodules/x86/ModuleExt2.cpp | 7++-----
4 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/includes/core/FileSystem.hpp b/includes/core/FileSystem.hpp @@ -8,7 +8,6 @@ class File; class FileSystem { public: void init(void); - //void mknod(char *module, char *name, u32 flag); File *path(char *p); File *path_parent(char *p, char *fname); u32 link(char *fname, char *newf); diff --git a/kernel/FileSystem.cpp b/kernel/FileSystem.cpp @@ -19,9 +19,7 @@ File *FileSystem::path(char *p) { File *fp = this->_root; char *name, *beg_p, *end_p; - if (p[0] == '/') { - fp = this->_root; - } else { + if (p[0] != '/') { if (__kern.pt.get_current()) fp = __kern.pt.get_current()->get_current_dir(); } @@ -40,7 +38,8 @@ File *FileSystem::path(char *p) { if (!strcmp("..", name)) { fp = fp->get_parent(); } else if (strcmp(".", name)) { - fp->scan(); + if (strcmp("/", fp->get_name())) + fp->scan(); if (!(fp = fp->find(name))) { __kern.mem.kfree(name); return 0; diff --git a/kernel/Kernel.cpp b/kernel/Kernel.cpp @@ -34,13 +34,13 @@ void Kernel::init(multiboot_info *mbi) { this->gdt.init(); this->idt.init(); this->mem.init(mbi->high_mem); - this->pt = *(new ProcessTable()); - this->pt.init(); this->ide = *(new IDE()); this->fs = *(new FileSystem()); this->mods = &__modules; this->mods->init(); this->fs.init(); + this->pt = *(new ProcessTable()); + this->pt.init(); this->ready(); __kern.io.puts("\n"); list_files(this->fs.get_root(), 0); diff --git a/modules/x86/ModuleExt2.cpp b/modules/x86/ModuleExt2.cpp @@ -10,6 +10,7 @@ ModuleExt2::ModuleExt2(char *name, u8 t, int is_root) : Module(name, t) { dir->disk = this->_get_disk_info(0, 0); dir->ext2inode = EXT2_INUM_ROOT; dir->scan(); + __kern.fs.set_root(dir); } } @@ -199,17 +200,13 @@ void ModuleExt2::_scan(Ext2File *dir) { } __kern.mem.kfree(filename); dsize -= dentry->rec_len; - dentry = (struct directory_entry *)((char *) dentry + dentry->rec_len); + dentry = (struct directory_entry *)((char *)dentry + dentry->rec_len); } __kern.mem.kfree(inode); if (f_toclose) { __kern.mem.kfree(dir->map); dir->map = 0; } - for (leaf = (Ext2File *)dir->get_child(); leaf; leaf = (Ext2File *)leaf->get_next()) { - if (leaf->get_type() == TYPE_DIRECTORY) - leaf->scan(); - } if (!strcmp(dir->get_name(), "/")) { __kern.fs.set_root(dir); }