Subject: bin/3686: disklabel can't handle non-512 bytes/sector correctly with -R
To: None <gnats-bugs@gnats.netbsd.org>
From: None <koji@math.human.nagoya-u.ac.jp>
List: netbsd-bugs
Date: 05/30/1997 17:17:02
>Number:         3686
>Category:       bin
>Synopsis:       disklabel can't handle non-512 bytes/sector correctly with -R
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 30 03:20:01 1997
>Last-Modified:
>Originator:     Koji Imada - je4owb/2
>Organization:
Mathematics Group of Graduate School of Human
	Infomatics, Nagoya University, Japan.
>Release:        970523
>Environment:
	
System: NetBSD bimota 1.2E NetBSD 1.2E (BIMOTA) #30: Tue May 13 23:32:51 JST 1997 koji@ducati:/mnt2/NetBSD/work/src-ufs-mod/sys/arch/i386/compile/BIMOTA i386


>Description:
	disklabel can't handle non-512 bytes/sector media correctly
	with -R option.

	When disklabelling non-512 bytes/sector media with -R option,
	disklabel is positioned as physical sector size is 512 bytes.
>How-To-Repeat:
	Write protofile for non-512bytes/sector media and disklabel it 
	with -R option. disklabel is not positioned in physical sector 
	size.
>Fix:
	Apply following patch.

Index: sbin/disklabel/disklabel.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sbin/disklabel/disklabel.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 disklabel.c
--- disklabel.c	1997/04/01 08:45:27	1.1.1.2
+++ disklabel.c	1997/04/17 18:30:37
@@ -316,11 +316,13 @@
 		if (installboot && argc == 3)
 			makelabel(argv[2], (char *)0, &lab);
 #endif
-		lp = makebootarea(bootarea, &lab, f);
 		if (!(t = fopen(argv[1], "r")))
 			err(4, "%s", argv[1]);
-		if (getasciilabel(t, lp))
-			error = writelabel(f, bootarea, lp);
+		if (getasciilabel(t, &lab) == 0)
+			break;
+		lp = makebootarea(bootarea, &lab, f);
+		*lp = lab;
+		error  = writelabel(f, bootarea, lp);
 		break;
 
 	case SETWRITEABLE:

>Audit-Trail:
>Unformatted: