vfs: refcount file structs used in fdescs

This commit is contained in:
Michael Shaw 2024-08-21 15:44:50 -04:00
commit 02c0a70a30
5 changed files with 22 additions and 4 deletions

View file

@ -126,6 +126,10 @@ int sys_open(const char *pathname, int flags)
fdesc->pos = 0;
fdesc->flags = flags;
spinlock_acquire(&file->ref_lock);
file->refcount++;
spinlock_release(&file->ref_lock);
struct rbnode *node = rbt_insert(&proc->fd_map, fdno);
node->value = (uintptr_t)fdesc;