AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
close.c
Go to the documentation of this file.
1
4
5#include <core/system.h>
6#include <core/panic.h>
7#include <fs/vfs.h>
8
18int vfs_close(struct vnode *vnode)
19{
20 vfs_log(LOG_DEBUG, "vfs_close(vnode=%p)\n", vnode);
21
22 /* invalid request */
23 if (!vnode || !vnode->fs)
24 return -EINVAL;
25
26 if (!vnode->ref)
27 panic("closing an already closed vnode");
28
29 vnode->ref--;
30
31 /* filesystems without a close operation keep their vnodes around */
32 if (!vnode->ref && vnode->fs->vops.close)
33 return vnode->fs->vops.close(vnode);
34
35 return 0;
36}
#define panic(s)
Definition panic.h:15
int vfs_close(struct vnode *vnode)
Drops a reference to a vnode.
Definition close.c:18
#define LOG_DEBUG
Definition printk.h:19
struct vops vops
Definition vfs.h:104
A file in memory (a vnode): what its inode says, and the kernel's own state.
Definition vfs.h:113
size_t ref
how many references there are to it
Definition vfs.h:133
struct fs * fs
Definition vfs.h:127
int(*) close(struct vnode *vnode)
Definition vfs.h:75