Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/gpt Add -H flag to ignore existing MBR (Hybrid MBR/GPT ...



details:   https://anonhg.NetBSD.org/src/rev/4de1c85260f0
branches:  trunk
changeset: 933318:4de1c85260f0
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun May 24 18:42:20 2020 +0000

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

diffstat:

 sbin/gpt/gpt.8  |  6 ++++--
 sbin/gpt/gpt.c  |  4 ++--
 sbin/gpt/gpt.h  |  3 ++-
 sbin/gpt/main.c |  9 ++++++---
 4 files changed, 14 insertions(+), 8 deletions(-)

diffs (96 lines):

diff -r bc6ea11e1fbd -r 4de1c85260f0 sbin/gpt/gpt.8
--- a/sbin/gpt/gpt.8    Sun May 24 17:28:20 2020 +0000
+++ b/sbin/gpt/gpt.8    Sun May 24 18:42:20 2020 +0000
@@ -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 @@
 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
diff -r bc6ea11e1fbd -r 4de1c85260f0 sbin/gpt/gpt.c
--- a/sbin/gpt/gpt.c    Sun May 24 17:28:20 2020 +0000
+++ b/sbin/gpt/gpt.c    Sun May 24 18:42:20 2020 +0000
@@ -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 @@
                        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) {
diff -r bc6ea11e1fbd -r 4de1c85260f0 sbin/gpt/gpt.h
--- a/sbin/gpt/gpt.h    Sun May 24 17:28:20 2020 +0000
+++ b/sbin/gpt/gpt.h    Sun May 24 18:42:20 2020 +0000
@@ -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 @@
 #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);
diff -r bc6ea11e1fbd -r 4de1c85260f0 sbin/gpt/main.c
--- a/sbin/gpt/main.c   Sun May 24 17:28:20 2020 +0000
+++ b/sbin/gpt/main.c   Sun May 24 18:42:20 2020 +0000
@@ -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 @@
 #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();



Home | Main Index | Thread Index | Old Index