diff options
author | Ian Moffett <ian@osmora.org> | 2024-07-13 17:37:05 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-07-13 17:37:05 -0400 |
commit | 06f3138dc919df83cbacb880fb68d63698977e44 (patch) | |
tree | 37f4b1a37efef70b95a7986d21855545ef5c73a2 | |
parent | 73a87562abbe8b1c0d49567d8f314193c2410768 (diff) |
kernel: dev: Support bdevsw
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | sys/fs/devfs.c | 12 | ||||
-rw-r--r-- | sys/include/sys/device.h | 4 |
2 files changed, 14 insertions, 2 deletions
diff --git a/sys/fs/devfs.c b/sys/fs/devfs.c index e320973..81c2a43 100644 --- a/sys/fs/devfs.c +++ b/sys/fs/devfs.c @@ -55,6 +55,14 @@ cdevsw_read(void *devsw, dev_t dev, struct sio_txn *sio) return cdevsw->read(dev, sio, 0); } +static inline int +bdevsw_read(void *devsw, dev_t dev, struct sio_txn *sio) +{ + struct bdevsw *bdevsw = devsw; + + return bdevsw->read(dev, sio, 0); +} + /* * Get a devfs node by name. * @@ -134,8 +142,8 @@ devfs_read(struct vnode *vp, struct sio_txn *sio) if (!dnp->is_block) return cdevsw_read(devsw, dnp->dev, sio); - /* TODO: Block devices */ - return -EIO; + /* Block device */ + return bdevsw_read(devsw, dnp->dev, sio); } static int diff --git a/sys/include/sys/device.h b/sys/include/sys/device.h index 3ba7141..edf83ae 100644 --- a/sys/include/sys/device.h +++ b/sys/include/sys/device.h @@ -44,6 +44,10 @@ struct cdevsw { int(*read)(dev_t dev, struct sio_txn *sio, int flags); }; +struct bdevsw { + int(*read)(dev_t dev, struct sio_txn *sio, int flags); +}; + void *dev_get(devmajor_t major, dev_t dev); dev_t dev_alloc(devmajor_t major); |