summaryrefslogtreecommitdiff
path: root/Source/Kernel/VFS
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-10-23 19:40:08 +0200
committerAlexis211 <alexis211@gmail.com>2009-10-23 19:40:08 +0200
commit48de0cd029b52f64f76345b6e1fdf3cde5c58de3 (patch)
tree792061381c556bef6639b327716cca107f6168c5 /Source/Kernel/VFS
parentf0556ed7f051fb101dc68752526696365bf79a11 (diff)
downloadMelon-48de0cd029b52f64f76345b6e1fdf3cde5c58de3.tar.gz
Melon-48de0cd029b52f64f76345b6e1fdf3cde5c58de3.zip
More work on syscalls and shell
Diffstat (limited to 'Source/Kernel/VFS')
-rw-r--r--Source/Kernel/VFS/DirectoryNode.class.cpp19
-rw-r--r--Source/Kernel/VFS/DirectoryNode.class.h9
-rw-r--r--Source/Kernel/VFS/FSNode-sc.proto.cpp19
-rw-r--r--Source/Kernel/VFS/FSNode.proto.h1
4 files changed, 47 insertions, 1 deletions
diff --git a/Source/Kernel/VFS/DirectoryNode.class.cpp b/Source/Kernel/VFS/DirectoryNode.class.cpp
index 0c58ca1..381ff49 100644
--- a/Source/Kernel/VFS/DirectoryNode.class.cpp
+++ b/Source/Kernel/VFS/DirectoryNode.class.cpp
@@ -1,5 +1,24 @@
#include "DirectoryNode.class.h"
+call_t DirectoryNode::m_callTable[] = {
+ CALL1(FNIF_GETIDXCHILD, &DirectoryNode::getIdxChildSC),
+ CALL1(FNIF_GETNAMECHILD, &DirectoryNode::getNameChildSC),
+ CALL0(0, 0)
+};
+
+u32int DirectoryNode::getIdxChildSC(u32int idx) {
+ FSNode* n = getChild(idx);
+ if (n != NULL) return n->resId();
+ return (u32int) - 1;
+}
+
+u32int DirectoryNode::getNameChildSC(u32int name) {
+ String* w = (String*)name;
+ FSNode* n = getChild(*w);
+ if (n != NULL) return n->resId();
+ return (u32int) - 1;
+}
+
bool DirectoryNode::removable() {
if (!m_contentLoaded)
if (!loadContent())
diff --git a/Source/Kernel/VFS/DirectoryNode.class.h b/Source/Kernel/VFS/DirectoryNode.class.h
index 346c4ab..4d9b211 100644
--- a/Source/Kernel/VFS/DirectoryNode.class.h
+++ b/Source/Kernel/VFS/DirectoryNode.class.h
@@ -9,10 +9,17 @@ class DirectoryNode : public FSNode {
Vector<FSNode*> m_children;
bool m_contentLoaded;
+ //Syscalls
+ static call_t m_callTable[];
+ u32int getIdxChildSC(u32int index);
+ u32int getNameChildSC(u32int name);
+
public:
DirectoryNode(String name, FileSystem* fs, FSNode* parent, u32int permissions = 0777,
u32int uid = 0, u32int gid = 0) :
- FSNode(name, fs, parent, 0, permissions, uid, gid), m_children(), m_contentLoaded(false) {}
+ FSNode(name, fs, parent, 0, permissions, uid, gid), m_children(), m_contentLoaded(false) {
+ addCallTable(m_callTable);
+ }
virtual ~DirectoryNode() {
if (m_contentLoaded) {
for (u32int i = 0; i < m_children.size(); i++) {
diff --git a/Source/Kernel/VFS/FSNode-sc.proto.cpp b/Source/Kernel/VFS/FSNode-sc.proto.cpp
index fdea85f..1e0c4c1 100644
--- a/Source/Kernel/VFS/FSNode-sc.proto.cpp
+++ b/Source/Kernel/VFS/FSNode-sc.proto.cpp
@@ -1,6 +1,8 @@
#include "FSNode.proto.h"
#include <VFS/VFS.ns.h>
+#include <SyscallManager/Res.ns.h>
#include <UserManager/Usr.ns.h>
+#include <TaskManager/Task.ns.h>
call_t FSNode::m_callTable[] = {
CALL0(FNIF_GETNAME, &FSNode::getNameSC),
@@ -11,11 +13,21 @@ call_t FSNode::m_callTable[] = {
CALL0(FNIF_GETGID, &FSNode::getGid),
CALL0(FNIF_GETPERM, &FSNode::getPermissions),
CALL0(FNIF_GETPATH, &FSNode::getPathSC),
+ CALL0(FNIF_SETCWD, &FSNode::setCwdSC),
CALL0(0, 0)
};
u32int FSNode::scall(u8int wat, u32int a, u32int b, u32int c, u32int d) {
if (wat == FNIF_SGETRFN) return VFS::getRootNode()->resId();
+ if (wat == FNIF_SGETCWD) return Task::currProcess()->getCwd()->resId();
+ if (wat == FNIF_SFIND) {
+ String* path = (String*)a;
+ if (b == 0) {
+ return VFS::find(*path)->resId();
+ } else {
+ return VFS::find(*path, Res::get<DirectoryNode>(b, FNIF_OBJTYPE))->resId();
+ }
+ }
return (u32int) - 1;
}
@@ -42,6 +54,13 @@ u32int FSNode::getPathSC() {
return VFS::path(this).serialize();
}
+u32int FSNode::setCwdSC() {
+ if (type() == NT_DIRECTORY) {
+ Task::currProcess()->setCwd((DirectoryNode*)this);
+ }
+ return 0;
+}
+
bool FSNode::readable(User* user) {
if (user == 0) user = Usr::user();
if (user->getUid() == m_uid)
diff --git a/Source/Kernel/VFS/FSNode.proto.h b/Source/Kernel/VFS/FSNode.proto.h
index 8b6974a..6536e21 100644
--- a/Source/Kernel/VFS/FSNode.proto.h
+++ b/Source/Kernel/VFS/FSNode.proto.h
@@ -26,6 +26,7 @@ class FSNode : public Ressource {
u32int typeSC();
u32int getParentSC();
u32int getPathSC();
+ u32int setCwdSC();
bool accessible();
public: