kboot: Disks should be at least 16MB

Linux pre-boot environments will often have a number of psuedo disks
that are small, all smaller than a few MB. 16MB is a good cutoff since
it's big enough to filter these devices, yet small enough to allow a
super-minimal partition through (the smallest I've been able to make
that's useful lately is around 20MB).

Sponsored by:		Netflix
This commit is contained in:
Warner Losh 2022-12-12 22:39:03 -07:00
parent 538b73578b
commit 0386255bee

View File

@ -60,6 +60,8 @@ struct devsw hostdisk = {
*/
#define SYSBLK "/sys/block"
#define HOSTDISK_MIN_SIZE (16ul << 20) /* 16MB */
typedef STAILQ_HEAD(, hdinfo) hdinfo_list_t;
typedef struct hdinfo {
STAILQ_ENTRY(hdinfo) hd_link; /* link in device list */
@ -162,6 +164,8 @@ hostdisk_add_drive(const char *drv, uint64_t secs)
if (!file2u64(fn, &hd->hd_sectorsize))
goto err;
hd->hd_size = hd->hd_sectors * hd->hd_sectorsize;
if (hd->hd_size < HOSTDISK_MIN_SIZE)
goto err;
hd->hd_flags = 0;
STAILQ_INIT(&hd->hd_children);
printf("/dev/%s: %ju %ju %ju\n",