Module Name:    src
Committed By:   jmcneill
Date:           Sun May 24 18:42:20 UTC 2020

Modified Files:
        src/sbin/gpt: gpt.8 gpt.c gpt.h main.c

Log Message:
Add -H flag to ignore existing MBR (Hybrid MBR/GPT mode).


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sbin/gpt/gpt.8
cvs rdiff -u -r1.81 -r1.82 src/sbin/gpt/gpt.c
cvs rdiff -u -r1.41 -r1.42 src/sbin/gpt/gpt.h
cvs rdiff -u -r1.13 -r1.14 src/sbin/gpt/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/gpt/gpt.8
diff -u src/sbin/gpt/gpt.8:1.71 src/sbin/gpt/gpt.8:1.72
--- src/sbin/gpt/gpt.8:1.71	Sun May 24 14:42:44 2020
+++ src/sbin/gpt/gpt.8	Sun May 24 18:42:20 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.71 2020/05/24 14:42:44 jmcneill Exp $
+.\" $NetBSD: gpt.8,v 1.72 2020/05/24 18:42:20 jmcneill Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -34,7 +34,7 @@
 .Nd GUID partition table maintenance utility
 .Sh SYNOPSIS
 .Nm
-.Op Fl nrqv
+.Op Fl Hnrqv
 .Op Fl m Ar mediasize
 .Op Fl s Ar sectorsize
 .Op Fl T Ar timestamp
@@ -83,6 +83,8 @@ have an effect on all commands.
 Override the default media size for the device (obtained
 from the kernel if possible) or defaulting to the file size for
 plain files.
+.If Fl H
+Ignore existing MBR (Hybrid MBR/GPT mode).
 .It Fl n
 Do not update the wedge information that
 .Nm

Index: src/sbin/gpt/gpt.c
diff -u src/sbin/gpt/gpt.c:1.81 src/sbin/gpt/gpt.c:1.82
--- src/sbin/gpt/gpt.c:1.81	Fri Oct 11 23:04:52 2019
+++ src/sbin/gpt/gpt.c	Sun May 24 18:42:20 2020
@@ -35,7 +35,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: gpt.c,v 1.81 2019/10/11 23:04:52 christos Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.82 2020/05/24 18:42:20 jmcneill Exp $");
 #endif
 
 #include <sys/param.h>
@@ -311,7 +311,7 @@ gpt_mbr(gpt_t gpt, off_t lba, unsigned i
 			continue;
 		if (mbr->mbr_part[i].part_typ == MBR_PTYPE_PMBR)
 			pmbr++;
-		else
+		else if ((gpt->flags & GPT_HYBRID) == 0)
 			break;
 	}
 	if (pmbr && i == 4 && lba == 0) {

Index: src/sbin/gpt/gpt.h
diff -u src/sbin/gpt/gpt.h:1.41 src/sbin/gpt/gpt.h:1.42
--- src/sbin/gpt/gpt.h:1.41	Sun Jun 30 11:38:16 2019
+++ src/sbin/gpt/gpt.h	Sun May 24 18:42:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: gpt.h,v 1.41 2019/06/30 11:38:16 sevan Exp $	*/
+/*	$NetBSD: gpt.h,v 1.42 2020/05/24 18:42:20 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2002 Marcel Moolenaar
@@ -84,6 +84,7 @@ gpt_t	gpt_open(const char *, int, int, o
 #define GPT_FILE	0x10
 #define GPT_TIMESTAMP	0x20
 #define GPT_SYNC	0x40
+#define GPT_HYBRID	0x80
 #define GPT_OPTDEV      0x8000
 
 void*	gpt_read(gpt_t, off_t, size_t);

Index: src/sbin/gpt/main.c
diff -u src/sbin/gpt/main.c:1.13 src/sbin/gpt/main.c:1.14
--- src/sbin/gpt/main.c:1.13	Tue Jun 25 04:53:40 2019
+++ src/sbin/gpt/main.c	Sun May 24 18:42:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.13 2019/06/25 04:53:40 jnemeth Exp $	*/
+/*	$NetBSD: main.c,v 1.14 2020/05/24 18:42:20 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2002 Marcel Moolenaar
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __RCSID
-__RCSID("$NetBSD: main.c,v 1.13 2019/06/25 04:53:40 jnemeth Exp $");
+__RCSID("$NetBSD: main.c,v 1.14 2020/05/24 18:42:20 jmcneill Exp $");
 #endif
 
 #include <stdio.h>
@@ -185,8 +185,11 @@ main(int argc, char *argv[])
 #endif
 
 	/* Get the generic options */
-	while ((ch = getopt(argc, argv, GETOPT_BE_POSIX "m:nqrs:T:v")) != -1) {
+	while ((ch = getopt(argc, argv, GETOPT_BE_POSIX "Hm:nqrs:T:v")) != -1) {
 		switch(ch) {
+		case 'H':
+			flags |= GPT_HYBRID;
+			break;
 		case 'm':
 			if (mediasz > 0)
 				usage();

Reply via email to