From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sat, 7 Jan 2012 20:22:13 +0100 From: tlaronde@polynum.com To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Message-ID: <20120107192213.GA4971@polynum.com> References: <20120107182908.GA3674@polynum.com> <1c3ba45416e47236eedd6ca05863d751@chula.quanstro.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1c3ba45416e47236eedd6ca05863d751@chula.quanstro.net> User-Agent: Mutt/1.4.2.3i Subject: Re: [9fans] BUG: disk/fdisk.c: corrupts MBR Topicbox-Message-UUID: 56400c0a-ead7-11e9-9d60-3106f5b1d025 On Sat, Jan 07, 2012 at 02:04:51PM -0500, erik quanstrom wrote: > On Sat Jan 7 13:30:33 EST 2012, tlaronde@polynum.com wrote: > > The explanation is arithmetic truncation. disk/fdisk.c does this: > > > > p->start = lba/sec2cyl; > > > > and, if modifications are done (for example creating a Plan9 partition, > > of marking a primary partition active), when written back, the entries > > are "restored" by: > > > > *endlba = (vlong)p->start*sec2cyl; > > > can you just set sec2cyl=1? This wouls probably do the trick. But the code is clean and setting just this is not---to my taste. The ideal would be to simply patch the existing with changed values (no need to be efficient for 4 * 16 bytes), and leave clearly alone values set by others. And to verify the magic signature for, at least, the active partition (it would have spot the problem). -- Thierry Laronde http://www.kergis.com/ Key fingerprint = 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C