summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-09-14 18:00:33 +0200
committerAlexis211 <alexis211@gmail.com>2009-09-14 18:00:33 +0200
commit6332f2561890edd654eafaeb58db16a131573319 (patch)
tree6477fc4898ee4b6045450c6304ad2a3769a4339b
parente0d27cc75009e27502d57258cb64c71221b4b7d1 (diff)
downloadMelon-6332f2561890edd654eafaeb58db16a131573319.tar.gz
Melon-6332f2561890edd654eafaeb58db16a131573319.zip
Added a few commands to kernel shell (rm && mkdir).
Also fixed a bug in VFS::remove.
-rw-r--r--Init.rfsbin564 -> 1439 bytes
-rw-r--r--Makefile2
-rw-r--r--Media/Screenshots/2009-09-14-173523_728x426_scrot.pngbin0 -> 17900 bytes
-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
10 files changed, 42 insertions, 16 deletions
diff --git a/Init.rfs b/Init.rfs
index 3c29618..87e0d5b 100644
--- a/Init.rfs
+++ b/Init.rfs
Binary files differ
diff --git a/Makefile b/Makefile
index 664900f..df31eac 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ Floppy = Melon.img
Projects = Kernel Tools/MakeRamFS
RamFS = Init.rfs
-RamFSFiles = :/System :/System/Applications Source/Kernel/Ressources/Welcome.txt:/Welcome.txt :/System/Configuration
+RamFSFiles = :/System :/System/Applications Source/Kernel/Ressources/Welcome.txt:/Welcome.txt :/System/Configuration :/Useless Source/Kernel/Ressources/Info.txt:/Useless/Info.txt Source/Kernel/Ressources/logo.cd:/Useless/Melon-logo
all:
for p in $(Projects); do \
diff --git a/Media/Screenshots/2009-09-14-173523_728x426_scrot.png b/Media/Screenshots/2009-09-14-173523_728x426_scrot.png
new file mode 100644
index 0000000..58bb7f8
--- /dev/null
+++ b/Media/Screenshots/2009-09-14-173523_728x426_scrot.png
Binary files differ
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;