NetBSD-Bugs archive

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

Re: bin/55601: Unable to destroy gpt on disk with invalid GPT



The following reply was made to PR bin/55601; it has been noted by GNATS.

From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: abs%absd.org@localhost
Cc: gnats-bugs%netbsd.org@localhost
Subject: Re: bin/55601: Unable to destroy gpt on disk with invalid GPT
Date: Mon, 24 Aug 2020 13:58:16 +0700

 Can you try the following patch?
 
 (For a bunch of reasons I'm not in a position to actually test this
 right now, but I think it should work).
 
 It applies (to HEAD) in src/sbin/gpt
 
 kre
 
 ps: the spaces in the #define of GPT_OPTDEV in gpt.h should be changed to
 a tab, but that has nothing to do with this issue.
 
 Index: destroy.c
 ===================================================================
 RCS file: /cvsroot/src/sbin/gpt/destroy.c,v
 retrieving revision 1.13
 diff -u -r1.13 destroy.c
 --- destroy.c	16 Oct 2019 19:03:53 -0000	1.13
 +++ destroy.c	24 Aug 2020 06:53:52 -0000
 @@ -59,7 +59,7 @@
  	"destroy",
  	cmd_destroy,
  	destroyhelp, __arraycount(destroyhelp),
 -	GPT_SYNC,
 +	GPT_IGNORE | GPT_SYNC,
  };
  
  #define usage() gpt_usage(NULL, &c_destroy)
 Index: gpt.c
 ===================================================================
 RCS file: /cvsroot/src/sbin/gpt/gpt.c,v
 retrieving revision 1.82
 diff -u -r1.82 gpt.c
 --- gpt.c	24 May 2020 18:42:20 -0000	1.82
 +++ gpt.c	24 Aug 2020 06:53:53 -0000
 @@ -569,6 +569,9 @@
  	if (map_init(gpt, devsz) == -1)
  		goto close;
  
 +	if (flags & GPT_IGNORE)
 +		return gpt;
 +
  	index = 1;
  	if (gpt_mbr(gpt, 0LL, &index, 0U) == -1)
  		goto close;
 Index: gpt.h
 ===================================================================
 RCS file: /cvsroot/src/sbin/gpt/gpt.h,v
 retrieving revision 1.42
 diff -u -r1.42 gpt.h
 --- gpt.h	24 May 2020 18:42:20 -0000	1.42
 +++ gpt.h	24 Aug 2020 06:53:53 -0000
 @@ -85,6 +85,7 @@
  #define GPT_TIMESTAMP	0x20
  #define GPT_SYNC	0x40
  #define GPT_HYBRID	0x80
 +#define GPT_IGNORE	0x4000
  #define GPT_OPTDEV      0x8000
  
  void*	gpt_read(gpt_t, off_t, size_t);
 
 


Home | Main Index | Thread Index | Old Index