All pastes #715297 Raw Edit

Untitled

public text v1 · immutable
#715297 ·published 2007-09-26 05:04 UTC
rendered paste body
#include <sys/types.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/cdrom.h>

#define CDDEVICE "/dev/cdrom"           /* CDROM device */

int main(int argc,char **argv)
{
   int cdrom;                           
   if ((cdrom = open(CDDEVICE,O_RDONLY | O_NONBLOCK)) < 0) {
        perror("open");
        exit(1);
   }

   /* Use ioctl to send the CDROMEJECT command to the device
   */
   if (ioctl(cdrom,CDROMEJECT,0)<0) {
        perror("ioctl");
        exit(1);
   }

   close(cdrom);
}