diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sys/include/os/vnode.h | 12 | ||||
-rw-r--r-- | src/sys/os/vfs_subr.c | 21 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/sys/include/os/vnode.h b/src/sys/include/os/vnode.h index 9054a55..1bef1e2 100644 --- a/src/sys/include/os/vnode.h +++ b/src/sys/include/os/vnode.h @@ -88,6 +88,7 @@ struct vop_rw_data { */ struct vop { int(*lookup)(struct vop_lookup_args *args); + int(*reclaim)(struct vnode *vp, int flags); ssize_t(*write)(struct vop_rw_data *data); ssize_t(*read)(struct vop_rw_data *data); }; @@ -164,4 +165,15 @@ ssize_t vop_write(struct vnode *vp, char *data, off_t off, size_t len); */ ssize_t vop_read(struct vnode *vp, char *data, off_t off, size_t len); +/* + * Reclaim the resources tied to a specific vnode + * + * @vp: Vnode to reclaim + * @flags: Optional flags + * + * Returns zero on success, otherwise a less than zero value + * on failure. + */ +int vop_reclaim(struct vnode *vp, int flags); + #endif /* !_OS_VNODE_H_ */ diff --git a/src/sys/os/vfs_subr.c b/src/sys/os/vfs_subr.c index a06b64f..6cb7767 100644 --- a/src/sys/os/vfs_subr.c +++ b/src/sys/os/vfs_subr.c @@ -203,3 +203,24 @@ vop_read(struct vnode *vp, char *data, off_t off, size_t len) rwdata.off = off; return vops->read(&rwdata); } + +int +vop_reclaim(struct vnode *vp, int flags) +{ + struct vop *vops; + + if (vp == NULL) { + return -EINVAL; + } + + /* Grab the virtual operations */ + if ((vops = vp->vops) == NULL) { + return -EIO; + } + + if (vops->reclaim == NULL) { + return -ENOTSUP; + } + + return vops->reclaim(vp, flags); +} |