* @if_typename: interface name for block device
* @desc: internal block device
* @dev_index: device index for block device
- * @offset: offset into disk for simple partitions
+ * @part_info: partition info
* @part: partition
* @disk: pointer to receive the created handle
* Return: disk object
const char *if_typename,
struct blk_desc *desc,
int dev_index,
- lbaint_t offset,
+ struct disk_partition *part_info,
unsigned int part,
struct efi_disk_obj **disk)
{
efi_add_handle(&diskobj->header);
/* Fill in object data */
- if (part) {
+ if (part_info) {
struct efi_device_path *node = efi_dp_part_node(desc, part);
struct efi_handler *handler;
void *protocol_interface;
diskobj->dp = efi_dp_append_node(dp_parent, node);
efi_free_pool(node);
+ diskobj->offset = part_info->start;
+ diskobj->media.last_block = part_info->size - 1;
} else {
diskobj->dp = efi_dp_from_part(desc, part);
+ diskobj->offset = 0;
+ diskobj->media.last_block = desc->lba - 1;
}
diskobj->part = part;
diskobj->ops = block_io_disk_template;
diskobj->ifname = if_typename;
diskobj->dev_index = dev_index;
- diskobj->offset = offset;
diskobj->desc = desc;
/* Fill in EFI IO Media info (for read/write callbacks) */
diskobj->media.media_id = 1;
diskobj->media.block_size = desc->blksz;
diskobj->media.io_align = desc->blksz;
- diskobj->media.last_block = desc->lba - offset;
if (part)
diskobj->media.logical_partition = 1;
diskobj->ops.media = &diskobj->media;
if (disk)
*disk = diskobj;
+ EFI_PRINT("BlockIO: part %u, present %d, logical %d, removable %d"
+ ", offset " LBAF ", last_block %llu\n",
+ diskobj->part,
+ diskobj->media.media_present,
+ diskobj->media.logical_partition,
+ diskobj->media.removable_media,
+ diskobj->offset,
+ diskobj->media.last_block);
+
/* Store first EFI system partition */
if (part && !efi_system_partition.if_type) {
int r;
{
int disks = 0;
char devname[32] = { 0 }; /* dp->str is u16[32] long */
- struct disk_partition info;
int part;
struct efi_device_path *dp = NULL;
efi_status_t ret;
/* Add devices for each partition */
for (part = 1; part <= MAX_SEARCH_PARTITIONS; part++) {
+ struct disk_partition info;
+
if (part_get_info(desc, part, &info))
continue;
snprintf(devname, sizeof(devname), "%s:%d", pdevname,
part);
ret = efi_disk_add_dev(parent, dp, if_typename, desc, diskid,
- info.start, part, NULL);
+ &info, part, NULL);
if (ret != EFI_SUCCESS) {
log_err("Adding partition %s failed\n", pdevname);
continue;
/* Add block device for the full device */
log_info("Scanning disk %s...\n", dev->name);
ret = efi_disk_add_dev(NULL, NULL, if_typename,
- desc, desc->devnum, 0, 0, &disk);
+ desc, desc->devnum, NULL, 0, &disk);
if (ret == EFI_NOT_READY) {
log_notice("Disk %s not ready\n", dev->name);
continue;
/* Add block device for the full device */
ret = efi_disk_add_dev(NULL, NULL, if_typename, desc,
- i, 0, 0, &disk);
+ i, NULL, 0, &disk);
if (ret == EFI_NOT_READY) {
log_notice("Disk %s not ready\n", devname);
continue;