Add -g flag to preserve GPT headers when updating MBR.
This commit is contained in:
parent
e5906ade5e
commit
f907c64a8f
|
@ -1,6 +1,6 @@
|
|||
.\" $NetBSD: fdisk.8,v 1.90 2019/12/15 11:49:28 wiz Exp $
|
||||
.\" $NetBSD: fdisk.8,v 1.91 2020/05/24 18:42:48 jmcneill Exp $
|
||||
.\"
|
||||
.Dd December 14, 2019
|
||||
.Dd May 24, 2020
|
||||
.Dt FDISK 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -8,7 +8,7 @@
|
|||
.Nd MS-DOS partition maintenance program
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl aBFfIiSuv
|
||||
.Op Fl aBFfgIiSuv
|
||||
.Oo
|
||||
.Fl 0 | 1 | 2 | 3 | E Ar number
|
||||
.Op Fl s Oo Ar id Oc Ns Oo / Ns Oo Ar start Oc Ns Oo / Ns Oo Ar size Oc Ns Oo / Ns Oo Ar bootmenu Oc Oc Oc Oc
|
||||
|
@ -114,7 +114,9 @@ selects defaults for its questions to guarantee that behaviour.
|
|||
If partition data is going to be updated and the disk carries GUID Partition
|
||||
Tables,
|
||||
.Nm
|
||||
will remove both primary and backup GPT headers from the disk.
|
||||
will remove both primary and backup GPT headers from the disk unless the
|
||||
.Fl g
|
||||
flag is specified.
|
||||
See
|
||||
.Xr gpt 8
|
||||
for information on how to manipulate GUID Partition Tables.
|
||||
|
@ -262,6 +264,8 @@ and
|
|||
fields
|
||||
.Pq only Ar start No and Ar size No can be specified by Fl s No option .
|
||||
They will be automatically computed using the BIOS geometry.
|
||||
.It Fl g
|
||||
Preserve existing GPT headers when updating partitions.
|
||||
.It Fl I
|
||||
Ignore errors from overlapping partitions.
|
||||
Some devices (cameras CHDK) require overlapping partitions to support
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fdisk.c,v 1.157 2019/10/07 20:56:07 christos Exp $ */
|
||||
/* $NetBSD: fdisk.c,v 1.158 2020/05/24 18:42:48 jmcneill Exp $ */
|
||||
|
||||
/*
|
||||
* Mach Operating System
|
||||
|
@ -39,7 +39,7 @@
|
|||
#include <sys/cdefs.h>
|
||||
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: fdisk.c,v 1.157 2019/10/07 20:56:07 christos Exp $");
|
||||
__RCSID("$NetBSD: fdisk.c,v 1.158 2020/05/24 18:42:48 jmcneill Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#define MBRPTYPENAMES
|
||||
|
@ -141,7 +141,7 @@ static char *boot_path = NULL; /* name of file we actually opened */
|
|||
#define BOOTSEL_OPTIONS
|
||||
#define change_part(e, p, id, st, sz, bm) change__part(e, p, id, st, sz)
|
||||
#endif
|
||||
#define OPTIONS BOOTSEL_OPTIONS "0123FSafiIluvA:b:c:E:r:s:w:z:"
|
||||
#define OPTIONS BOOTSEL_OPTIONS "0123FSafgiIluvA:b:c:E:r:s:w:z:"
|
||||
|
||||
/*
|
||||
* Disk geometry and partition alignment.
|
||||
|
@ -215,6 +215,7 @@ static int u_flag; /* update partition data */
|
|||
static int v_flag; /* more verbose */
|
||||
static int sh_flag; /* Output data as shell defines */
|
||||
static int f_flag; /* force --not interactive */
|
||||
static int g_flag; /* preserve GPT headers */
|
||||
static int s_flag; /* set id,offset,size */
|
||||
static int b_flag; /* Set cyl, heads, secs (as c/h/s) */
|
||||
static int B_flag; /* Edit/install bootselect code */
|
||||
|
@ -430,6 +431,9 @@ main(int argc, char *argv[])
|
|||
case 'f': /* Non interactive */
|
||||
f_flag = 1;
|
||||
break;
|
||||
case 'g': /* Preserve GPT headers */
|
||||
g_flag = 1;
|
||||
break;
|
||||
case 'i': /* Always update bootcode */
|
||||
i_flag = 1;
|
||||
break;
|
||||
|
@ -3058,6 +3062,9 @@ delete_gpt(struct gpt_hdr *gptp)
|
|||
char buf[512];
|
||||
struct gpt_hdr *hdr = (void *)buf;
|
||||
|
||||
if (g_flag)
|
||||
return 0; /* preserve existing GPT headers */
|
||||
|
||||
if (gptp->hdr_size == 0)
|
||||
return 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue