Skip to contentSkip to conversation

I can eject a mounted CD

DISCUSSION Giuliano Pochini 10 participants 18 messages Apr 13, 2001 – Apr 20, 2001

lore
Share & tools
lore
#0 lore raw

My fstab:

/dev/cdrom /mnt/cdrom iso9660
noauto,user,ro 0 0
/dev/cdrom /mnt/cdmac hfs
noauto,user,ro 0 0

I insert an apple cd (hfs) and mount /mnt/cdmac
If I type eject /mnt/cdrom the cd momes out but
df shows it's still mounted:

/dev/sr0 667978 667978 0 100% /mnt/cdmac

It's funny it don't let me eject cdmac

[Giu@Jay Giu]$ eject /mnt/cdmac/
umount: /dev/sr0 is not in the fstab (and you are not root)
eject: unmount of `/dev/sr0' failed

Bye.

#1 lore raw
Quoted 8 lines
Quoted 7 lines

My fstab:

/dev/cdrom /mnt/cdrom iso9660
noauto,user,ro 0 0
/dev/cdrom /mnt/cdmac hfs
noauto,user,ro 0 0

Quoted 6 lines

Change your fstab to read instead:

/dev/cdrom /mnt/cdrom auto noauto,user,ro 0 0

And remove the other cdrom listing. This will allow mounting any supported format and eliminate the duel support for one device.

That's not the point. The kernel should not allow someone to eject a mounted media.

Bye.

#2 lore raw
Quoted 7 lines
Quoted 4 lines

/dev/cdrom /mnt/cdrom auto noauto,user,ro 0 0

And remove the other cdrom listing. This will allow mounting any supported format and eliminate the duel support for one device.

That's not the point. The kernel should not allow someone to eject a mounted media.

rpm -e magicdev

#3 lore raw
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines

/dev/cdrom /mnt/cdrom auto noauto,user,ro 0 0

And remove the other cdrom listing. This will allow mounting any supported format and eliminate the duel support for one device.

That's not the point. The kernel should not allow someone to eject a mounted media.

rpm -e magicdev

Magicdev is not installed.
Ok, I'm the only one with this problem, I'll manage to find the bug by myself.

Bye.

    Giuliano Pochini ->)|(<- Shiny Network {AS6665} ->)|(<-
#4 lore raw
Quoted 4 lines
Quoted 1 line

rpm -e magicdev

Magicdev is not installed.
Ok, I'm the only one with this problem, I'll manage to find the bug by myself.

vmware and one or two other apps I've also seen do this. WHen you unlock the cdrom door as root you can unlock it even if a file system is mounted

#5 lore raw
Quoted 3 lines

vmware and one or two other apps I've also seen do this. WHen you unlock the cdrom door as root you can unlock it even if a file system is mounted

Right, so I'll check what eject(1) does. It might eject the disk even if it failed to unmount.

Bye.

    Giuliano Pochini ->)|(<- Shiny Network {AS6665} ->)|(<-
#6 lore raw
In reply to Alan Cox
Quoted 6 lines · Giuliano Pochini
Quoted 3 lines

vmware and one or two other apps I've also seen do this. WHen you unlock the cdrom door as root you can unlock it even if a file system is mounted

Right, so I'll check what eject(1) does. It might eject the disk even if it failed to unmount.

It shouldn't be able to. But check and see what happens.

Signature · 1 line
Jens Axboe
#7 lore raw
In reply to Alan Cox
Quoted 9 lines · Jens Axboe
Quoted 5 lines · Giuliano Pochini
Quoted 2 lines

vmware and one or two other apps I've also seen do this. WHen you unlock the cdrom door as root you can unlock it even if a file system is mounted

Right, so I'll check what eject(1) does. It might eject the disk even if it failed to unmount.

It shouldn't be able to. But check and see what happens.

(1) There are many different programs all called eject(1). I find at least four of them on this machine.

(2) I missed the start of the discussion; if this is a SCSI cdrom then many eject programs will use raw SCSI commands and the kernel does not try to parse raw SCSI commands so does not know that it is ejecting a mounted cdrom.

Andries

#8 lore raw
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

Right, so I'll check what eject(1) does. It might eject the disk even if it failed to unmount.

It shouldn't be able to. But check and see what happens.

Quoted 7 lines

(1) There are many different programs all called eject(1). I find at least four of them on this machine.

(2) I missed the start of the discussion; if this is a SCSI cdrom then many eject programs will use raw SCSI commands and the kernel does not try to parse raw SCSI commands so does not know that it is ejecting a mounted cdrom.

Yes, eject(1) (version 2.0.2, I don't remember the author) sends a SCSI command to eject the disk, but it's broken because it doesn't even try to umount the partition. It gets confused by my unusual fstab. I'll fix it as soon as I have some spare time.

Bye.

    Giuliano Pochini ->)|(<- Shiny Network {AS6665} ->)|(<-
#9 lore raw
In reply to Alan Cox
Quoted 12 lines · Guest section DW
Quoted 10 lines · Jens Axboe
Quoted 6 lines · Giuliano Pochini
Quoted 3 lines

vmware and one or two other apps I've also seen do this. WHen you unlock the cdrom door as root you can unlock it even if a file system is mounted

Right, so I'll check what eject(1) does. It might eject the disk even if it failed to unmount.

It shouldn't be able to. But check and see what happens.

Quoted 7 lines

(1) There are many different programs all called eject(1). I find at least four of them on this machine.

(2) I missed the start of the discussion; if this is a SCSI cdrom then many eject programs will use raw SCSI commands and the kernel does not try to parse raw SCSI commands so does not know that it is ejecting a mounted cdrom.

#2 can be done on any CDROM these days in fact, if eject uses CDROM_SEND_PACKET then it can _always_ open the tray as well regardless of mount status etc.

Signature · 1 line
Jens Axboe
#10 lore raw
In reply to Giuliano Pochini
Quoted 7 lines · Alan Cox
Quoted 4 lines
Quoted 1 line

rpm -e magicdev

Magicdev is not installed.
Ok, I'm the only one with this problem, I'll manage to find the bug by myself.

vmware and one or two other apps I've also seen do this. WHen you unlock the cdrom door as root you can unlock it even if a file system is mounted

yes, unlocking is definitely possible and then of course a manual eject. Only by root of course, however an ioctl eject should fail unless the cdrom really isn't busy (ie mounted or has other opens).

Signature · 1 line
Jens Axboe
#11 lore raw
In reply to Alan Cox
Quoted 6 lines · Giuliano Pochini
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

/dev/cdrom /mnt/cdrom auto noauto,user,ro 0 0

And remove the other cdrom listing. This will allow mounting any supported format and eliminate the duel support for one device.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

That's not the point. The kernel should not allow someone to eject a mounted media.

rpm -e magicdev

Magicdev is not installed.
Ok, I'm the only one with this problem, I'll manage to find the bug by myself.

eject(1) line 36:

If the device is currently mounted, it is unmounted before ejecting.

#12 lore raw
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

That's not the point. The kernel should not allow someone to eject a mounted media.

rpm -e magicdev

Quoted 7 lines
Quoted 2 lines

Magicdev is not installed.
Ok, I'm the only one with this problem, I'll manage to find the bug by myself.

eject(1) line 36:

If the device is currently mounted, it is unmounted before ejecting.

But it doesn't get unmounted. I eject the disk but I can still see and read the (cached) files !

Bye.

    Giuliano Pochini ->)|(<- Shiny Network {AS6665} ->)|(<-
#13 lore raw
Quoted 16 lines · Giuliano Pochini
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

That's not the point. The kernel should not allow someone to eject a mounted media.

rpm -e magicdev

Quoted 7 lines
Quoted 2 lines

Magicdev is not installed.
Ok, I'm the only one with this problem, I'll manage to find the bug by myself.

eject(1) line 36:

If the device is currently mounted, it is unmounted before ejecting.

But it doesn't get unmounted. I eject the disk but I can still see and read the (cached) files !

Quoted 8 lines

Bye.

    Giuliano Pochini ->)|(<- Shiny Network {AS6665} ->)|(<-

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

hdparm has an option controlling door locking; try locking it manually to see if the drive can even lock the door. then try setting it to match mounted/unmounted status of device; maybe it defaults to always unlocked for some reason.

hdparm -L 1 /dev/hdc

also try commenting out one of those fstab lines... may be confusing things. it should work the way you have it - you say mount /mnt/fstype and depending of fstype it picks the right line, but just for the sake of debugging try loosing one temporarily.

Cheers

#14 lore raw
In reply to Giuliano Pochini
Quoted 11 lines · Giuliano Pochini
Quoted 11 lines
Quoted 6 lines

My fstab:

/dev/cdrom /mnt/cdrom iso9660
noauto,user,ro 0 0
/dev/cdrom /mnt/cdmac hfs
noauto,user,ro 0 0

Change your fstab to read instead:

/dev/cdrom /mnt/cdrom auto noauto,user,ro 0 0

Quoted 7 lines
Quoted 2 lines

And remove the other cdrom listing. This will allow mounting any supported format and eliminate the duel support for one device.

That's not the point. The kernel should not allow someone to eject a mounted media.

Bye.

The kernel actually should allow a misconfigured system to behave as configured. Basically, your /etc/fstab is telling the kernel that you have two different devices occupying the same device address. In my case, I have two cdrom drives. With the original configuration, either one would mount to /mnt/cdrom. I changed /etc/fstab to identify the first drive as being at /dev/scd0, mounted to /mnt/cdrom and the second at /dev/scd1, mounted to /mnt/cd-r. Now I can have to independent drives. I could have just as easily setup the fstab as above, but I would not be able to use both drives.

One cannot expect any program to behave properly when configured improperly. Your kernel was behaving exactly as it had been programmed it to.

Anthony D. Saxton
LnA Concepts

#15 lore raw
In reply to Giuliano Pochini
Quoted 9 lines · Giuliano Pochini

My fstab:

/dev/cdrom              /mnt/cdrom              iso9660 noauto,user,ro 0 0
/dev/cdrom              /mnt/cdmac              hfs noauto,user,ro 0 0

I insert an apple cd (hfs) and mount /mnt/cdmac If I type eject /mnt/cdrom the cd momes out but df shows it's still mounted:

Quoted 7 lines

/dev/sr0 667978 667978 0 100% /mnt/cdmac

It's funny it don't let me eject cdmac

[Giu@Jay Giu]$ eject /mnt/cdmac/ umount: /dev/sr0 is not in the fstab (and you are not root) eject: unmount of `/dev/sr0' failed

I have similar problem with my swim3 floppy drive. Digging deeply I found that when I make do folowing steps then disk is lost and I have to reboot to get it back:

floppy = open(/dev/fd0);
ioctl( floopy, FDGETDRVPRM, &fdp) /* some *invalid* ioctl */ exit

Device is lost for root too. It is impossible to make any operation on this device anymore. And adding some debuging messages showed me that there is no problem in swim3 device driver. Still digging...(but have no much time to do this ;-( )

Hw&Sw: PowerPC G3 beige, kernel 2.4.3, devfs

Tomas

P.S. CC to me, I'm not in linux-kernel list. Only in linux-ppc

#16 lore raw
Quoted 3 lines
Quoted 3 lines

[Giu@Jay Giu]$ eject /mnt/cdmac/ umount: /dev/sr0 is not in the fstab (and you are not root) eject: unmount of `/dev/sr0' failed

Eject(1) is suid.

Quoted 3 lines

I have similar problem with my swim3 floppy drive. Digging deeply I found that when I make do folowing steps then disk is lost and I have to reboot to get it back:

I can't try this case because I haven't a floppy. When I ehect the cd I can recover it by unmounting it. But the CD is read-only. I can try with a MO, but the actual problem is that eject is buggy. It's not a kernel bug. I'll fix it...

Bye.

    Giuliano Pochini ->)|(<- Shiny Network {AS6665} ->)|(<-
#17 lore raw
Quoted 5 lines · Giuliano Pochini
Quoted 3 lines
Quoted 3 lines

[Giu@Jay Giu]$ eject /mnt/cdmac/ umount: /dev/sr0 is not in the fstab (and you are not root) eject: unmount of `/dev/sr0' failed

Eject(1) is suid.

No, it's not on proper installations.

$  ls -l /usr/bin/eject 
 17k -rwxr-xr-x    1 root     root          16k Jan 29 01:14
/usr/bin/eject

You need to have write access to the device to eject it.
I guess you use something like /dev/cdrom as the device for the mount point /mnt/cdmac, /dev/cdrom being a symlink to /dev/sr0. Try 'eject /dev/cdrom' you'll probably have more luck.

<snip>

Cheers

Signature · 2 lines
/Bastien Nocera
http://hadess.net