diff options
author | Ian Moffett <ian@osmora.org> | 2025-05-26 01:51:22 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-05-26 01:51:22 -0400 |
commit | 6b52b61f5bde1bcc1e08d760b6650009e9f1cab4 (patch) | |
tree | 8b807f62328afc186e79383f585595f4833727c5 /sys/fs | |
parent | 08d925bce8a18361655a56bf5b38d6f9e9134b8a (diff) |
kernel: devfs: Add callback to request block size
Add bsize() callback within the bdevsw structure. This returns the
number of blocks a block device supports at maximum. This result is *not*
in bytes.
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/devfs.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/fs/devfs.c b/sys/fs/devfs.c index 15a2864..1dfc10d 100644 --- a/sys/fs/devfs.c +++ b/sys/fs/devfs.c @@ -137,6 +137,8 @@ devfs_getattr(struct vop_getattr_args *args) struct vnode *vp; struct vattr *attr; struct devfs_node *dnp; + struct bdevsw *bdev; + size_t size = 0; vp = args->vp; if ((dnp = vp->data) == NULL) { @@ -146,6 +148,13 @@ devfs_getattr(struct vop_getattr_args *args) return -EIO; } + if (dnp->is_block) { + bdev = dev_get(dnp->major, dnp->dev); + if (bdev->bsize != NULL) { + size = bdev->bsize(dnp->dev); + } + } + /* * Set stat attributes from device node structure * found within vnode data. @@ -154,7 +163,7 @@ devfs_getattr(struct vop_getattr_args *args) * size is hardwired to 0. */ attr->mode = dnp->mode; - attr->size = 0; + attr->size = size; return 0; } |