diff options
author | sotech117 <michael_foiani@brown.edu> | 2024-04-25 02:58:09 +0000 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2024-04-25 02:58:09 +0000 |
commit | a3e64ef2bf31dda9a94db011a96651de918ea968 (patch) | |
tree | 67c1d65ccc219c223d261dfd4cb024201220dcff /kernel/proc/proc.c | |
parent | d970aa2698d831645986effded059eb344a77486 (diff) |
old vfs fixes
Diffstat (limited to 'kernel/proc/proc.c')
-rw-r--r-- | kernel/proc/proc.c | 33 |
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) { |