Bug 24109

Summary: patch for making the atapi-cd drive waits for media
Product: Base System Reporter: alexandre12 <alexandre12>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description alexandre12 2001-01-06 16:20:01 UTC
If you use a command (such as mount) reading the ATAPI-CDROM device (eg /dev/acd0a) and the drive is still initializing the drive, the command will fail with a "device busy" message. This patch corrects the problem by making the command waiting for the drive to be ready.

Fix: apply this patch to your (4.2-RELEASE) kernel source tree : (when you are in /usr/src/sys)

** start **



note that since i don't own a scsi cdrom drive, i don't know if this works with it. 

note2: since i can't have cvs access, i can't patch directly with the current branch and the patch should work only with the src from 4.2-release.--7v6kTEd4ByyHSzq5Yui8L0xI2PnBuYoIJ32y3YrBXAGiaZHW
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- dev/ata/atapi-cd.c.orig	Sat Jan  6 16:41:54 2001
+++ dev/ata/atapi-cd.c	Sat Jan  6 16:44:39 2001
@@ -490,6 +490,12 @@
     struct acd_softc *cdp;
     int track = (dev->si_udev & 0x00ff0000) >> 16;
 
+    /*
+     * Close the CDROM door and waits for the media to be ready (patch by <alexandre12@mageos.com>)
+     */
+
+    acdioctl(dev, CDIOCCLOSE,0,flags, p);
+
     if (track) {
 	dev_t dev1 = makedev(major(dev), (dev->si_udev & 0xff0000ff));
 
** end **
How-To-Repeat: -
Comment 1 sos 2001-01-06 17:25:46 UTC
It seems alexandre12@mageos.com wrote:
> --- dev/ata/atapi-cd.c.orig	Sat Jan  6 16:41:54 2001
> +++ dev/ata/atapi-cd.c	Sat Jan  6 16:44:39 2001
> @@ -490,6 +490,12 @@
>      struct acd_softc *cdp;
>      int track = (dev->si_udev & 0x00ff0000) >> 16;
>  
> +    /*
> +     * Close the CDROM door and waits for the media to be ready (patch by <alexandre12@mageos.com>)
> +     */
> +
> +    acdioctl(dev, CDIOCCLOSE,0,flags, p);
> +
>      if (track) {
>  	dev_t dev1 = makedev(major(dev), (dev->si_udev & 0xff0000ff));

This will do the same, but is much cleaner:

--- atapi-cd.c  2000/10/25 06:43:02     1.48.2.6
+++ atapi-cd.c  2001/01/06 17:24:39
@@ -490,6 +490,8 @@
     struct acd_softc *cdp;
     int track = (dev->si_udev & 0x00ff0000) >> 16;
 
+    acd_eject(cdp, 1);
+
     if (track) {
        dev_t dev1 = makedev(major(dev), (dev->si_udev & 0xff0000ff));
 


But I'm not sure I want this to happen....

-Søren
Comment 2 Søren Schmidt freebsd_committer freebsd_triage 2001-01-07 16:49:15 UTC
State Changed
From-To: open->closed


The idea is good, but the implementation is not, see the patch I 
just put into -current, and which will be MFC'd soon..