Re: ATAPI CD-ROM locked at boot - 2.1.x

Gerd Knorr (kraxel@cs.tu-berlin.de)
Wed, 27 Nov 1996 20:06:14 +0100


In linux.dev.kernel you write:

>I have noticed that under 2.1.13 and earlier, my ATAPI CD-ROM (Mitusmi) is
>locked on boot-up. Mounting and un-mounting the drive fixes the problem, as
>long as there is a CD in the drive. If not, the only resolution is to
>reboot.

>Any patches yet?

Patch not, but a small eject program. Yes, this works even if there is no
CD in the drive, so you can avoid the reboot :-)

Gerd

---------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <linux/cdrom.h>
#include <linux/ucdrom.h>
#include <sys/ioctl.h>

char *devname = "/dev/cdrom";
int filehandle;

int
main(int argc, char *argv[])
{
if (argc > 1) devname = argv[1];

filehandle = open(devname,O_RDONLY | O_NONBLOCK);
if (filehandle == -1) {
perror("open");
exit(1);
}
if (0 != ioctl(filehandle,CDROMEJECT,0)) {
perror("ioctl eject");
exit(1);
}
exit(0);
}