Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/fdisk Add -g flag to preserve GPT headers when updating...
details: https://anonhg.NetBSD.org/src/rev/a562b7d1822a
branches: trunk
changeset: 933319:a562b7d1822a
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sun May 24 18:42:48 2020 +0000
description:
Add -g flag to preserve GPT headers when updating MBR.
diffstat:
sbin/fdisk/fdisk.8 | 12 ++++++++----
sbin/fdisk/fdisk.c | 13 ++++++++++---
2 files changed, 18 insertions(+), 7 deletions(-)
diffs (96 lines):
diff -r 4de1c85260f0 -r a562b7d1822a sbin/fdisk/fdisk.8
--- a/sbin/fdisk/fdisk.8 Sun May 24 18:42:20 2020 +0000
+++ b/sbin/fdisk/fdisk.8 Sun May 24 18:42:48 2020 +0000
@@ -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 @@
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 @@
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
diff -r 4de1c85260f0 -r a562b7d1822a sbin/fdisk/fdisk.c
--- a/sbin/fdisk/fdisk.c Sun May 24 18:42:20 2020 +0000
+++ b/sbin/fdisk/fdisk.c Sun May 24 18:42:48 2020 +0000
@@ -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 @@
#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 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 @@
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 @@
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;
Home |
Main Index |
Thread Index |
Old Index