[TriLUG] Laptop CD Drive
Brian Phelps
brphelps at ieee.org
Fri Mar 28 13:44:51 EDT 2008
Thanks Brian D for your help!
That works! Heres the code for anyone else who wants to fix this
annoying laptop cd-rom problem:
#include <sys/ioctl.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/cdrom.h>
#include <string.h>
#include <libgen.h>
int main(int argc, char* argv[]){
int fd;
fd = open("/dev/scd0", O_RDONLY);
ioctl(fd, CDROM_LOCKDOOR, 1);
printf("CD locked!\n");
return 0;
}
write into lock.c
execute:
gcc lock.c -o main && sudo ./lock
on the line:
ioctl(fd, CDROM_LOCKDOOR, 1);
change the 1 to a 0 to get the drive to unlock
This is now a keyboard shortcut w/ gksu on my laptop!
On Fri, 2008-03-28 at 10:53 -0400, Brian Daniels wrote:
> On Fri, Mar 28, 2008 at 08:49:28AM -0400, Brian Phelps wrote:
> > My laptop has a trigger-happy CD Drive button. Is there a way (command
> > or system call) to disable the drive from ejecting upon pressing the
> > button?
> >
> >
> > -Brian
> > --
> > <a href=http://electronjunkie.wordpress.com>Got e-?</a>
>
> There's a system call:
> http://www.mjmwired.net/kernel/Documentation/ioctl/cdrom.txt#773
> CDROM_LOCKDOOR
>
> that would work.
>
> hdparm has a -L option to set the drive's doorlock flag - don't know if that
> would work on a cd...
>
> --Brian
>
> --
> Be it thy course to busy giddy minds
> With foreign quarrels; that action, hence borne out,
> May waste the memory of the former days.
> Henry IV, Part 2
>
>
> Brian Daniels bitmage at pobox.com
> http://www.eviloverlord.net
--
<a href=http://electronjunkie.wordpress.com>Got e-?</a>
More information about the TriLUG
mailing list