diff options
Diffstat (limited to 'include/block.h')
-rw-r--r-- | include/block.h | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/include/block.h b/include/block.h index 1fb40e942f..a0f226c764 100644 --- a/include/block.h +++ b/include/block.h @@ -7,6 +7,7 @@ #include <linux/types.h> struct block_device; +struct file_list; struct block_device_ops { int (*read)(struct block_device *, void *buf, sector_t block, blkcnt_t num_blocks); @@ -16,11 +17,25 @@ struct block_device_ops { struct chunk; +enum blk_type { + BLK_TYPE_UNSPEC = 0, + BLK_TYPE_USB, + BLK_TYPE_SD, + BLK_TYPE_AHCI, + BLK_TYPE_IDE, + BLK_TYPE_NVME, + BLK_TYPE_VIRTUAL, + BLK_TYPE_MMC, +}; + +const char *blk_type_str(enum blk_type); + struct block_device { - struct device_d *dev; + struct device *dev; struct list_head list; struct block_device_ops *ops; - int blockbits; + u8 blockbits; + u8 type; /* holds enum blk_type */ blkcnt_t num_blocks; int rdbufsize; int blkmask; @@ -32,8 +47,12 @@ struct block_device { struct list_head idle_blocks; struct cdev cdev; + + bool need_reparse; }; +#define BLOCKSIZE(blk) (1u << (blk)->blockbits) + extern struct list_head block_device_list; #define for_each_block_device(bdev) list_for_each_entry(bdev, &block_device_list, list) @@ -50,12 +69,32 @@ static inline int block_flush(struct block_device *blk) } #ifdef CONFIG_BLOCK -struct block_device *cdev_get_block_device(struct cdev *cdev); +struct block_device *cdev_get_block_device(const struct cdev *cdev); +unsigned file_list_add_blockdevs(struct file_list *files); #else -static inline struct block_device *cdev_get_block_device(struct cdev *cdev) +static inline struct block_device *cdev_get_block_device(const struct cdev *cdev) { return NULL; } +static inline unsigned file_list_add_blockdevs(struct file_list *files) +{ + return 0; +} #endif +static inline bool cdev_is_block_device(const struct cdev *cdev) +{ + return cdev_get_block_device(cdev) != NULL; +} + +static inline bool cdev_is_block_partition(const struct cdev *cdev) +{ + return cdev_is_block_device(cdev) && cdev_is_partition(cdev); +} + +static inline bool cdev_is_block_disk(const struct cdev *cdev) +{ + return cdev_is_block_device(cdev) && !cdev_is_partition(cdev); +} + #endif /* __BLOCK_H */ |