From nobody@FreeBSD.org  Sat Jan  6 08:15:16 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id BC78B37B400
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  6 Jan 2001 08:15:15 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.1/8.11.1) id f06GFFm07093;
	Sat, 6 Jan 2001 08:15:15 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200101061615.f06GFFm07093@freefall.freebsd.org>
Date: Sat, 6 Jan 2001 08:15:15 -0800 (PST)
From: alexandre12@mageos.com
Sender: nobody@FreeBSD.org
To: freebsd-gnats-submit@FreeBSD.org
Subject: patch for making the atapi-cd drive waits for media
X-Send-Pr-Version: www-1.0

>Number:         24109
>Category:       kern
>Synopsis:       patch for making the atapi-cd drive waits for media
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 06 08:20:01 PST 2001
>Closed-Date:    Sun Jan 7 08:49:15 PST 2001
>Last-Modified:  Sun Jan 07 08:50:13 PST 2001
>Originator:     alexandre j
>Release:        4.2
>Organization:
-
>Environment:
-
>Description:
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.
>How-To-Repeat:
-
>Fix:
apply this patch to your (4.2-RELEASE) kernel source tree : (when you are in /usr/src/sys)

** start **

--- 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 **

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. 


>Release-Note:
>Audit-Trail:

From: Soren Schmidt <sos@freebsd.dk>
To: alexandre12@mageos.com
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: kern/24109: patch for making the atapi-cd drive waits for media
Date: Sat, 6 Jan 2001 18:25:46 +0100 (CET)

 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....
 
 -Sren
 
State-Changed-From-To: open->closed 
State-Changed-By: sos 
State-Changed-When: Sun Jan 7 08:49:15 PST 2001 
State-Changed-Why:  

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


http://www.freebsd.org/cgi/query-pr.cgi?pr=24109 
>Unformatted:
