Subject: bin/6622: fix to make 'disklabel -r -e' work on a blank un-labeled disk
To: None <gnats-bugs@gnats.netbsd.org>
From: None <woods@mail.weird.com>
List: netbsd-bugs
Date: 12/20/1998 22:03:34
>Number:         6622
>Category:       bin
>Synopsis:       fix to make 'disklabel -r -e' work on a blank un-labeled disk
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 20 19:05:00 1998
>Last-Modified:
>Originator:     Greg A. Woods
>Organization:
Planix, Inc.; Toronto, Ontario; Canada
>Release:        NetBSD-current sup'ed Mon Nov 16 08:02:37 EST 1998
>Environment:

System: NetBSD 
Architecture: i386

>Description:

	It is impossible to edit a label on a new un-labeled disk even
	though "disklabel" gives an error message that suggests it can
	be done with '-r'.  As a result it is impossible to install a
	new label in a blank un-labeled disk without editing
	/etc/disktab.

	(It's also impossible to specify a file other than /etc/disktab
	to disklabel(8), but that's another PR!)

>How-To-Repeat:

	Try running "disklabel -r -e" on a brand new, blank, disk.

>Fix:

	This change has been tested, once, on a i386 SCSI system, so it
	may not be complete, but it was sufficient to label the one
	non-bootable disk I had to do.

	NOTICE:  This change should be enhanced to work with '-i' too!

Index: sbin/disklabel/disklabel.c
===================================================================
RCS file: /cvs/NetBSD/src/sbin/disklabel/disklabel.c,v
retrieving revision 1.1.1.5
diff -c -r1.1.1.5 sbin/disklabel/disklabel.c
*** sbin/disklabel/disklabel.c	1998/11/16 20:44:45	1.1.1.5
--- sbin/disklabel/disklabel.c	1998/12/21 02:43:04
***************
*** 836,842 ****
  			}
  		}
  		/* lp = (struct disklabel *)(bootarea + LABELOFFSET); */
! 		errx(1, msg);
  	} else {
  		lp = &lab;
  		if (ioctl(f, DIOCGDINFO, lp) < 0)
--- 846,858 ----
  			}
  		}
  		/* lp = (struct disklabel *)(bootarea + LABELOFFSET); */
! 		if (op == EDIT) {	/* XXX: || op == INTERACT */
! 			warnx("NOTICE: %s: editing from the in-core label, no boot block installed!", msg);
! 			lp = &lab;
! 			if (ioctl(f, DIOCGDINFO, lp) < 0)
! 				err(4, "ioctl DIOCGDINFO");
! 		} else
! 			errx(1, msg);
  	} else {
  		lp = &lab;
  		if (ioctl(f, DIOCGDINFO, lp) < 0)
***************
*** 1224,1229 ****
--- 1244,1251 ----
  	}
  	(void)fchmod(fd, 0600);
  	display(fp, lp);
+ 	if (rflag)
+ 		lp = makebootarea(bootarea, lp, f);
  	(void) fclose(fp);
  	for (;;) {
  		if (!editit())
>Audit-Trail:
>Unformatted: