15#ifndef CARDSIGHT_BLKDEV_H
16#define CARDSIGHT_BLKDEV_H
24#define DISK_NAME_LEN 16
26#define BDEV_LABEL_LEN 32
29#define GENHD_FL_RDONLY 0x02
44 int (*
read)(
struct gendisk *disk, uint64_t sector,
void *buffer, uint32_t count);
46 int (*
write)(
struct gendisk *disk, uint64_t sector,
const void *buffer, uint32_t count);
int blk_erase_partition_table(struct gendisk *disk)
Erase the MBR and both GPT copies.
uint32_t bdev_sector_size(const struct block_device *bdev)
Logical sector size of the disk behind a block device.
blk_partition_content
File system marker stored in a created partition.
Definition blkdev.h:244
@ BLK_PARTITION_EXT4
Definition blkdev.h:247
@ BLK_PARTITION_FAT32
Definition blkdev.h:245
@ BLK_PARTITION_EXFAT
Definition blkdev.h:246
const char * bdev_name(const struct block_device *bdev)
Name of a block device as registered.
uint64_t bdev_nr_sectors(const struct block_device *bdev)
Length of a block device in sectors.
int del_gendisk(struct gendisk *disk)
Take the disk and its partitions away.
struct block_device * bdev_open_by_name(const char *name)
Open a registered block device by name.
int bdev_flush(struct block_device *bdev)
Ask the disk behind a block device to write out its cached writes.
#define DISK_NAME_LEN
Longest disk name, including the terminating zero.
Definition blkdev.h:24
void put_disk(struct gendisk *disk)
Drop the caller's reference to a disk.
int bdev_read(struct block_device *bdev, uint64_t sector, void *buffer, uint32_t count)
Read sectors through a block device view.
void bdev_close(struct block_device *bdev)
Drop one opener of a block device.
void del_gendisk_force(struct gendisk *disk)
Remove the disk without checking its mounts.
struct gendisk * alloc_disk(void)
Allocate a zeroed disk with its whole-disk block device.
bool bdev_is_whole(const struct block_device *bdev)
Report whether a block device covers a whole disk.
int bdev_write(struct block_device *bdev, uint64_t sector, const void *buffer, uint32_t count)
Write sectors through a block device view.
int blk_write_partition_layout(struct gendisk *disk, enum blk_partition_table_type table, const struct blk_partition_layout_entry *entries, uint32_t count)
Write a fresh partition table and rescan it.
int bdev_claim_mount(struct block_device *bdev)
Claim a block device for one file system instance.
int add_disk(struct gendisk *disk)
Register the disk and read its partition table.
blk_partition_table_type
Partition table format written by blk_write_partition_layout().
Definition blkdev.h:236
@ BLK_PARTITION_TABLE_GPT
Definition blkdev.h:238
@ BLK_PARTITION_TABLE_MBR
Definition blkdev.h:237
void bdev_release_mount(struct block_device *bdev)
Release the mount claim of a block device.
bool bdev_read_only(const struct block_device *bdev)
Report whether a block device refuses writes.
#define BDEV_LABEL_LEN
Longest partition label in bytes.
Definition blkdev.h:26
The tiny device model the mmc card and the block layer need: a name and a reference count.
One partition to create, in disk order.
Definition blkdev.h:253
enum blk_partition_content content
Definition blkdev.h:255
uint64_t sectors
Definition blkdev.h:254
char label[BDEV_LABEL_LEN]
Definition blkdev.h:256
Operations a disk driver provides to the block layer.
Definition blkdev.h:37
int(* write)(struct gendisk *disk, uint64_t sector, const void *buffer, uint32_t count)
Write sectors; may be NULL on a disk with GENHD_FL_RDONLY.
Definition blkdev.h:46
int(* read)(struct gendisk *disk, uint64_t sector, void *buffer, uint32_t count)
Read sectors.
Definition blkdev.h:44
void(* free_disk)(struct gendisk *disk)
Release driver state when the last reference is gone.
Definition blkdev.h:54
int(* flush)(struct gendisk *disk)
Write out what the disk holds back; NULL when it writes through.
Definition blkdev.h:48
One openable view of a disk: the whole disk or one partition.
Definition blkdev.h:60
struct block_device * next
Definition blkdev.h:72
struct device dev
Backing device; the name is the disk name or "<disk>p<N>".
Definition blkdev.h:62
uint8_t part_type
Definition blkdev.h:67
uint32_t openers
Definition blkdev.h:70
char label[BDEV_LABEL_LEN]
Definition blkdev.h:69
bool read_only
Definition blkdev.h:68
uint64_t nr_sects
Definition blkdev.h:66
uint32_t mounts
Definition blkdev.h:71
uint64_t start_sect
Definition blkdev.h:65
uint32_t partno
Definition blkdev.h:64
struct gendisk * bd_disk
Definition blkdev.h:63
Reference-counted object shared between the driver and its users.
Definition device.h:21
A disk as a driver describes it to the block layer.
Definition blkdev.h:78
bool dead
Definition blkdev.h:90
void * private_data
Definition blkdev.h:80
uint32_t flags
Definition blkdev.h:84
uint32_t logical_block_size
Definition blkdev.h:83
bool registered
Definition blkdev.h:89
const struct block_device_operations * fops
Definition blkdev.h:81
uint64_t capacity
Definition blkdev.h:82
uint32_t part_count
Definition blkdev.h:87
struct block_device * parts
Definition blkdev.h:86
struct gendisk * next
Definition blkdev.h:88
struct block_device * part0
Definition blkdev.h:85
char disk_name[DISK_NAME_LEN]
Definition blkdev.h:79