summaryrefslogtreecommitdiff
path: root/Source/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Kernel')
-rw-r--r--Source/Kernel/Ressources/Texts/Info.txt5
-rw-r--r--Source/Kernel/VFS/FSNode-sc.proto.cpp13
-rw-r--r--Source/Kernel/VFS/VFS.ns.cpp31
-rw-r--r--Source/Kernel/VFS/VFS.ns.h1
4 files changed, 45 insertions, 5 deletions
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 <CR>.<CR>
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<DirectoryNode>(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<String> 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