block: add a sb_open_mode helper
Add a helper to return the open flags for blkdev_get_by* for passed in super block flags instead of open coding the logic in many places. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Acked-by: Christian Brauner <brauner@kernel.org> Link: https://lore.kernel.org/r/20230608110258.189493-17-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
2736e8eeb0
commit
3f0b3e785e
@@ -1473,6 +1473,13 @@ struct blk_holder_ops {
|
||||
void (*mark_dead)(struct block_device *bdev);
|
||||
};
|
||||
|
||||
/*
|
||||
* Return the correct open flags for blkdev_get_by_* for super block flags
|
||||
* as stored in sb->s_flags.
|
||||
*/
|
||||
#define sb_open_mode(flags) \
|
||||
(FMODE_READ | (((flags) & SB_RDONLY) ? 0 : FMODE_WRITE))
|
||||
|
||||
struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, void *holder,
|
||||
const struct blk_holder_ops *hops);
|
||||
struct block_device *blkdev_get_by_path(const char *path, fmode_t mode,
|
||||
|
||||
Reference in New Issue
Block a user