Doubt in CDROM Ejecting Program

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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..
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux