summaryrefslogtreecommitdiff
path: root/sys/fs/devfs.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-05-14 00:07:14 -0400
committerIan Moffett <ian@osmora.org>2024-05-14 00:07:14 -0400
commit002bdd193d3454147fe4b7e8dfd4eecfa08d05bc (patch)
tree443ce5bfd22c33281b40d9ab7acc7aec1163b1e0 /sys/fs/devfs.c
parentb3c0e1e2f9bef74b395c9d9f670c93a8d8f5c725 (diff)
kernel: devfs: Add cdev_read()
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/fs/devfs.c')
-rw-r--r--sys/fs/devfs.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/sys/fs/devfs.c b/sys/fs/devfs.c
index 6e8efc9..79606eb 100644
--- a/sys/fs/devfs.c
+++ b/sys/fs/devfs.c
@@ -64,6 +64,17 @@ node_from_name(const char *name)
}
static int
+cdev_read(struct device *dev, struct device_node *node, struct sio_txn *sio)
+{
+ size_t n_bytes;
+
+ spinlock_acquire(&node->lock);
+ n_bytes = dev->read(dev, sio);
+ spinlock_release(&node->lock);
+ return n_bytes;
+}
+
+static int
blkdev_read(struct device *dev, struct device_node *node, struct sio_txn *sio)
{
char *buf;
@@ -139,7 +150,11 @@ vop_read(struct vnode *vp, struct sio_txn *sio)
node = vp->data;
dev = device_fetch(node->major, node->minor);
- return blkdev_read(dev, node, sio);
+
+ if (dev->blocksize > 1)
+ return blkdev_read(dev, node, sio);
+
+ return cdev_read(dev, node, sio);
}
static int