I am having code for ejecting CDROM in my Linux system. This is code
*#include <sys/types.h>* *#include <sys/ioctl.h>* *#include <fcntl.h>* *#include <linux/cdrom.h>* *#include <stdio.h>* *#include <stdlib.h>* *int main( int argc, char **argv )* *{* * int cdrom;* * int i;*
* /* open device */* * if ((cdrom = open("/dev/cdrom",O_RDONLY | O_NONBLOCK)) < 0) {* * perror("open");* * exit(1);* * }*
* /* eject */* * if(ioctl(cdrom, CDROMEJECT) < 0) {* * printf("Could not eject cdrom tray\n");* * }*
* /* close device */* * close(cdrom);* * return 0;* *}* * *
CDROM is ejecting fine. ie its opening. But i don't know how to make my CDROM to close. Even if i run these program again its not closing. Can anyone help me..
Hi, On Sat, Nov 26, 2011 at 10:33 PM, Niamathullah sharief <newbiesha@gmail.com> wrote:
I am having code for ejecting CDROM in my Linux system. This is code
CDROM is ejecting fine. ie its opening. But i don't know how to make my CDROM to close. Even if i run these program again its not closing. Can anyone help me..
if (ioctl(cdrom, CDROMCLOSETRAY) < 0) { printf("Could not close cdrom tray\n"); } Regards.
participants (2)
-
Niamathullah sharief -
Prashant Shah