Re: (Child) Locking the CD tray in software
From: Robert Wood (rob_at_rnwood.co.uk)
Date: 02/17/05
- Previous message: Bob Alexander: "KDE, GNOME, too intrusive for me !! Any alternatives ?"
- In reply to: Nazri Ramliy: "(Child) Locking the CD tray in software"
- Next in thread: Benedict Verheyen: "Re: (Child) Locking the CD tray in software"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: debian-user@lists.debian.org Date: Thu, 17 Feb 2005 08:01:35 +0000
On Wednesday 16 Feb 2005 18:01, Nazri Ramliy wrote:
> Hi list.
>
> My 15 months old amuses himself by opening and closing the CDROM tray
> on my box by pressing the eject button, waits for the tray to come
> out, then pushes it back in. He does this over and over.
>>cut
>
> Anybody know of any cd tools to keep the tray closed, i.e. ignoring
> the signal from the eject button?
This little bit of code sends the right ioctl to lock the tray of /dev/cdrom.
To compile save into a file "blah.c" and run gcc -o lock blah.c
#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/cdrom.h>
int main()
{
int fd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK);
if (fd == -1) { return -1; }
int lock = 1; # change to 1 to unlock
if (ioctl(fd, CDROM_LOCKDOOR, lock) == -1) { return -1; }
close(fd);
return 0;
}
Regards
Rob
-- Robert Wood <rob@rnwood.co.uk> http://www.rnwood.co.uk/ "If you can't make something good, make something look good." - Bill Gates -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
- Previous message: Bob Alexander: "KDE, GNOME, too intrusive for me !! Any alternatives ?"
- In reply to: Nazri Ramliy: "(Child) Locking the CD tray in software"
- Next in thread: Benedict Verheyen: "Re: (Child) Locking the CD tray in software"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]