From 5bd0c8a5e587b7fa0f5d6c9d67c8e10ea41634fe Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 1 Sep 2009 11:18:57 -0700 Subject: [PATCH] Kernel - Disk - do not bother trying to read the MBR if media_size is 0 * Do not bother trying to read the MBR if media_size is 0, typically indicating removable media with no media present. --- sys/kern/subr_diskmbr.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/kern/subr_diskmbr.c b/sys/kern/subr_diskmbr.c index 0ac4506594..94a5e99ed8 100644 --- a/sys/kern/subr_diskmbr.c +++ b/sys/kern/subr_diskmbr.c @@ -118,9 +118,18 @@ mbrinit(cdev_t dev, struct disk_info *info, struct diskslices **sspp) mbr_offset = DOSBBSECTOR; reread_mbr: + /* + * Don't bother if the block size is weird or the + * media size is 0 (probably means no media present). + */ if (info->d_media_blksize & DEV_BMASK) return (EIO); - /* Read master boot record. */ + if (info->d_media_size == 0) + return (EIO); + + /* + * Read master boot record. + */ wdev = dev; bp = geteblk((int)info->d_media_blksize); bp->b_bio1.bio_offset = (off_t)mbr_offset * info->d_media_blksize; -- 2.41.0