From 9836acd720988af30250c2c1ec18d618664dea4e Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Tue, 20 Oct 2009 19:21:34 +0200 Subject: Started working on a userland shell This means I'll have to do syscalls for everything I need. --- Source/Kernel/Makefile | 1 + Source/Kernel/SyscallManager/Res.ns.cpp | 2 ++ Source/Kernel/VFS/FSNode-sc.proto.cpp | 34 +++++++++++++++++++++++++++++++++ Source/Kernel/VFS/FSNode.proto.h | 16 ++++++++++++++-- 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 Source/Kernel/VFS/FSNode-sc.proto.cpp (limited to 'Source/Kernel') 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 #include #include +#include #include 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 + +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 class FSNode; #include +#include + +#include 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() {} -- cgit v1.2.3