2001-04-13 22:11:46

by Giuliano Pochini

[permalink] [raw]
Subject: I can eject a mounted CD



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.


2001-04-17 20:39:31

by Giuliano Pochini

[permalink] [raw]
Subject: Re: I can eject a mounted CD


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


2001-04-17 20:49:24

by Alan

[permalink] [raw]
Subject: Re: I can eject a mounted CD

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


2001-04-18 07:27:04

by Giuliano Pochini

[permalink] [raw]
Subject: Re: I can eject a mounted CD


>> > /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} ->)|(<-

2001-04-18 08:43:32

by Anthony D. Saxton

[permalink] [raw]
Subject: Re: I can eject a mounted CD

Giuliano Pochini wrote:

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

2001-04-18 09:10:16

by Tim Peeler

[permalink] [raw]
Subject: Re: I can eject a mounted CD

On Wed, Apr 18, 2001 at 09:25:43AM +0200, Giuliano Pochini wrote:
>
> >> > /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.

eject(1) line 36:

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


2001-04-18 09:18:48

by Giuliano Pochini

[permalink] [raw]
Subject: Re: I can eject a mounted CD


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

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} ->)|(<-

2001-04-18 12:21:54

by Alan

[permalink] [raw]
Subject: Re: I can eject a mounted CD

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

2001-04-18 12:27:24

by Jens Axboe

[permalink] [raw]
Subject: Re: I can eject a mounted CD

On Wed, Apr 18 2001, Alan Cox wrote:
> > > 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).

--
Jens Axboe

2001-04-18 13:03:56

by Giuliano Pochini

[permalink] [raw]
Subject: Re: I can eject a mounted CD


> 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} ->)|(<-

2001-04-18 13:06:56

by Jens Axboe

[permalink] [raw]
Subject: Re: I can eject a mounted CD

On Wed, Apr 18 2001, Giuliano Pochini wrote:
>
> > 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.

--
Jens Axboe

2001-04-18 13:25:28

by Jeremy Jackson

[permalink] [raw]
Subject: Re: I can eject a mounted CD

Giuliano Pochini wrote:

> >> >> 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.
>
> 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} ->)|(<-
>
> -
> 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

2001-04-18 21:03:51

by Guest section DW

[permalink] [raw]
Subject: Re: I can eject a mounted CD

On Wed, Apr 18, 2001 at 03:06:22PM +0200, Jens Axboe wrote:
> On Wed, Apr 18 2001, Giuliano Pochini wrote:

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

2001-04-18 21:37:27

by Jens Axboe

[permalink] [raw]
Subject: Re: I can eject a mounted CD

On Wed, Apr 18 2001, Guest section DW wrote:
> On Wed, Apr 18, 2001 at 03:06:22PM +0200, Jens Axboe wrote:
> > On Wed, Apr 18 2001, Giuliano Pochini wrote:
>
> > > > 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.

#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.

--
Jens Axboe

2001-04-19 07:50:34

by Giuliano Pochini

[permalink] [raw]
Subject: Re: I can eject a mounted CD


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

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} ->)|(<-

2001-04-19 21:36:55

by Tomas Jura

[permalink] [raw]
Subject: Re: I can eject a mounted CD

On Sat, Apr 14, 2001 at 12:12:28AM +0200, Giuliano Pochini wrote:
>
> 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
>

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


2001-04-20 07:50:35

by Giuliano Pochini

[permalink] [raw]
Subject: Re: I can eject a mounted CD


>> [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.

> 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} ->)|(<-

2001-04-20 17:45:55

by Bastien Nocera

[permalink] [raw]
Subject: Re: I can eject a mounted CD

On 20 Apr 2001 09:49:55 +0200, Giuliano Pochini wrote:
>
> >> [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

--
/Bastien Nocera
http://hadess.net