From 9a4ec7539041f9ff25b947b2716aded028c0291f Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 21 May 2024 22:15:27 -0400 Subject: kernel: vfs: Add support for close VOP Signed-off-by: Ian Moffett --- sys/kern/kern_filedesc.c | 4 ++++ sys/kern/vfs_subr.c | 9 +++++++++ 2 files changed, 13 insertions(+) (limited to 'sys/kern') diff --git a/sys/kern/kern_filedesc.c b/sys/kern/kern_filedesc.c index 74ab859..ec0aee7 100644 --- a/sys/kern/kern_filedesc.c +++ b/sys/kern/kern_filedesc.c @@ -211,6 +211,10 @@ fd_close_fdnum(struct proc *td, int fdno) return; } + if (fd->vnode != NULL) { + vfs_close(fd->vnode); + } + dynfree(fd); td->fds[fdno] = NULL; } diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index f760831..60afa31 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -247,3 +247,12 @@ int vfs_open(struct vnode *vp) return vp->vops->open(vp); } + +int +vfs_close(struct vnode *vp) +{ + if (vp->vops->close == NULL) + return -EIO; + + return vp->vops->close(vp); +} -- cgit v1.2.3