Re: EEK! Able to eject mounted Zip Disk (2.3.46/2.2.13)

From: Guest section DW (dwguest@win.tue.nl)
Date: Thu Mar 02 2000 - 20:42:05 EST


On Thu, Mar 02, 2000 at 07:04:11PM -0500, Ricky Beam wrote:
> On Thu, 2 Mar 2000, Guest section DW wrote:
> >I suspect the following:
> >- eject uses privately constructed SCSI commands to eject your disk
> > so you are doing this entirely behind the back of everybody,
> > the kernel does not know what you did.
>
> While true, I know of no utilities that will frame a scsi command to eject a
> disk -- it wouldn't work with IDE devices (I said _I_D_E_ not _A_T_A_P_I_)
> or propriatary interfaces. (The only thing I know about is my own creation
> and it does work with SCSI and ATAPI devices.)
>
> >- refusing to eject /dev/sdb4 is something eject.c does for you;
> > you might fix eject.c to also refuse /dev/sdb; send the patch
> > to the maintainer.
>
> Actually, the stock eject uses a standard ioctl() to eject media. The kernel
> maintains a use count and will not eject anything it thinks is still in use.

False.
Let me verify my conjecture. take a random eject: eject-2.0.2.
# grep 'ioctl(' *.c
eject.c: status = ioctl(fd, CDROMEJECT_SW, onOff);
eject.c: status = ioctl(fd, CDROM_SELECT_DISC, slot);
eject.c: status = ioctl(fd, CDROMLOADFROMSLOT, slot);
eject.c: status = ioctl(fd, CDROMCLOSETRAY);
eject.c: status = ioctl(fd, CDROMEJECT);
eject.c: status = ioctl(fd, SCSI_IOCTL_SEND_COMMAND, (void *)&scsi_cmd);
eject.c: status = ioctl(fd, SCSI_IOCTL_SEND_COMMAND, (void *)&scsi_cmd);
eject.c: status = ioctl(fd, SCSI_IOCTL_SEND_COMMAND, (void *)&scsi_cmd);
eject.c: status = ioctl(fd, FDEJECT);
eject.c: status = ioctl(fd, MTIOCTOP, &op);

You see, it indeed uses SCSI_IOCTL_SEND_COMMAND to do its deed.
My own version adds an
        ioctl(fd, BLKFLSBUF)
before ejecting.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Mar 07 2000 - 21:00:13 EST