installer: Use ioctl(DIOCGPART) for getting a disk's size.
commit795e32157bb0bc3e1efe5a4a0fce70a9f39b74be
authorSascha Wildner <saw@online.de>
Tue, 31 May 2016 21:27:35 +0000 (31 23:27 +0200)
committerSascha Wildner <saw@online.de>
Tue, 31 May 2016 21:28:35 +0000 (31 23:28 +0200)
treeabd82d0ddbe806a9dcdb44f1212eacea7394a3f5
parent2f7069fc9ad937c24e41ca31ce05180eba980035
installer: Use ioctl(DIOCGPART) for getting a disk's size.

Before this commit, the installer was grepping in /var/run/dmesg.boot.
This approach has one problem in particular, which is that it was
used with CAM attached disks in mind, which will always print their
size in MiBs. However, some drivers, such as mmcsd(4), roll their own
disk, so they are free to choose what they print in their *_attach()
function. Yet we still want to offer these disks from the installer.
For example, mmcsd(4) starts printing the size in gigabytes if the
disk is >= 10GiB.

This commit changes the installer's survey function to read the
disk's size using ioctl(DIOCGPART) to have consistent results.

Reported-by: Dmitry Postolov <dpostolov@yandex.ru>
Dragonfly-bug: <https://bugs.dragonflybsd.org/issues/2899>
usr.sbin/installer/libinstaller/survey.c