| 1 |
/*********************************************************************** |
| 2 |
* Code listing from "Advanced Linux Programming," by CodeSourcery LLC * |
| 3 |
* Copyright (C) 2001 by New Riders Publishing * |
| 4 |
* See COPYRIGHT for license information. * |
| 5 |
***********************************************************************/ |
| 6 |
|
| 7 |
#include <fcntl.h> |
| 8 |
#include <linux/cdrom.h> |
| 9 |
#include <sys/ioctl.h> |
| 10 |
#include <sys/stat.h> |
| 11 |
#include <sys/types.h> |
| 12 |
#include <unistd.h> |
| 13 |
|
| 14 |
int main (int argc, char* argv[]) |
| 15 |
{ |
| 16 |
/* Open a file descriptor to the device specified on the command line. */ |
| 17 |
int fd = open (argv[1], O_RDONLY); |
| 18 |
/* Eject the CD-ROM. */ |
| 19 |
ioctl (fd, CDROMEJECT); |
| 20 |
/* Close the file descriptor. */ |
| 21 |
close (fd); |
| 22 |
|
| 23 |
return 0; |
| 24 |
} |