From 34ea800dbdcdb6e8fae3085636939170d37c78a9 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 23 Jun 2009 16:08:26 -0700 Subject: [PATCH] kernel diskmbr handling - Detect maxed out slice ds_size field. If the DOS slice field is found to be maxed out (0xFFFFFFFFU), use the actual media size for calculations instead of ds_size. This allows disks > 2TB to have a conventional slice table and still contain a disklabel64 which covers the actual size of the media. --- sys/kern/subr_diskmbr.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sys/kern/subr_diskmbr.c b/sys/kern/subr_diskmbr.c index c8b11ae364..b353566eae 100644 --- a/sys/kern/subr_diskmbr.c +++ b/sys/kern/subr_diskmbr.c @@ -516,12 +516,18 @@ mbr_setslice(char *sname, struct disk_info *info, struct diskslice *sp, return (1); } size = info->d_media_blocks - offset; - if (size >= dp->dp_size) - size = dp->dp_size; - else - kprintf( -"%s: slice extends beyond end of disk: truncating from %lu to %llu sectors\n", - sname, (u_long)dp->dp_size, size); + if (size >= dp->dp_size) { + if (dp->dp_size == 0xFFFFFFFFU) { + kprintf("%s: slice >2TB, using media size instead " + "of slice table size\n", sname); + } else { + size = dp->dp_size; + } + } else { + kprintf("%s: slice extends beyond end of disk: " + "truncating from %lu to %llu sectors\n", + sname, (u_long)dp->dp_size, size); + } sp->ds_offset = offset; sp->ds_size = size; sp->ds_type = dp->dp_typ; -- 2.41.0