Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Jun 2011 17:50:10 GMT
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        freebsd-geom@FreeBSD.org
Subject:   Re: kern/157724: [geom] gpart(8) 'add' command must preserve gap for schemes
Message-ID:  <201106271750.p5RHoAN8046023@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/157724; it has been noted by GNATS.

From: "Andrey V. Elsukov" <ae@FreeBSD.org>
To: Marcel Moolenaar <marcel@xcllnt.net>
Cc: bug-followup@FreeBSD.org, eirnym@gmail.com, 
 Marcel Moolenaar <marcel@FreeBSD.org>
Subject: Re: kern/157724: [geom] gpart(8) 'add' command must preserve gap
 for schemes
Date: Mon, 27 Jun 2011 21:40:41 +0400

 This is a multi-part message in MIME format.
 --------------020406000309010000060206
 Content-Type: text/plain; charset=KOI8-R
 Content-Transfer-Encoding: 7bit
 
 On 27.06.2011 20:39, Marcel Moolenaar wrote:
 >> I am partially agree with you. geom_part_bsd does not protects
 >> metadata from overwriting. And it is bad for users which are not
 >> aware about this. Also it is easy to wipe metadata now, when
 >> first partition of BSD scheme should not always have UFS file
 >> system.
 > 
 > There isn't a lot we can do about it. This is one of those
 > historical mistakes that you can't fix without breaking with
 > 30+ years of history. It's not worth the hassle IMO...
 
 Hi, Marcel
 
 I think we can just set gpt_first = 16 in g_part_bsd_create for new
 tables and for existing tables also set gpt_first = 16 if all partitions
 don not use this space. Something like this (untested):
 
 -- 
 WBR, Andrey V. Elsukov
 
 --------------020406000309010000060206
 Content-Type: text/plain;
  name="g_part_bsd.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="g_part_bsd.diff"
 
 Index: head/sys/geom/part/g_part_bsd.c
 ===================================================================
 --- head/sys/geom/part/g_part_bsd.c	(revision 223600)
 +++ head/sys/geom/part/g_part_bsd.c	(working copy)
 @@ -225,12 +225,12 @@ g_part_bsd_create(struct g_part_table *basetable,
  	le16enc(ptr + 138, basetable->gpt_entries);	/* d_npartitions */
  	le32enc(ptr + 140, BBSIZE);			/* d_bbsize */
  
 -	basetable->gpt_first = 0;
 +	basetable->gpt_first = BBSIZE / pp->sectorsize;
  	basetable->gpt_last = msize - 1;
  	basetable->gpt_isleaf = 1;
  
  	baseentry = g_part_new_entry(basetable, RAW_PART + 1,
 -	    basetable->gpt_first, basetable->gpt_last);
 +	    0, basetable->gpt_last);
  	baseentry->gpe_internal = 1;
  	entry = (struct g_part_bsd_entry *)baseentry;
  	entry->part.p_size = basetable->gpt_last + 1;
 @@ -437,7 +437,11 @@ g_part_bsd_read(struct g_part_table *basetable, st
  		entry->part = part;
  		if (index == RAW_PART)
  			baseentry->gpe_internal = 1;
 +		else if (baseentry->gpe_start < BBSIZE / pp->sectorsize)
 +			error = 1;
  	}
 +	if (error == 0)
 +		basetable->gpt_first = BBSIZE / pp->sectorsize;
  
  	return (0);
  
 
 --------------020406000309010000060206--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106271750.p5RHoAN8046023>