NetBSD Problem Report #6325

Received: (qmail 7026 invoked from network); 18 Oct 1998 06:22:17 -0000
Message-Id: <199810180620.PAA25880@mirage.ceres.dti.ne.jp>
Date: Sun, 18 Oct 1998 15:20:57 +0900 (JST)
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@gnats.netbsd.org
Subject: [port-sparc] readdisklabel() should check a Sun disk label first
X-Send-Pr-Version: 3.95

>Number:         6325
>Category:       port-sparc
>Synopsis:       readdisklabel() should check a Sun disk label first
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-sparc-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 17 23:35:01 +0000 1998
>Closed-Date:    Fri Mar 24 22:34:20 +0000 2006
>Last-Modified:  Fri Mar 24 22:34:20 +0000 2006
>Originator:     Izumi Tsutsui
>Release:        1.3H current supped on October 17 1998
>Organization:
Izumi Tsutsui	Himeji City Japan
>Environment:
System: NetBSD legnum 1.3H NetBSD 1.3H (LEGNUM) #16: Sat Oct 17 17:47:33 JST 1998 tsutsui@legnum:/usr/src/sys/arch/sparc/compile/LEGNUM sparc

>Description:
Although writedisklabel() writes only a Sun disk label,
readdisklabel() is checking a NetBSD disk label first.
So if there is a valid NetBSD disk label on the disk,
kernel does not recognize that the Sun disk label is
modified.

>How-To-Repeat:
Connect a disk which has a valid NetBSD disklabel for sparc,
then modify and read the disklabel.

BTW, sparc is the only port which defines LABELOFFSET as 128,
so most disks do not have the valid NetBSD disklabels for sparc..

>Fix:
Check a Sun disk label first in readdisklabel() like sun3 does.

--- disksubr.c.orig	Sat Jun 20 20:29:36 1998
+++ disksubr.c	Sun Oct 18 14:47:59 1998
@@ -183,6 +183,11 @@
 	if (error)
 		return ("disk label read error");

+	/* Check for a Sun disk label (for PROM compatibility). */
+	slp = (struct sun_disklabel *) clp->cd_block;
+	if (slp->sl_magic == SUN_DKMAGIC)
+		return (disklabel_sun_to_bsd(clp->cd_block, lp));
+
 	/* Check for a NetBSD disk label. */
 	dlp = (struct disklabel *) (clp->cd_block + LABELOFFSET);
 	if (dlp->d_magic == DISKMAGIC) {
@@ -191,12 +196,6 @@
 		*lp = *dlp;
 		return (NULL);
 	}
-
-	/* Check for a Sun disk label (for PROM compatibility). */
-	slp = (struct sun_disklabel *) clp->cd_block;
-	if (slp->sl_magic == SUN_DKMAGIC)
-		return (disklabel_sun_to_bsd(clp->cd_block, lp));
-

 	bzero(clp->cd_block, sizeof(clp->cd_block));
 	return ("no disk label");
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->port-sparc-maintainer 
Responsible-Changed-By: fair 
Responsible-Changed-When: Mon Dec 28 09:31:30 PST 1998 
Responsible-Changed-Why:  
This PR is the responsibility of the portmaster, 
not the GNATS database administrator. 
State-Changed-From-To: open->feedback 
State-Changed-By: pk 
State-Changed-When: Sat Feb 5 05:17:00 PST 2000 
State-Changed-Why:  
Please provide more details on the failure mode of this problem. 
Specifically: the disklabel you start with + the way you get it on the 
disk initially. 

Note that writedisklabel() always writes both a NetBSD and a SunOS label, 
where the NetBSD label is embedded in a chunk of unused space within 
the SunOS label. 

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: pk@netbsd.org
Cc: gnats-bugs@gnats.netbsd.org, port-sparc-maintainer@netbsd.org
Subject: Re: port-sparc/6325
Date: Sun, 6 Feb 2000 01:18:38 +0900 (JST)

 In <20000205132818.872.qmail@mail.netbsd.org>
 pk@netbsd.org wrote:

 > Synopsis: readdisklabel() should check a Sun disk label first

 > Please provide more details on the failure mode of this problem.
 > Specifically: the disklabel you start with + the way you get it on the
 > disk initially.

 When I sent this PR, I was trying to mount a disk
 which was labeled on newsmips, which wrote only BSD disklabel.
 The disk could be mounted on macppc and sun3 but sparc could
 not mount it. Then I noticed LABELOFFSET on sparc was 128,
 even though LABELOFFSET of other ports (sun3, macppc etc.) was 64.
 I changed LABELOFFSET on sparc from 128 to 64 and made a kernel
 then it could mount the disk, but it could not write BSD disklabel
 properly.

 > Note that writedisklabel() always writes both a NetBSD and a SunOS label,
 > where the NetBSD label is embedded in a chunk of unused space within
 > the SunOS label.

 Now I notice writedisklabel() on sparc writes NetBSD label.
 I misunderstood. But there is still another problem.
 readdisklabel() uses LABELOFFSET to read NetBSD label,
 but writedisklabel() does not use LABELOFFSET.
 It uses offset 128 which is hardcoded in struct sun_disklabel
 in /sys/dev/sun/disklabel.h.

 I'm not sure why sparc and sun3 use different LABELOFFSET
 and whether BSD and Sun labels can co-exist when LABELOFFSET is 64,
 but NetBSD label at LABELOFFSET=128 would not be so useful anyway.
 I think it is better that sparc has the same LABELOFFSET with
 the other ports to share the same disks.
 ---
 Izumi Tsutsui
 tsutsui@ceres.dti.ne.jp
State-Changed-From-To: feedback->open 
State-Changed-By: fair 
State-Changed-When: Sun Apr 23 02:58:16 PDT 2000 
State-Changed-Why:  
Feedback was provided. 
State-Changed-From-To: open->closed
State-Changed-By: tsutsui@netbsd.org
State-Changed-When: Fri, 24 Mar 2006 22:34:20 +0000
State-Changed-Why:
sys/dev/sun/disksubr.c has fixed this.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.