From e1b26186029d2ebbe5b0a6bd09c5b5eb3937020f Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 25 Jun 2024 23:08:27 -0400 Subject: kernel: initramfs: Implement getattr vop Signed-off-by: Ian Moffett --- sys/fs/initramfs.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'sys/fs') diff --git a/sys/fs/initramfs.c b/sys/fs/initramfs.c index 57b6456..810d691 100644 --- a/sys/fs/initramfs.c +++ b/sys/fs/initramfs.c @@ -192,6 +192,25 @@ initramfs_lookup(struct vop_lookup_args *args) return 0; } +static int +initramfs_getattr(struct vop_getattr_args *args) +{ + struct vnode *vp; + struct initramfs_node *n; + struct vattr attr; + + if ((vp = args->vp) == NULL) + return -EIO; + if ((n = vp->data) == NULL) + return -EIO; + + memset(&attr, VNOVAL, sizeof(attr)); + attr.mode = n->mode; + attr.size = n->size; + *args->res = attr; + return 0; +} + static int initramfs_read(struct vnode *vp, struct sio_txn *sio) { @@ -256,7 +275,8 @@ initramfs_init(struct fs_info *fip) const struct vops g_initramfs_vops = { .lookup = initramfs_lookup, .read = initramfs_read, - .reclaim = initramfs_reclaim + .reclaim = initramfs_reclaim, + .getattr = initramfs_getattr }; const struct vfsops g_initramfs_vfsops = { -- cgit v1.2.3