Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Sep 2007 13:45:47 +0800 (KRAST)
From:      Eugene Grosbein <eugen@grosbein.pp.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   kern/116538: [fdc] [patch] reintroduce FD_NO_CHLINE flag for fdc(4)
Message-ID:  <200709220545.l8M5jlrt002238@grosbein.pp.ru>
Resent-Message-ID: <200709220550.l8M5o1Ge067039@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         116538
>Category:       kern
>Synopsis:       [fdc] [patch] reintroduce FD_NO_CHLINE flag for fdc(4)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Sep 22 05:50:01 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Eugene Grosbein
>Release:        FreeBSD 6.2-STABLE i386
>Organization:
Svyaz-Service JSC
>Environment:
System: FreeBSD grosbein.pp.ru 6.2-STABLE FreeBSD 6.2-STABLE #2: Sun Sep 16 16:54:23 KRAST 2007 eu@grosbein.pp.ru:/home/obj/usr/local/src/sys/DADV i386

>Description:
	Workaround for floppy disk drives missing media change indication
	support (FD_NO_CHLINE flag for fdc(4)) was removed in 2001 after
	media change detection was fixed in fdc(4) and believed to work
	reliably.

	This is no longer true these days when new motherboards
	have FDD controlles that miss Configuration Control Register,
	so fdc(4) cannot detect media change. We need FD_NO_CHLINE flag
	again until fdc(4) fixed. See commit log message for
	sys/dev/fdc/fdc.c,v.1.307.2.4 for additional details.

>How-To-Repeat:

	Take motherboard which FDD controller does not have CCR.
	Modern Intel desktop motherboards fit, also you may get
	more examples from
	http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/103841

	Boot kernel with fdc(4) compiled in or kldload fdc.ko
	when there is write-protected floppy in the drive.
	Then do:

echo -n > /dev/fd0

	You'll get 'Read-only file system' error.
	Remove disk from the drive, uprotect it, insert back
	and repeat 'echo -n > /dev/fd0'. You'll get the same error
	because media change detection does not work.

	For real example replace 'echo -n' with 'fdformat' that also
	opens device for writing. So it's impossible to format floppy drive
	until reboot if there was write-protected disk in the drive
	and the boot time.

	Note that fdc(4) man page still mentions 0x10 flag that 
	was ever used as valuse for FD_NO_CHLINE flag it does not exist
	in the code many years. More, the value 0x10 is now used by fdc(4)
	internally for other means and we need to choose another value.

>Fix:

--- share/man/man4/fdc.4.orig	2007-09-16 16:23:27.000000000 +0800
+++ share/man/man4/fdc.4	2007-09-16 16:23:34.000000000 +0800
@@ -101,7 +101,7 @@
 the driver.
 To indicate a drive that does not have the changeline support,
 this can be overridden using the per-drive device flags value of
-.Ar 0x10
+.Ar 0x40
 (causing each call to
 .Xr open 2
 to perform the autodetection).
@@ -98,6 +98,8 @@
 				 * and fd1 */
 #define FD_NO_PROBE	0x20	/* don't probe drive (seek test), just
 				 * assume it is there */
+#define FD_NO_CHLINE	0x40	/* drive does not support changeline
+				* aka. unit attention */
 
 /*
  * Things that could conceiveably considered parameters or tweakables
@@ -827,7 +829,8 @@
 
 	if (bp->bio_cmd & BIO_PROBE) {
 
-		if (!(fdin_rd(fdc) & FDI_DCHG) && !(fd->flags & FD_EMPTY))
+		if (!(fd->flags & FD_NO_CHLINE) &&
+		    !(fdin_rd(fdc) & FDI_DCHG) && !(fd->flags & FD_EMPTY))
 			return (fdc_biodone(fdc, 0));
 
 		/*


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200709220545.l8M5jlrt002238>