summaryrefslogtreecommitdiff
path: root/Source/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Kernel')
-rw-r--r--Source/Kernel/Core/kmain.wtf.cpp36
-rwxr-xr-xSource/Kernel/Melon.kebin145145 -> 149241 bytes
-rw-r--r--Source/Kernel/MemoryManager/PhysMem.ns.cpp3
-rw-r--r--Source/Kernel/Ressources/Info.txt6
-rw-r--r--Source/Kernel/Ressources/Welcome.txt6
-rw-r--r--Source/Kernel/VFS/DirectoryNode.class.cpp1
-rw-r--r--Source/Kernel/VFS/VFS.ns.cpp4
7 files changed, 41 insertions, 15 deletions
diff --git a/Source/Kernel/Core/kmain.wtf.cpp b/Source/Kernel/Core/kmain.wtf.cpp
index aef98e3..78347d7 100644
--- a/Source/Kernel/Core/kmain.wtf.cpp
+++ b/Source/Kernel/Core/kmain.wtf.cpp
@@ -111,31 +111,29 @@ void kmain(multiboot_info_t* mbd, u32int magic) {
PROCESSING(kvt, "Detecting floppy drives...");
FloppyController::detect(); OK(kvt);
+ PROCESSING(kvt, "Mounting first module as ramfs on root directory...");
FileSystem* fs = new RamFS((u8int*)mods[0].mod_start, 1024 * 1024);
DirectoryNode* cwd;
cwd = fs->getRootNode();
- VFS::setRootNode(cwd);
+ VFS::setRootNode(cwd); OK(kvt);
asm volatile("sti");
while(1) {
- kvt->setColor(0);
- *kvt << "[" << cwd->getName() << "]# ";
kvt->setColor(8);
+ *kvt << "[" << cwd->getName() << "]# ";
+ kvt->setColor(1);
Vector<String> tokens = kvt->readLine().split(" ");
kvt->setColor(0);
if (tokens[0] == "help") {
*kvt << " - Command list for integrated kernel shell:\n";
*kvt << " - help shows this help screen\n";
*kvt << " - reboot reboots your computer\n";
- *kvt << " - ls [<dir>] shows contents of a directory\n";
- *kvt << " - cd <dir> goes to directory <dir>\n";
- *kvt << " - cat <file> shows contents of file <file>\n";
- *kvt << " - pwd prints current directory\n";
*kvt << " - devices shows all detected devices on your computer\n";
*kvt << " - free shows memory usage (physical frames and kernel heap)\n";
*kvt << " - uptime shows seconds since boot\n";
*kvt << " - part shows all detected block devices and partitions\n";
+ *kvt << " - Commands you should know how to use : ls, cd, cat, pwd, rm, mkdir, wf\n";
} else if (tokens[0] == "reboot") {
Sys::reboot();
} else if (tokens[0] == "ls") {
@@ -159,7 +157,7 @@ void kmain(multiboot_info_t* mbd, u32int magic) {
kvt->setCursorCol(30);
*kvt << (s32int)f->getLength() << " bytes.\n";
} else if (n->type() == NT_DIRECTORY) {
- *kvt << " - DIR\t" << n->getName();
+ *kvt << " - DIR\t" << n->getName() << "/";
kvt->setCursorCol(30);
*kvt << (s32int)n->getLength() << " items.\n";
}
@@ -181,9 +179,9 @@ void kmain(multiboot_info_t* mbd, u32int magic) {
for (u32int i = 1; i < tokens.size(); i++) {
FSNode* n = VFS::find(tokens[i], cwd);
if (n == NULL) {
- *kvt << "No such file : " << tokens[1] << "\n";
+ *kvt << "No such file : " << tokens[i] << "\n";
} else if (n->type() != NT_FILE) {
- *kvt << "Not a file : " << tokens[1] << "\n";
+ *kvt << "Not a file : " << tokens[i] << "\n";
} else {
FileNode* f = (FileNode*) n;
u8int *buff = (u8int*)Mem::kalloc(f->getLength() + 1);
@@ -195,6 +193,24 @@ void kmain(multiboot_info_t* mbd, u32int magic) {
}
} else if (tokens[0] == "pwd") {
*kvt << "Current location : " << VFS::path(cwd) << "\n";
+ } else if (tokens[0] == "rm") {
+ if (tokens.size() == 1) *kvt << "No argument specified. I suppose that means I'll have to erase everything.\n";
+ for (u32int i = 1; i < tokens.size(); i++) {
+ if (!VFS::remove(tokens[i], cwd)) {
+ *kvt << "Error while removing file " << tokens[i] << "\n";
+ }
+ }
+ } else if (tokens[0] == "mkdir") {
+ if (tokens.size() > 1) {
+ for (u32int i = 1; i < tokens.size(); i++) {
+ if (VFS::createDirectory(tokens[i], cwd) == NULL)
+ *kvt << "Error while creating directory" << tokens[i] << "\n";
+ }
+ } else {
+ *kvt << "No argument specified. WTF???\n";
+ }
+ } else if (tokens[0] == "wf") {
+ *kvt << "Sorry, this command isn't implemented yet.\n";
} else if (tokens[0] == "devices") {
Vector<Device*> dev = Dev::findDevices();
*kvt << " - Detected devices :\n";
diff --git a/Source/Kernel/Melon.ke b/Source/Kernel/Melon.ke
index 3ec26f0..bdc10a5 100755
--- a/Source/Kernel/Melon.ke
+++ b/Source/Kernel/Melon.ke
Binary files differ
diff --git a/Source/Kernel/MemoryManager/PhysMem.ns.cpp b/Source/Kernel/MemoryManager/PhysMem.ns.cpp
index a9bfd35..19323a7 100644
--- a/Source/Kernel/MemoryManager/PhysMem.ns.cpp
+++ b/Source/Kernel/MemoryManager/PhysMem.ns.cpp
@@ -63,7 +63,8 @@ void freeFrame(page_t *page) {
if (page->frame == 0) {
return;
} else {
- frames->clearBit(page->frame / 0x1000);
+ if (page->frame >= 0x100) //First 1M are reserved (system)
+ frames->clearBit(page->frame / 0x1000);
page->frame = 0;
}
}
diff --git a/Source/Kernel/Ressources/Info.txt b/Source/Kernel/Ressources/Info.txt
new file mode 100644
index 0000000..2b86198
--- /dev/null
+++ b/Source/Kernel/Ressources/Info.txt
@@ -0,0 +1,6 @@
+These files were just added here for fun.
+
+Oh, you wanted to know what the wf command meant ?
+Simple : it means Write File. When it will exist, it will prompt you for
+the textual contents of the file given as an argument. Not very exciting,
+but it might be useful one day.
diff --git a/Source/Kernel/Ressources/Welcome.txt b/Source/Kernel/Ressources/Welcome.txt
index 9af0942..882a4a7 100644
--- a/Source/Kernel/Ressources/Welcome.txt
+++ b/Source/Kernel/Ressources/Welcome.txt
@@ -1,12 +1,12 @@
EN :
-Welcome on this Melon live-floppy ! For the moment, the project isn't very
+Welcome to this Melon live-floppy ! For the moment, the project isn't very
advanced, but if you can read this text, it's already because of a lot of
-great efforts I'v made for developping this.
+great efforts I'v made in Melon's developpment.
FR :
Bienvenue sur cette live-disquette de Melon ! Pour l'instant, le projet
n'est pas très avancé, mais si vous pouvez lire ce texte, c'est déjà grâce
-à un grand travail de ma part dans le développement.
+à un grand travail de ma part dans le développement de Melon.
ES :
[I can't speak Spanish properly, sorry]
diff --git a/Source/Kernel/VFS/DirectoryNode.class.cpp b/Source/Kernel/VFS/DirectoryNode.class.cpp
index 95d2245..415899c 100644
--- a/Source/Kernel/VFS/DirectoryNode.class.cpp
+++ b/Source/Kernel/VFS/DirectoryNode.class.cpp
@@ -71,6 +71,7 @@ bool DirectoryNode::remove(FSNode* child) {
//Remove node from our children list
m_children[idx] = m_children.back();
m_children.pop();
+ m_length--;
delete child;
diff --git a/Source/Kernel/VFS/VFS.ns.cpp b/Source/Kernel/VFS/VFS.ns.cpp
index 6db791a..30ad2d7 100644
--- a/Source/Kernel/VFS/VFS.ns.cpp
+++ b/Source/Kernel/VFS/VFS.ns.cpp
@@ -40,6 +40,7 @@ FSNode* find(const String& path, FSNode* start) {
}
FSNode* createFile(const String& path, FSNode* start) {
+ if (find(path, start) != NULL) return NULL; //Something already has that name.
if (start == 0) start = rootNode;
Vector<String> p = path.split("/");
@@ -71,6 +72,7 @@ FSNode* createFile(const String& path, FSNode* start) {
}
FSNode* createDirectory(const String& path, FSNode* start) {
+ if (find(path, start) != NULL) return NULL; //Something already has that name.
if (start == 0) start = rootNode;
Vector<String> p = path.split("/");
@@ -102,7 +104,7 @@ FSNode* createDirectory(const String& path, FSNode* start) {
}
bool remove(const String& path, FSNode* start) {
- FSNode* node =find(path, start);
+ FSNode* node = find(path, start);
if (node == NULL) return false;
FSNode* parent = node->getParent();
if (parent == NULL) return false;