freebsd-dev/sys/boot/usb
Toomas Soome c12dbfe608 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).

Reviewed by:	allanjude
Approved by:	allanjude (mentor)
Differential Revision:	https://reviews.freebsd.org/D8594
2017-02-06 08:26:45 +00:00
..
storage loader: Implement disk_ioctl() to support DIOCGSECTORSIZE and DIOCGMEDIASIZE. 2017-02-06 08:26:45 +00:00
tools Use MAN= to specify that no man page is provided 2016-01-22 21:33:27 +00:00
bsd_usbloader_test.c Add function needed for linking USB test application. 2016-04-26 15:33:53 +00:00
Makefile Merge from CheriBSD: 2014-08-04 23:00:13 +00:00
Makefile.test For libstand and sys/boot, split off gcc-only flags into CFLAGS.gcc. 2013-12-26 11:32:39 +00:00
usb_busdma_loader.c Use properly aligned buffer in usb_alloc 2015-11-27 18:13:28 +00:00
usbcore.mk Add support for exynos5_ehci in loader 2015-11-27 18:22:04 +00:00