Bug 13628 - CD-ROM is not locked if a volume is mounted.
Summary: CD-ROM is not locked if a volume is mounted.
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: magicdev
Version: 7.1
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Owen Taylor
QA Contact:
URL:
Whiteboard: Florence RC-1
: 15520 18680 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-07-09 17:57 UTC by Sam Varshavchik
Modified: 2008-05-01 15:37 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2001-02-07 23:23:12 UTC
Embargoed:


Attachments (Terms of Use)

Description Sam Varshavchik 2000-07-09 17:57:08 UTC
I can always eject a CD in beta3, even if the volume is mounted.

I have two boxes with two identical CD-ROM drives:

Host: scsi0 Channel: 00 Id: 04 Lun: 00
  Vendor: YAMAHA   Model: CRW8424S         Rev: 1.0d
  Type:   CD-ROM                           ANSI SCSI revision: 02

and

Host: scsi0 Channel: 00 Id: 03 Lun: 00
  Vendor: YAMAHA   Model: CRW8424S         Rev: 1.0d
  Type:   CD-ROM                           ANSI SCSI revision: 02


The first box runs RH 6.2, kernel 2.2.16-3, onboard SCSI controller:

  Bus  0, device   6, function  0:
    SCSI storage controller: Adaptec AIC-7890/1 (rev 0).
      Medium devsel.  Fast back-to-back capable.  BIST capable.  IRQ 9. 
Master Capable.  Latency=32.  Min Gnt=39.Max Lat=25.
      I/O at 0xd000 [0xd001].
      Non-prefetchable 64 bit memory at 0xe0800000 [0xe0800004].

The second box has beta3 installed, uses a PCI controller:

  Bus  0, device  15, function  0:
    SCSI storage controller: Adaptec AHA-2940U2 (rev 0).
      Medium devsel.  Fast back-to-back capable.  BIST capable.  IRQ 10. 
Master Capable.  Latency=32.  Min Gnt=39.Max Lat=25.
      I/O at 0xa800 [0xa801].
      Non-prefetchable 64 bit memory at 0xec000000 [0xec000004].

This is basically the PCI version of the same AIC78xx controller.

The RH 6.2 box uses autofs, and I can NEVER eject a CD while its mounted. 
The beta3 box ALWAYS lets me eject a CD, no matter what.

Comment 1 Henri Schlereth 2000-07-16 23:00:41 UTC
I can verify this with 6.2 as well, but it only seems to do this with IDE drives. A Sony CDU33a locks just fine. I have a compaq
32x and a BCD-8X 1996-09-04, ATAPI CDROM drive that do not lock under 6.2.

Comment 2 Sam Varshavchik 2000-07-22 03:01:03 UTC
Verified that the problem still exists in beta4.

Comment 3 Sam Varshavchik 2000-07-29 22:03:23 UTC
Pinstripe still ejects a mounted CD.


Comment 4 Sam Varshavchik 2000-08-01 16:18:02 UTC
Another pinstripe datapoint: pinstripe install on a laptop with an IDE CDROM
*does* properly lock the CD when it's mounted, and it cannot be ejected.

Looks like a SCSI driver issue.



Comment 5 Henri Schlereth 2000-08-01 18:29:29 UTC
Evidently works with IDE CD-Roms now.

Comment 6 Christian Rose 2000-08-05 22:40:23 UTC
*** Bug 15520 has been marked as a duplicate of this bug. ***

Comment 7 David Balažic 2000-08-07 08:17:05 UTC
Everything is OK until magicdev mounts ( automatically ) a CD.
After that the CD drive is never locked.
Mounted or unmounted. magicdev running or not.
my cd is /dev/hdc ( IDE secondary master )

Comment 8 David Balažic 2000-08-30 07:57:40 UTC
Here is what happens. When magicdev is run, it runs the following
function ( in magicdev/magicmedia.c ) :
-----
static void
cdrom_ioctl_frenzy(int fd)
{
  /* I have no idea what these ioctl's do - I just copied them from autorun ;-) 
*/
  ioctl(fd, CDROM_CLEAR_OPTIONS, CDO_LOCK|CDO_AUTO_CLOSE|CDO_AUTO_EJECT);
  ioctl(fd, CDROM_SET_OPTIONS, CDO_USE_FFLAGS|CDO_CHECK_TYPE);
#ifdef CDROM_LOCKDOOR
  ioctl(fd, CDROM_LOCKDOOR, 0);
#else
#warning "Need Linux kernel >= 2.2.4 to work with IDE."
#endif
}
-----
I think the comment says it all :-(

What happens is that it clears the CDO_LOCK flag of the CD drive,
which means that the drive is no more automatically locked when
mounted.
To fix this, do :
echo 0 > /proc/sys/dev/cdrom/lock
echo 1 > /proc/sys/dev/cdrom/lock

I think the magicdev people should think first and code later !

A quick fix to the magicdev code is to leave the CDO_LOCK flag
alone , since magicdev doesn't watch for ejects and then
automatically unmount the media, so it is left mounted and ejected.
Maybe the entire cdrom_ioctl_frenzy() function could be deleted ?

I recomend leaving automounting to the automounter !
( with a short umount timeout )
!

Comment 9 David Balažic 2001-02-06 17:24:17 UTC
Bug still there in in Redhat Linux 7.0.
And in Florence beta2.
And in Redhat 7.1 ( isn't released yet , but wanna bet ? )

Comment 10 Preston Brown 2001-02-06 17:44:57 UTC
This bug is must fix for RC1.  Bero/Harald, you also need to check out the
autorun code and make sure it isn't doing something similarly stupid.

Comment 11 Glen Foster 2001-02-06 18:30:50 UTC
This defect is considered MUST-FIX for Florence Release-Candidate #1

Comment 12 Owen Taylor 2001-02-07 23:07:58 UTC
*** Bug 18680 has been marked as a duplicate of this bug. ***

Comment 13 Owen Taylor 2001-02-07 23:08:35 UTC
*** Bug 18680 has been marked as a duplicate of this bug. ***

Comment 14 Owen Taylor 2001-02-07 23:35:38 UTC
OK, here is a rewritten version of the function, leaving in
only one of the ioctls as a sanity check.

====
static void
cdrom_ioctl_frenzy(int fd)
{
	/* This is complete paranoia - if someone cleared CDO_USE_FFLAGS (meaning
	 * "ignore O_NONBLOCK"), and CDO_CHECK_TYPE is set, then things will
	 * be messed up.
	 */
	ioctl(fd, CDROM_SET_OPTIONS, CDO_USE_FFLAGS);

	/* Stuff in here before that I've turned off. OWT - 7 Feb. 2001
	 */
	/* Auto-close and auto-eject should work fine with magicdev, so leave them
	 * at their defaults 
	 */
#if 0	
	ioctl(fd, CDROM_CLEAR_OPTIONS, CDO_AUTO_CLOSE|CDO_AUTO_EJECT);
#endif	
	/* CDO_CHECK_TYPE breaks some crufy programs - it's cleared by default as
	 * a backwards-compat thing. It doesn't really help us to set it.
	 */
#if 0	
	ioctl(fd, CDROM_SET_OPTIONS, CDO_CHECK_TYPE);
#endif	

	/* We used to try and unlock the door here, but it could be considered
	 * bad form. The problem is that if programs don't notice the disk change,
	 * they can get very much confused. We could alternatively look for the media,
	 * unmount, then remount, but (as long as the user is running gmc) having
	 * having to right click on the icon and select eject isn't too bad.
	 */
#if 0	 
	ioctl(fd, CDROM_CLEAR_OPTIONS, CDO_LOCK);
#ifdef CDROM_LOCKDOOR
	ioctl(fd, CDROM_LOCKDOOR, 0);
#else
#warning "Need Linux kernel >= 2.2.4 to work with IDE."
#endif
#endif /* 0 */
}



Note You need to log in before you can comment on or make changes to this bug.