7598 loader: Implement disk_ioctl() to support DIOCGSECTORSIZE and DIOCGMEDIASIZE.

Review Request #271 - Created Nov. 20, 2016 and submitted

Information
Toomas Soome
illumos-gate
7598
282
272
8047917...
Reviewers
general

7598 loader: Implement disk_ioctl() to support DIOCGSECTORSIZE and DIOCGMEDIASIZE.

Need interface to extract information about disk abstraction,
to read disk or partition size depending on the provided argument
and adjust disk size based on information in partition table.

The disk handle from disk_open() has d_offset field to point to
partition start. So we can use this fact to return either whole disk
size or partition size. For this we only need to record partition size
we get from disk_open() anyhow.

In addition, this will also make it possible to adjust the disk media size
based on information from partition table. The problem with disk size is
about some BIOS systems reporting bogus disk size for 2+TB disks, but
since such disks are using GPT partitioning, and GPT does have information
about disk size (alternate LBA + 1), we can use this fact to record disk
size based on partition table.

This patch does exactly this: implements DIOCGSECTORSIZE and DIOCGMEDIASIZE
ioctl, and DIOCGMEDIASIZE will report either disk media size or partition size.

Adds ptable_getsize() call to read partition size in bytes from ptable pointer.
Updates disk_open() to use ptable_getsize() to update mediasize value.

Implements GPT detection function to update ptable size (used by
ptable_getsize()) according to alternate lba (which is location of backup copy
of GPT header table).

This implementation is used by https://reviews.freebsd.org/D8581
and https://www.illumos.org/rb/r/272/


  

Issues

  • 0
  • 6
  • 1
  • 7
Description From Last Updated
Toomas Soome
Toomas Soome
Robert Mustacchi
Toomas Soome
Toomas Soome
Robert Mustacchi
Toomas Soome
Robert Mustacchi
Toomas Soome
Toomas Soome
Robert Mustacchi
Toomas Soome
Robert Mustacchi
Juraj Lutter
Toomas Soome
Review request changed

Status: Closed (submitted)

Loading...