summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2022-06-02 21:59:16 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-06-10 09:50:46 +0200
commit84173bf3d0ccc4036a16c4b074642aea59648063 (patch)
tree3ca5e91b8891798f038a8f408224f8ff301822b0 /common
parent7cceef54a045ca8b9b33145b708d843b371718ba (diff)
downloadbarebox-84173bf3d0ccc4036a16c4b074642aea59648063.tar.gz
barebox-84173bf3d0ccc4036a16c4b074642aea59648063.tar.xz
block: set S_IFBLK for block devices instead of S_IFCHR
In barebox, block devices are a special case of character devices. Nevertheless, differentiation can be useful to allow scripts iterating over all block devices without accounting for naming, e.g. for dev in /dev/*; do test -b $dev && echo $dev: blockdevice done Add the necessary support. This will break scripts that assume test -c blockdevice to be true, but that's a quite improbable check. Tested-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20220602195916.9061-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/block.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/common/block.c b/common/block.c
index 1d386edcfd..19bb81df2c 100644
--- a/common/block.c
+++ b/common/block.c
@@ -361,6 +361,14 @@ static struct cdev_operations block_ops = {
.discard_range = block_op_discard_range,
};
+struct block_device *cdev_get_block_device(struct cdev *cdev)
+{
+ if (!cdev || cdev->ops != &block_ops)
+ return NULL;
+
+ return container_of(cdev, struct block_device, cdev);
+}
+
int blockdevice_register(struct block_device *blk)
{
loff_t size = (loff_t)blk->num_blocks * BLOCKSIZE(blk);