Subject: bin/2719: 'badsect' accesses wrong device (doesn't work that way)
To: None <gnats-bugs@NetBSD.ORG>
From: Phillip F Knaack <>
List: netbsd-bugs
Date: 08/29/1996 11:58:20
>Number:         2719
>Category:       bin
>Synopsis:       'badsect' accesses wrong device (doesn't work that way)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 29 13:20:01 1996
>Originator:     Phillip F Knaack
	Information Development for Extension Audiences (IDEA)
	Iowa State University Extension
>Release:        1.2_ALPHA
System: NetBSD 1.2_ALPHA NetBSD 1.2_ALPHA (NCREMP) #11: Fri Jun 21 11:12:44 CDT 1996 i386
	Basically stock 1.2_ALPHA machine.

	'badsect' uses the directory you specify to locate the actual block
device in /dev of the mounted filesystem. however, it tries to read from the
block device to determine if the block you specified is in use or not (rather
than the raw device, you can't access the block device when a filesystem is
	(/dev/wd1e is mounted on /local/disk1, assume bad block is 17462)
	# badsect /local/disk1/BAD 17462
	/dev/wd1e: device busy

	The following patch appears to fix it perfectly (after locating the
device node, tack an extra 'r' in front of the name to get the char device).

*** /local/disk1/src/sbin/badsect/badsect.c     Fri Oct 13 20:08:15 1995
--- /usr/src/sbin/badsect/badsect.c     Thu Aug 29 11:46:20 1996
*** 125,130 ****
--- 125,137 ----
+       /*
+        * we've found the block device, but since the filesystem 
+        * is mounted, we must write to the raw (character) device
+        * instead.
+        */
+       name[5] = 'r';
+       strcpy(&name[6], dp->d_name);
        if (dp == NULL) {
                printf("Cannot find dev 0%o corresponding to %s\n",