summaryrefslogtreecommitdiff
path: root/Source/Kernel
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-10-20 19:21:34 +0200
committerAlexis211 <alexis211@gmail.com>2009-10-20 19:21:34 +0200
commit9836acd720988af30250c2c1ec18d618664dea4e (patch)
tree9e26d7d65e1693d1a7f9fd93c9fd33b41d175464 /Source/Kernel
parent90b49b6f171108f272ff529f7546bd9625ca7d17 (diff)
downloadMelon-9836acd720988af30250c2c1ec18d618664dea4e.tar.gz
Melon-9836acd720988af30250c2c1ec18d618664dea4e.zip
Started working on a userland shell
This means I'll have to do syscalls for everything I need.
Diffstat (limited to 'Source/Kernel')
-rw-r--r--Source/Kernel/Makefile1
-rw-r--r--Source/Kernel/SyscallManager/Res.ns.cpp2
-rw-r--r--Source/Kernel/VFS/FSNode-sc.proto.cpp34
-rw-r--r--Source/Kernel/VFS/FSNode.proto.h16
4 files changed, 51 insertions, 2 deletions
diff --git a/Source/Kernel/Makefile b/Source/Kernel/Makefile
index 1c83e5a..55c5fb0 100644
--- a/Source/Kernel/Makefile
+++ b/Source/Kernel/Makefile
@@ -55,6 +55,7 @@ Objects = Core/loader.wtf.o \
VFS/Partition.class.o \
VFS/Part.ns.o \
VFS/VFS.ns.o \
+ VFS/FSNode-sc.proto.o \
VFS/File.class.o \
VFS/TextFile.class.o \
VFS/DirectoryNode.class.o \
diff --git a/Source/Kernel/SyscallManager/Res.ns.cpp b/Source/Kernel/SyscallManager/Res.ns.cpp
index 98d3ac3..048d17a 100644
--- a/Source/Kernel/SyscallManager/Res.ns.cpp
+++ b/Source/Kernel/SyscallManager/Res.ns.cpp
@@ -3,6 +3,7 @@
#include <VirtualTerminal.iface.h>
#include <Process.iface.h>
#include <Thread.iface.h>
+#include <FSNode.iface.h>
#include <TaskManager/Task.ns.h>
namespace Res {
@@ -18,6 +19,7 @@ static_call_t staticCalls[] = {
{VTIF_OBJTYPE, VirtualTerminal::scall},
{PRIF_OBJTYPE, Process::scall},
{THIF_OBJTYPE, Thread::scall},
+ {FNIF_OBJTYPE, FSNode::scall},
{0, 0}
};
diff --git a/Source/Kernel/VFS/FSNode-sc.proto.cpp b/Source/Kernel/VFS/FSNode-sc.proto.cpp
new file mode 100644
index 0000000..9e485e1
--- /dev/null
+++ b/Source/Kernel/VFS/FSNode-sc.proto.cpp
@@ -0,0 +1,34 @@
+#include "FSNode.proto.h"
+#include <VFS/VFS.ns.h>
+
+call_t FSNode::m_callTable[] = {
+ CALL0(FNIF_GETNAME, &FSNode::getNameSC),
+ CALL0(FNIF_TYPE, &FSNode::typeSC),
+ CALL0(FNIF_GETPARENT, &FSNode::getParentSC),
+ CALL0(FNIF_GETLENGTH, &FSNode::getLengthSC),
+ CALL0(0, 0)
+};
+
+u32int FSNode::scall(u8int wat, u32int a, u32int b, u32int c, u32int d) {
+ if (wat == FNIF_SGETRFN) return VFS::getRootNode()->resId();
+ return (u32int) - 1;
+}
+
+u32int FSNode::getNameSC() {
+ return getName().serialize();
+}
+
+u32int FSNode::typeSC() {
+ return type();
+}
+
+u32int FSNode::getLengthSC() {
+ u64int* a = (u64int*)Mem::mkXchgSpace(sizeof(u64int));
+ *a = getLength();
+ return (u32int)a;
+}
+
+u32int FSNode::getParentSC() {
+ if (m_parent != 0) return m_parent->resId();
+ return (u32int) - 1;
+}
diff --git a/Source/Kernel/VFS/FSNode.proto.h b/Source/Kernel/VFS/FSNode.proto.h
index c3cd1c1..b648141 100644
--- a/Source/Kernel/VFS/FSNode.proto.h
+++ b/Source/Kernel/VFS/FSNode.proto.h
@@ -5,6 +5,9 @@
#include <String.class.h>
class FSNode;
#include <VFS/FileSystem.proto.h>
+#include <SyscallManager/Ressource.class.h>
+
+#include <FSNode.iface.h>
enum {
NT_FILE = 1,
@@ -13,18 +16,27 @@ enum {
NT_MOUNTPOINT = 4
};
-class FSNode {
+class FSNode : public Ressource {
protected:
String m_name;
u64int m_length;
u32int m_permissions, m_uid, m_gid;
FileSystem *m_fs;
FSNode *m_parent;
+
+ //Syscall related
+ static call_t m_callTable[];
+ u32int getNameSC();
+ u32int getLengthSC();
+ u32int typeSC();
+ u32int getParentSC();
public:
+ static u32int scall(u8int, u32int, u32int, u32int, u32int);
+
FSNode(String name, FileSystem* fs, FSNode* parent, u64int length = 0, u32int permissions = 0777,
u32int uid = 0, u32int gid = 0) :
- m_name(name), m_length(length), m_permissions(permissions),
+ Ressource(FNIF_OBJTYPE, m_callTable), m_name(name), m_length(length), m_permissions(permissions),
m_uid(uid), m_gid(gid), m_fs(fs), m_parent(parent) {}
virtual ~FSNode() {}