diff options
author | Ian Moffett <ian@osmora.org> | 2024-05-19 23:05:21 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-05-19 23:05:21 -0400 |
commit | 673753e8befcfbb575380ed0d23fc6741b4e50a0 (patch) | |
tree | 087ef9499c52523601b8d95d74eec709885a0899 /sys/fs/devfs.c | |
parent | f9a6fc6f474ced84a78df50e2b105bd7da052d06 (diff) |
kernel: vfs: Add support for open hook
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/fs/devfs.c')
-rw-r--r-- | sys/fs/devfs.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/sys/fs/devfs.c b/sys/fs/devfs.c index 79606eb..d7944aa 100644 --- a/sys/fs/devfs.c +++ b/sys/fs/devfs.c @@ -158,6 +158,26 @@ vop_read(struct vnode *vp, struct sio_txn *sio) } static int +vop_open(struct vnode *vp) +{ + struct device_node *node; + struct device *dev; + + if (vp == NULL) { + return -EIO; + } + + node = vp->data; + dev = device_fetch(node->major, node->minor); + + if (dev->open == NULL) { + return -EIO; + } + + return dev->open(dev); +} + +static int devfs_init(struct fs_info *info, struct vnode *source) { if (source != NULL) @@ -249,5 +269,6 @@ struct vfsops g_devfs_ops = { struct vops g_devfs_vops = { .vget = vop_vget, - .read = vop_read + .read = vop_read, + .open = vop_open }; |