From: krw Date: Thu, 27 May 2021 14:27:41 +0000 (+0000) Subject: Relax criteria for recognizing GPT formatted media by allowing the X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8b2581710961959a9fc65ad0ac896ef8c9d5c9aa;p=openbsd Relax criteria for recognizing GPT formatted media by allowing the EFI GPT partition (0xEE) in the protective MBR to be smaller that the actual size of the media. This allows GPT disk images dd'ed onto larger physical media to be recognized by fdisk(8) and the kernel. Feedback from kettenis@ on various earlier versions. --- diff --git a/sbin/fdisk/mbr.c b/sbin/fdisk/mbr.c index f2b685980cd..6ccbc244982 100644 --- a/sbin/fdisk/mbr.c +++ b/sbin/fdisk/mbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mbr.c,v 1.71 2021/05/21 19:09:46 krw Exp $ */ +/* $OpenBSD: mbr.c,v 1.72 2021/05/27 14:27:41 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -315,7 +315,7 @@ gpt_chk_mbr(struct dos_partition *dp, u_int64_t dsize) if (letoh32(dp2->dp_start) != GPTSECTOR) continue; psize = letoh32(dp2->dp_size); - if (psize == (dsize - 1) || psize == UINT32_MAX) { + if (psize <= (dsize - 1) || psize == UINT32_MAX) { efi = i; eficnt++; } diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index a6d512ec322..ba1b8c1782d 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.241 2021/05/14 21:11:15 krw Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.242 2021/05/27 14:27:41 krw Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -607,7 +607,7 @@ gpt_chk_mbr(struct dos_partition *dp, uint64_t dsize) if (letoh32(dp2->dp_start) != GPTSECTOR) continue; psize = letoh32(dp2->dp_size); - if (psize == (dsize - 1) || psize == UINT32_MAX) { + if (psize <= (dsize - 1) || psize == UINT32_MAX) { efi = i; eficnt++; }