Date: Tue, 1 Jul 2003 00:29:21 +0200 (CEST) From: Benjamin Lutz <benlutz@datacomm.ch> To: FreeBSD-gnats-submit@FreeBSD.org Subject: kern/53941: [PATCH] ATAPI CD drives don't open the tray if they're empty Message-ID: <20030630222921.187CB12D262@maxlor.mine.nu> Resent-Message-ID: <200306302230.h5UMUE7q012125@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 53941 >Category: kern >Synopsis: [PATCH] ATAPI CD drives don't open the tray if they're empty >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jun 30 15:30:14 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Benjamin Lutz >Release: FreeBSD 5.1-RELEASE i386 >Organization: >Environment: System: FreeBSD merlin 5.1-RELEASE FreeBSD 5.1-RELEASE #6: Mon Jun 30 23:29:15 CEST 2003 root@merlin:/usr/src/sys/i386/compile/MERLIN i386 >Description: cdcontrol -f /dev/acd0 eject does not work if the cd drive is empty. This is not a bug in cdcontrol, but in the kernel's atapi-cd code. If the drive is empty, it seems that acd_start_stop(cdp, 0) always returns EBUSY. >How-To-Repeat: Type "cdcontrol -f /dev/acd0 eject". The cd tray opens if a cd is in the drive, but doesn't if there isn't one. >Fix: ----- DIFF START ----- --- atapi-cd.c.orig Mon Jun 30 23:42:47 2003 +++ atapi-cd.c Mon Jun 30 23:28:54 2003 @@ -1860,9 +1860,9 @@ { int error; - if ((error = acd_start_stop(cdp, 0)) == EBUSY) { - if (!close) - return 0; + error = acd_start_stop(cdp, 0); + + if (close && (error == EBUSY)) { if ((error = acd_start_stop(cdp, 3))) return error; acd_read_toc(cdp); @@ -1870,10 +1870,6 @@ cdp->flags |= F_LOCKED; return 0; } - if (error) - return error; - if (close) - return 0; acd_prevent_allow(cdp, 0); cdp->flags &= ~F_LOCKED; cdp->device->flags |= ATA_D_MEDIA_CHANGED; ---- DIFF END ---- I changed the code to ignore the error returned by acd_start_stop(cdp, 0) if we're trying to open the tray. Shouldn't matter much, since if the drive shouldn't be opened, it'll be locked. I tested this by using a cd burner and trying to open the tray while burning a CD. As expected it did not interrupt the burning process. Now, there's one thing that still bothers me a tiny bit... Maybe someone with more background knowledge can check this. My code now executes the following if we're trying to open the drive: acd_start_stop(cdp, 0); acd_prevent_allow(cdp, 0); cdp->flags &= ~F_LOCKED; cdp->device->flags |= ATA_D_MEDIA_CHANGED; return acd_start_stop(cdp, 2); In other words, cdp->flags and cdp->device->flags always get changed. As I said, this doesn't seem to matter on my machine, but maybe I'm overlooking something. >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030630222921.187CB12D262>