NetBSD Problem Report #54640

From tsutsui@ceres.dti.ne.jp  Tue Oct 22 13:14:45 2019
Return-Path: <tsutsui@ceres.dti.ne.jp>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id AD56F7A173
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 22 Oct 2019 13:14:45 +0000 (UTC)
Message-Id: <201910221314.x9MDEdtq028090@ceres.dti.ne.jp>
Date: Tue, 22 Oct 2019 22:14:39 +0900 (JST)
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Wrong RAW_PART in MAKEDEV(8) for hpcarm and zaurus
X-Send-Pr-Version: 3.95

>Number:         54640
>Category:       port-arm
>Synopsis:       Wrong RAW_PART in MAKEDEV(8) for hpcarm and zaurus
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    martin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 22 13:15:01 +0000 2019
>Closed-Date:    Wed Nov 06 17:12:52 +0000 2019
>Last-Modified:  Wed Nov 06 17:12:52 +0000 2019
>Originator:     Izumi Tsutsui
>Release:        NetBSD 8.1
>Organization:
>Environment:
System: NetBSD (GENERIC)
Architecture: arm
Machine: zaurus, hpcarm
>Description:
On NetBSD/hpcarm and NetBSD/zaurus, RAW_PART is 3 by historical reasons,
unlike other arm ports as evbarm and acorn32 etc.

However it looks MAKEDEV(8) scripts in etc.tgz from NetBSD/hpcarm 8.1
and NetBSD/zaurus 8.1 have incorrect RAW_PART number (2, not 3).

Then all disk device nodes without partition suffix have wrong minor,
so all commands that use opendisk(3) (like disklabel(8) and fdisk(8))
fail to open the raw device if disk name without /dev path is passed.

>How-To-Repeat:
disklabel(8) or fdisk(8) on NetBSD/zaurus 8.1:

---
# fdisk ld0
fdisk: cannot opendisk /dev/rld0: Device not configured
# disklabel ld0
disklabel: /dev/rld0: Device not configured
# disklabel /dev/rld0d
# /dev/rld0d:
type: ESDI
 :

---

MAKEDEV(8) in etc.tgz:

% ftp -o - http://cdn.netbsd.org/pub/NetBSD/NetBSD-8.1/zaurus/binary/sets/etc.tgz | tar -zxvf - ./dev/MAKEDEV
./dev/MAKEDEV
tar: ustar vol 1, 316 files, 4290560 bytes read, 0 bytes written in 1 secs (4290560 bytes/sec)
% grep -h -A 5 ro= dev/MAKEDEV
	ro=2
	mkdev ${name}${unit}	b $blk $(($unit * 8 + $ro))	640 $g_operator
	mkdev r${name}${unit}	c $chr $(($unit * 8 + $ro))	640 $g_operator

	mkdev ${name}${unit}a	b $blk $(($unit * 8 + 0))	640 $g_operator
	mkdev ${name}${unit}b	b $blk $(($unit * 8 + 1))	640 $g_operator
--
	ro=2
	mkdev ${name}${unit}	b $blk $(($unit * 8 + $ro))	640 $g_operator
	mkdev r${name}${unit}	c $chr $(($unit * 8 + $ro))	640 $g_operator

	mkdev ${name}${unit}a	b $blk $(($unit * 8 + 0))	640 $g_operator
	mkdev ${name}${unit}b	b $blk $(($unit * 8 + 1))	640 $g_operator
--
	ro=2
	mkdev ${name}${unit}	b $blk $(($unit * 16 + $ro))	640 $g_operator
	mkdev r${name}${unit}	c $chr $(($unit * 16 + $ro))	640 $g_operator

	mkdev ${name}${unit}a	b $blk $(($unit * 16 + 0))	640 $g_operator
	mkdev ${name}${unit}b	b $blk $(($unit * 16 + 1))	640 $g_operator
--
	ro=2
	mkdev ${name}${unit}	b $blk $(($unit * 8 + $ro))	640 $g_operator
	mkdev r${name}${unit}	c $chr $(($unit * 8 + $ro))	640 $g_operator

	mkdev ${name}${unit}a	b $blk $(($unit * 8 + 0))	640 $g_operator
	mkdev ${name}${unit}b	b $blk $(($unit * 8 + 1))	640 $g_operator
--
	ro=2
	rn=c

	mkdev ${name}${unit}	b $blk $(($unit * $doff + $ro))	640 $g_operator
	mkdev r${name}${unit}	c $chr $(($unit * $doff + $ro))	640 $g_operator

% 

>Fix:
I'm not sure how each etc.tgz for arm is built,
but check src/etc/MAKEDEV.awk and src/etc/MAKEDEV.tmpl?
 https://nxr.netbsd.org/xref/src/etc/MAKEDEV.awk?r=1.25#126

---
    126 	while (1) {
    127 		inc = top "arch/" incdir "/include/disklabel.h"
    128 		if (system("test -f '" inc "'") != 0) {
    129 			print "ERROR: can't find kernel include file '" inc "'" > "/dev/stderr"
    130 			exit 1
    131 		}
    132 		incdir = 0
    133 		while (getline < inc) {
    134 			if ($1 == "#define" && $2 == "MAXPARTITIONS")
    135 				diskpartitions = $3
    136 			else if ($1 == "#define" && $2 == "OLDMAXPARTITIONS")
    137 				diskbackcompat = $3
    138 			else if ($1 == "#define" && $2 == "RAW_PART")
    139 				RAWDISK_OFF = $3
---
Izumi Tsutsui

>Release-Note:

>Audit-Trail:
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: port-arm/54640: Wrong RAW_PART in MAKEDEV(8) for hpcarm and zaurus
Date: Sat, 2 Nov 2019 08:21:45 +0900

 quote from port-zaurus:

 ---
 The problem is not in kernels but MAKEDEV.awk script,
 so I think someone[TM] can easily fix it.

 ---
 	while (1) {
 		inc = top "arch/" incdir "/include/disklabel.h"
 		if (system("test -f '" inc "'") != 0) {
 			print "ERROR: can't find kernel include file '" inc "'" > "/dev/stderr"
 			exit 1
 		}
 		incdir = 0
 		while (getline < inc) {
 			if ($1 == "#define" && $2 == "MAXPARTITIONS")
 				diskpartitions = $3
 			else if ($1 == "#define" && $2 == "OLDMAXPARTITIONS")
 				diskbackcompat = $3
 			else if ($1 == "#define" && $2 == "RAW_PART")
 				RAWDISK_OFF = $3
 			else if ($1 == "#include" && 
 				 $2 ~ "<.*/disklabel.h>" &&
 				 $2 !~ ".*nbinclude.*")
 			{
 				# wrapper, switch to the right file
 				incdir = substr($2, 2)
 				sub("/.*", "", incdir)
 				break;
 			}
 ---

 It checks arch/zaurus/include/disklabel.h so it will find
 > #define RAW_PART	3
 line in it. However zaurus/include/disklabel.h also includes
 <arm/disklabel.h> and it also has the following definition:
 ---
 #ifndef RAW_PART
 #define RAW_PART		2	/* raw partition: XX?c */
 #endif
 ---

 The problem is MAKEDEV.awk cannot parse "#ifndef RAW_PART", isn't it?
 ---

Responsible-Changed-From-To: port-arm-maintainer->martin
Responsible-Changed-By: martin@NetBSD.org
Responsible-Changed-When: Sun, 03 Nov 2019 12:04:43 +0000
Responsible-Changed-Why:
Take


State-Changed-From-To: open->feedback
State-Changed-By: martin@NetBSD.org
State-Changed-When: Sun, 03 Nov 2019 12:04:43 +0000
State-Changed-Why:
I commited a fix - could you please test and request pullups?


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54640 CVS commit: src/etc
Date: Sun, 3 Nov 2019 12:03:36 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun Nov  3 12:03:36 UTC 2019

 Modified Files:
 	src/etc: MAKEDEV.awk

 Log Message:
 PR port-arm/54640: hack to work around conditional RAW_PART definition in
 arm/include/disklabel.h.

 Recognize this special case and skip lines between #ifndef RAW_PART and
 the next #endif.


 To generate a diff of this commit:
 cvs rdiff -u -r1.27 -r1.28 src/etc/MAKEDEV.awk

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: martin@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: port-arm/54640 (Wrong RAW_PART in MAKEDEV(8) for hpcarm and zaurus)
Date: Mon, 4 Nov 2019 00:42:51 +0900

 Works fine on NetBSD 8.1 tree. Thanks!

 ---
 % /s/src/obj.zaurus/tooldir.NetBSD-8.1-i386/bin/nbmake-zaurus MAKEDEV
 #    create  etc/MAKEDEV
 MACHINE=zaurus MACHINE_ARCH=earm  NETBSDSRCDIR=/s/src  /s/src/obj.zaurus/tooldir.NetBSD-8.1-i386/bin/nbawk -f /s/src/etc/MAKEDEV.awk /s/src/etc/MAKEDEV.tmpl  > MAKEDEV
 % grep ro= obj.zaurus/MAKEDEV
 	ro=3
 	ro=3
 	ro=3
 	ro=3
 	ro=3
 % /s/src/obj.hpcarm/tooldir.NetBSD-8.1-i386/bin/nbmake-hpcarm MAKEDEV
 #    create  etc/MAKEDEV
 MACHINE=hpcarm MACHINE_ARCH=earmv4  NETBSDSRCDIR=/s/src  /s/src/obj.hpcarm/tooldir.NetBSD-8.1-i386/bin/nbawk -f /s/src/etc/MAKEDEV.awk /s/src/etc/MAKEDEV.tmpl  > MAKEDEV
 % grep ro= obj.hpcarm/MAKEDEV
 	ro=3
 	ro=3
 	ro=3
 	ro=3
 	ro=3
 % /s/src/obj.shark/tooldir.NetBSD-8.1-i386/bin/nbmake-shark MAKEDEV
 #    create  etc/MAKEDEV
 MACHINE=shark MACHINE_ARCH=earmv4  NETBSDSRCDIR=/s/src  /s/src/obj.shark/tooldir.NetBSD-8.1-i386/bin/nbawk -f /s/src/etc/MAKEDEV.awk /s/src/etc/MAKEDEV.tmpl  > MAKEDEV
 % grep ro= obj.shark/MAKEDEV 
 	ro=2
 	ro=2
 	ro=2
 	ro=2
 	ro=2
 % 
 ---
 Izumi Tsutsui

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54640 CVS commit: [netbsd-9] src/etc
Date: Mon, 4 Nov 2019 14:35:57 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Mon Nov  4 14:35:57 UTC 2019

 Modified Files:
 	src/etc [netbsd-9]: MAKEDEV.awk

 Log Message:
 Pull up following revision(s) (requested by tsutsui in ticket #397):

 	etc/MAKEDEV.awk: revision 1.28

 PR port-arm/54640: hack to work around conditional RAW_PART definition in
 arm/include/disklabel.h.

 Recognize this special case and skip lines between #ifndef RAW_PART and
 the next #endif.


 To generate a diff of this commit:
 cvs rdiff -u -r1.26 -r1.26.2.1 src/etc/MAKEDEV.awk

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54640 CVS commit: [netbsd-8] src/etc
Date: Mon, 4 Nov 2019 14:37:42 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Mon Nov  4 14:37:42 UTC 2019

 Modified Files:
 	src/etc [netbsd-8]: MAKEDEV.awk

 Log Message:
 Pull up following revision(s) (requested by tsutsui in ticket #1423):

 	etc/MAKEDEV.awk: revision 1.28

 PR port-arm/54640: hack to work around conditional RAW_PART definition in
 arm/include/disklabel.h.

 Recognize this special case and skip lines between #ifndef RAW_PART and
 the next #endif.


 To generate a diff of this commit:
 cvs rdiff -u -r1.25 -r1.25.8.1 src/etc/MAKEDEV.awk

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: feedback->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Wed, 06 Nov 2019 17:12:52 +0000
State-Changed-Why:
Confirmed and pulled up.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.