From 5dd48c50c0cf7793a5dafa6be769c8a3f8b9ab60 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Fri, 23 Oct 2009 21:06:23 +0200 Subject: Added some screenshots (\o/) and implemented mkdir in userland. --- Source/Kernel/Ressources/Texts/Info.txt | 5 ----- Source/Kernel/VFS/FSNode-sc.proto.cpp | 13 +++++++++++++ Source/Kernel/VFS/VFS.ns.cpp | 31 +++++++++++++++++++++++++++++++ Source/Kernel/VFS/VFS.ns.h | 1 + 4 files changed, 45 insertions(+), 5 deletions(-) delete mode 100644 Source/Kernel/Ressources/Texts/Info.txt (limited to 'Source/Kernel') diff --git a/Source/Kernel/Ressources/Texts/Info.txt b/Source/Kernel/Ressources/Texts/Info.txt deleted file mode 100644 index 56016a2..0000000 --- a/Source/Kernel/Ressources/Texts/Info.txt +++ /dev/null @@ -1,5 +0,0 @@ -These files were just added here for fun. - -Oh, you wanted to know what the wf command meant ? -Simple : it means Write File. Type 'wf filename' and then enter the -file's contents, ending with . diff --git a/Source/Kernel/VFS/FSNode-sc.proto.cpp b/Source/Kernel/VFS/FSNode-sc.proto.cpp index e3f11db..279303b 100644 --- a/Source/Kernel/VFS/FSNode-sc.proto.cpp +++ b/Source/Kernel/VFS/FSNode-sc.proto.cpp @@ -31,6 +31,16 @@ u32int FSNode::scall(u8int wat, u32int a, u32int b, u32int c, u32int d) { } if (n != 0) return n->resId(); } + if (wat == FNIF_SMKDIR) { + String* path = (String*)a; + FSNode* n; + if (b == 0) { + n = VFS::mkdir(*path); + } else { + n = VFS::mkdir(*path, Res::get(b, FNIF_OBJTYPE)); + } + if (n != 0) return n->resId(); + } return (u32int) - 1; } @@ -70,6 +80,7 @@ u32int FSNode::removeSC() { } bool FSNode::readable(User* user) { + if (ISROOT) return true; if (user == 0) user = Usr::user(); if (user->getUid() == m_uid) return ((m_permissions >> 6) & 4) != 0; @@ -79,6 +90,7 @@ bool FSNode::readable(User* user) { } bool FSNode::writable(User* user) { + if (ISROOT) return true; if (user == 0) user = Usr::user(); if (user->getUid() == m_uid) return ((m_permissions >> 6) & 2) != 0; @@ -88,6 +100,7 @@ bool FSNode::writable(User* user) { } bool FSNode::runnable(User* user) { + if (ISROOT) return true; if (user == 0) user = Usr::user(); if (user->getUid() == m_uid) return ((m_permissions >> 6) & 1) != 0; diff --git a/Source/Kernel/VFS/VFS.ns.cpp b/Source/Kernel/VFS/VFS.ns.cpp index 2333a36..fdfc265 100644 --- a/Source/Kernel/VFS/VFS.ns.cpp +++ b/Source/Kernel/VFS/VFS.ns.cpp @@ -103,6 +103,37 @@ FSNode* createDirectory(const String& path, FSNode* start) { } } +//Same as createDirectory but checks for parent directory permissions for current process +FSNode* mkdir(const String& path, FSNode* start) { + if (find(path, start) != NULL) return NULL; //Something already has that name. + if (start == 0) start = rootNode; + + Vector p = path.split("/"); + String name = p.back(); + p.pop(); + + FSNode* node = start; + if (!path.empty()) { + if (p[0].empty()) node = rootNode; + for (u32int i = 0; i < p.size(); i++) { + if (p[i] == "..") { + node = node->getParent(); + } else if (!p[i].empty() and p[i] != ".") { + if (node->type() == NT_DIRECTORY) { + node = ((DirectoryNode*)node)->getChild(p[i]); + } else { + node = NULL; + } + } + if (node == NULL) return node; + } + } + + if (node->type() == NT_DIRECTORY) + if (node->writable()) return ((DirectoryNode*)node)->createDirectory(name); + return NULL; +} + bool remove(FSNode* node) { FSNode* parent = node->getParent(); if (parent == NULL) return false; diff --git a/Source/Kernel/VFS/VFS.ns.h b/Source/Kernel/VFS/VFS.ns.h index 72b8c44..63229bf 100644 --- a/Source/Kernel/VFS/VFS.ns.h +++ b/Source/Kernel/VFS/VFS.ns.h @@ -15,6 +15,7 @@ namespace VFS { FSNode* find(const String& path, FSNode* start = 0); FSNode* createFile(const String& path, FSNode* start = 0); FSNode* createDirectory(const String& path, FSNode* start = 0); + FSNode* mkdir(const String& path, FSNode* start = 0); //Same as createDirectory, except it checks for parent directory writablilty by current process bool remove(FSNode* node); bool remove(const String& path, FSNode* start = 0); //Returns false for non-empty directories String path(FSNode* node); //Returns complete path for a node -- cgit v1.2.3