From a6ccf59fc56f90c97a82fe851f758decaeea9aef Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 17 Oct 2025 19:56:04 -0400 Subject: kern: tmpfs: Implement getattr vop for tmpfs Signed-off-by: Ian Moffett --- src/sys/fs/tmpfs.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/sys/fs') diff --git a/src/sys/fs/tmpfs.c b/src/sys/fs/tmpfs.c index 63e6577..af1537f 100644 --- a/src/sys/fs/tmpfs.c +++ b/src/sys/fs/tmpfs.c @@ -325,6 +325,23 @@ tmpfs_read(struct vop_rw_data *data) return len; } +static int +tmpfs_getattr(struct vnode *vp, struct vattr *res) +{ + struct tmpfs_node *np; + + if (vp == NULL || res == NULL) { + return -EINVAL; + } + + if ((np = vp->data) == NULL) { + return -EIO; + } + + res->size = np->real_len; + return 0; +} + static int tmpfs_reclaim(struct vnode *vp, int flags) { @@ -336,7 +353,8 @@ static struct vop tmpfs_vops = { .create = tmpfs_create, .reclaim = tmpfs_reclaim, .write = tmpfs_write, - .read = tmpfs_read + .read = tmpfs_read, + .getattr = tmpfs_getattr }; struct vfsops g_tmpfs_vfsops = { -- cgit v1.2.3