BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / f0dcd5469d9d1ca1dd816f97411f1209eb5a287a / task

// Related

Nucleus

Barry Files namespace f0dcd54 (3 years, 3 months ago)
diff --git a/task/clone.c b/task/clone.c
index 86cf440..4dd15e7 100644
--- a/task/clone.c
+++ b/task/clone.c
@@ -25,6 +25,12 @@ clone(int flags)
 	else
 		child->fs = copy(parent->fs);
 
+	/* Clone parent's files namespace */
+	if (flags & CLONE_FILES)
+		child->files = get(parent->files);
+	else
+		child->files = copy(parent->files);
+
 	/* After this, anything on the stack is desynchronised */
 	child->pageDir = clone_dir();
 
diff --git a/task/task.c b/task/task.c
index 87c0c79..0e53b77 100644
--- a/task/task.c
+++ b/task/task.c
@@ -10,6 +10,7 @@
 #include <nucleus/task.h>
 #include <nucleus/memory.h>
 #include <nucleus/object.h>
+#include <nucleus/vfs.h>
 
 void init_scheduler(void);
 void timer_handler(struct InterruptFrame *frame);
@@ -18,12 +19,14 @@ static void task_new(Object *);
 
 /* Task object type */
 ObjectType taskType = {
+	.name = "TASK",
 	.size = sizeof(Task),
 	.new = task_new,
 };
 
 Task *currentTask[MAX_CPUS];
 pid_t nextTid = 1;
+extern char stackTop[];
 
 /* Create a new Task */
 static void
@@ -31,12 +34,11 @@ task_new(Object *obj)
 {
 	Task *task = (void *) obj;
 	task->tid = nextTid++;
+	task->tgid = task->tid;
 	task->priority = NORMAL;
 	task->state = READY;
 }
 
-extern char stackTop[];
-
 /* Move the stack */
 static void
 move_stack(uintptr_t top, size_t size)
@@ -80,6 +82,9 @@ init_tasking(void)
 	/* File System namespace */
 	current->fs = new(&fsType);
 
+	/* Files namespace */
+	current->files = new(&filesType);
+
 	init_scheduler();
 	register_interrupt(0, timer_handler);