aboutsummaryrefslogtreecommitdiff
path: root/kernel/proc
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/proc')
-rw-r--r--kernel/proc/proc.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/kernel/proc/proc.c b/kernel/proc/proc.c
index 7ce42dc..1e38ca8 100644
--- a/kernel/proc/proc.c
+++ b/kernel/proc/proc.c
@@ -218,6 +218,23 @@ proc_t *proc_create(const char *name)
list_insert_tail(&proc_list, &proc->p_list_link);
dbg(DBG_PROC, "SUCESSFULLY created PROCESS name=%s & pid =%d\n", name, proc_pid);
+#ifdef __VFS__
+ // clone and ref the files from curproc
+ for (int fd = 0; fd < NFILES; fd++)
+ {
+ proc->p_files[fd] = NULL;
+ }
+ if (proc->p_pid != PID_INIT)
+ {
+ proc->p_cwd = proc->p_pproc->p_cwd;
+ vref(proc->p_cwd);
+ }
+ else
+ {
+ proc->p_cwd = NULL;
+ }
+#endif
+
return proc;
}
@@ -272,6 +289,20 @@ void proc_cleanup(long status)
// } else {
curproc->p_status = status;
// }
+
+#ifdef __VFS__
+ for (int fd = 0; fd < NFILES; fd++)
+ {
+ if (curproc->p_files[fd])
+ {
+ fput(curproc->p_files + fd);
+ }
+ }
+ if (curproc->p_cwd)
+ {
+ vput(&curproc->p_cwd);
+ }
+#endif
}
/*
@@ -365,7 +396,9 @@ void proc_destroy(proc_t *proc)
for (int fd = 0; fd < NFILES; fd++)
{
if (proc->p_files[fd])
+ {
fput(proc->p_files + fd);
+ }
}
if (proc->p_cwd)
{