summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-10-27 00:53:05 -0400
committerIan Moffett <ian@osmora.org>2024-10-27 00:53:05 -0400
commit18e76c1d4cb4ef3f9be1db53b2b794d8f4c16de5 (patch)
treed6fd5fbd1df014981accae44fc403e1d695b1fa5 /sys
parentcaad8d9443d1e751ba743de660cc1d592faae5d9 (diff)
kernel: devfs: Add getattr vop for device files
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/fs/devfs.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/sys/fs/devfs.c b/sys/fs/devfs.c
index 81c2a43..75cf991 100644
--- a/sys/fs/devfs.c
+++ b/sys/fs/devfs.c
@@ -115,6 +115,33 @@ devfs_lookup(struct vop_lookup_args *args)
}
static int
+devfs_getattr(struct vop_getattr_args *args)
+{
+ struct vnode *vp;
+ struct vattr *attr;
+ struct devfs_node *dnp;
+
+ vp = args->vp;
+ if ((dnp = vp->data) == NULL) {
+ return -EIO;
+ }
+ if ((attr = args->res) == NULL) {
+ return -EIO;
+ }
+
+ /*
+ * Set stat attributes from device node structure
+ * found within vnode data.
+ *
+ * XXX: Device files have no fixed size, hence why
+ * size is hardwired to 0.
+ */
+ attr->mode = dnp->mode;
+ attr->size = 0;
+ return 0;
+}
+
+static int
devfs_reclaim(struct vnode *vp)
{
struct devfs_node *dnp;
@@ -204,7 +231,8 @@ devfs_create_entry(const char *name, devmajor_t major, dev_t dev, mode_t mode)
const struct vops g_devfs_vops = {
.lookup = devfs_lookup,
.reclaim = devfs_reclaim,
- .read = devfs_read
+ .read = devfs_read,
+ .getattr = devfs_getattr
};
const struct vfsops g_devfs_vfsops = {