From Andre.Albsmeier@mchp.siemens.de  Tue Sep 30 08:58:09 1997
Received: from david-relay.siemens.de (david-relay.siemens.de [139.23.36.13])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id IAA03377
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 Sep 1997 08:58:08 -0700 (PDT)
Received: from salomon.mchp.siemens.de (salomon.siemens.de [139.23.33.13])
	by david-relay.siemens.de (8.8.7/8.8.7) with ESMTP id RAA27094
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 Sep 1997 17:55:07 +0200 (MET DST)
Received: from curry.mchp.siemens.de (daemon@curry.mchp.siemens.de [146.180.31.23])
	by salomon.mchp.siemens.de (8.8.7/8.8.5) with ESMTP id RAA16557
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 Sep 1997 17:58:03 +0200 (MDT)
Received: (from daemon@localhost)
	by curry.mchp.siemens.de (8.8.7/8.8.7) id RAA02366
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 Sep 1997 17:58:03 +0200 (MET DST)
Message-Id: <199709301557.RAA03366@curry.mchp.siemens.de>
Date: Tue, 30 Sep 1997 17:57:58 +0200 (CEST)
From: Andre Albsmeier <Andre.Albsmeier@mchp.siemens.de>
To: FreeBSD-gnats-submit@freebsd.org
Subject: bug in wd.c when using devfs
X-Send-Pr-Version: 3.2

>Number:         4660
>Category:       kern
>Synopsis:       bug in wd.c when using devfs
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 30 09:00:00 PDT 1997
>Closed-Date:    Sun Oct 19 20:22:32 MEST 1997
>Last-Modified:  Sun Oct 19 20:23:43 MEST 1997
>Originator:     Andre Albsmeier
>Release:        FreeBSD 2.2-STABLE i386
>Organization:
>Environment:

	I suspect all systems, but at least 2.2-STABLE

>Description:

When using devfs on 2.2-STABLE with 3 IDE drives, I saw that wd2
doesn't appear in /devs. Instead, when booting, the kernel prints
a message that wd0 (yes, wd0) is already present. IMHO this is due
to a bug in wd.c: When calling the devfs routines, the variable unit
is passed instead of lunit. As far as I am correct, unit refers to
the physical unit on the controller wdc which is 0 for wd2. And
lunit refers to the logical unit which is 2 for wd2. So the kernel
thinks, wd0 should be registered once more and complains. I have
attached my changes to wd.c which makes it work.

Maybe, this applies to 2.1 and current, too.

And maybe, I am also completely wrong :-)

*** wd.c.ORI	Sun Sep 21 14:38:19 1997
--- wd.c	Sun Sep 21 14:50:16 1997
***************
*** 478,492 ****
  			wdtimeout(du);
  
  #ifdef DEVFS
! 			mynor = dkmakeminor(unit, WHOLE_DISK_SLICE, RAW_PART);
  			du->dk_bdev = devfs_add_devswf(&wd_bdevsw, mynor,
  						       DV_BLK, UID_ROOT,
  						       GID_OPERATOR, 0640,
! 						       "wd%d", unit);
  			du->dk_cdev = devfs_add_devswf(&wd_cdevsw, mynor,
  						       DV_CHR, UID_ROOT,
  						       GID_OPERATOR, 0640,
! 						       "rwd%d", unit);
  #endif
  
  			if (dk_ndrive < DK_NDRIVE) {
--- 478,492 ----
  			wdtimeout(du);
  
  #ifdef DEVFS
! 			mynor = dkmakeminor(lunit, WHOLE_DISK_SLICE, RAW_PART);
  			du->dk_bdev = devfs_add_devswf(&wd_bdevsw, mynor,
  						       DV_BLK, UID_ROOT,
  						       GID_OPERATOR, 0640,
! 						       "wd%d", lunit);
  			du->dk_cdev = devfs_add_devswf(&wd_cdevsw, mynor,
  						       DV_CHR, UID_ROOT,
  						       GID_OPERATOR, 0640,
! 						       "rwd%d", lunit);
  #endif
  
  			if (dk_ndrive < DK_NDRIVE) {
	

>How-To-Repeat:

	Make a machine with at least 3 IDE drives and enable devfs.

>Fix:
	
	see above

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: joerg 
State-Changed-When: Sun Oct 19 20:22:32 MEST 1997 
State-Changed-Why:  

Fix applied by sos in rev 1.141 of wd.c, but he forgot to metnion 
and close the PR. 
>Unformatted:
