Bug 19574

Summary: Let badsect recognize character device.
Product: Base System Reporter: clive <clive>
Component: i386Assignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.0-CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description clive 2000-06-29 10:00:01 UTC
	1) There's no block device in 5.0-C.
	2) But our sbin/badsect still look for block device.
	3) So why not fix the bug instead of buying a new hard drive ? :->
	4) Since on -current the only bug fingured out is about style(9),
	   I think it's ok to send-pr.

Fix: Apply patch.
How-To-Repeat: 
	1) Use any FreeBSD version that has no block device.
	2) Prepare a slice that doesn't store important data.
	3) Mkdir BAD within the slice root.
	4) badsect BAD [any sector number within this slice]

	*) If it's hard to figure out which sector is within the slice
	   test wanted, then prepare a hard drive that really has bad
	   sector. After some accessing, the bad sector number will be
	   reported on the console.
Comment 1 Bruce Evans 2000-07-01 16:34:19 UTC
On Thu, 29 Jun 2000 clive@CirX.ORG wrote:

> >Description:
> 
> 	1) There's no block device in 5.0-C.
> 	2) But our sbin/badsect still look for block device.

The patch leaves a lot of dead code related to block devices.

> Index: badsect.c
> ===================================================================
> RCS file: /home/ncvs/src/sbin/badsect/badsect.c,v
> retrieving revision 1.7
> diff -u -r1.7 badsect.c
> --- badsect.c	1999/08/28 00:12:28	1.7
> +++ badsect.c	2000/06/29 08:39:56
> @@ -118,11 +118,17 @@
>  		err(3, "%s", name);
>  	name_dir_end = name + strlen(name);
>  	while ((dp = readdir(dirp)) != NULL) {
> +		/*
> +		 * Opening of a mounted on device is not allowed.

Opening it read-only is now allowed.  Otherwise badsect wouldn't work at
all.

> +		 * Attempt to open the raw device instead.

All disk devices are now raw.

> +		 */
> +		if (dp->d_name[0] != 'r')
> +			continue ; 

The non-'r' name should be preferred.

statfs(2) should be used instead of the readdir() loop.

Bruce
Comment 2 Adrian Chadd freebsd_committer freebsd_triage 2000-11-09 10:51:32 UTC
State Changed
From-To: open->closed



Fixed in rev 1.8 of badsect.c (and MFCed to RELENG_4)