diff options
author | Ian Moffett <ian@osmora.org> | 2024-03-27 19:27:12 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-03-27 19:27:12 -0400 |
commit | 380da5fe2e8ef39cfca6e92ef53c1b3f44ab77c6 (patch) | |
tree | 70c770fd0dd82a173c5da8c0003c9c735dc3910e /sys/fs | |
parent | 7f27268c86bcb54a79854bb16d3c2631cb10ff80 (diff) |
kernel: vfs: Add getattr vop
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/initramfs.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/sys/fs/initramfs.c b/sys/fs/initramfs.c index 00d1020..b7f0c71 100644 --- a/sys/fs/initramfs.c +++ b/sys/fs/initramfs.c @@ -146,6 +146,28 @@ vop_read(struct vnode *vp, struct sio_txn *sio) return sio->len; } +static int +vop_getattr(struct vnode *vp, struct vattr *vattr) +{ + struct tar_hdr *hdr = vp->data; + + if (hdr == NULL) { + return -EIO; + } + + switch (hdr->type) { + case TAR_TYPEFLAG_NORMAL: + vattr->type = VREG; + break; + case TAR_TYPEFLAG_DIR: + vattr->type = VDIR; + break; + } + + vattr->size = getsize(hdr->size); + return 0; +} + static char * get_module(const char *path, uint64_t *size) { for (uint64_t i = 0; i < mod_req.response->module_count; ++i) { @@ -232,5 +254,6 @@ struct vfsops g_initramfs_ops = { struct vops g_initramfs_vops = { .vget = vop_vget, - .read = vop_read + .read = vop_read, + .getattr = vop_getattr }; |