[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: Help CD Lock
Vikas P forced the electrons to say:
> I need some help, How can I lock my CDROM Drive as Linux does when we mount
> CDROM, it can't be open even if we press Exit button on CDROM Drive Face.
> How Linux achieves this... Can we do same in C???
The ioctl to do this is CDROM_LOCKDOOR.
Here is sample code:
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/cdrom.h>
int main(void)
{
int fd = open ("/dev/cdrom", O_RDONLY);
ioctl (fd, CDROM_LOCKDOOR, 1);
return 0;
}
Change the third argument to ioctl() to 0 to unlock.
How linux implements this is a different matter. Look in
drivers/cdrom/cdrom.c for implementation details.
Binand