Subject: Re: disklabel -Rr sd0 protofile, disklabel -wr sd0 disktype
To: None <port-i386@NetBSD.ORG>
From: Hiroyuki Ito <hiroy@netcom.com>
List: port-i386
Date: 04/30/1996 09:51:32
I wrote:
> "disklabel -Rr sd0 protofile" trashes existing boot or MBR.
> "disklabel -wr sd0 disktype"  trashes existing boot or MBR.

A patch against /usr/src/sbin/disklabel/disklabel.c,v 1.30
--------------------------------------------------------------------
*** disklabel.c.orig	Mon Apr  8 01:54:26 1996
--- disklabel.c	Mon Apr 29 23:23:53 1996
***************
*** 420,425 ****
--- 420,444 ----
  			}
  			sectoffset = 0;
  		}
+ 		/*
+ 		 * If we are not installing a boot program
+ 		 * we must read the current bootarea so we don't
+ 		 * clobber the existing boot.
+ 		 */
+ 		if (!installboot) {
+ 			struct disklabel tlab;
+ 
+ 			if (lseek(f, sectoffset, SEEK_SET) < 0) {
+ 				perror("lseek");
+ 				return (1);
+ 			}
+ 			tlab = *lp;
+ 			if (read(f, boot, tlab.d_bbsize) != tlab.d_bbsize) {
+ 				perror("read");
+ 				return (1);
+ 			}
+ 			*lp =tlab;
+ 		}
  #endif
  
  		/*
***************
*** 651,661 ****
--- 670,682 ----
  	 * clobber the existing boot.
  	 */
  	if (!installboot) {
+ #ifndef i386
  		if (rflag) {
  			if (read(f, boot, BBSIZE) < BBSIZE)
  				err(4, "%s", specname);
  			memset(lp, 0, sizeof *lp);
  		}
+ #endif
  		return (lp);
  	}
  	/*
--------------------------------------------------------------------

Hiroyuki Ito