pci: don't do sanity check for missing pci bus, the check can misfire.
[minix.git] / commands / simple / eject.c
blob7bce8cd5528faf718358013690ef51f66058b0a2
1 /* eject 1.3 - Eject removable media Author: Kees J. Bot
2 * 11 Dec 1993
3 */
4 #define nil 0
5 #include <sys/types.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <errno.h>
9 #include <fcntl.h>
10 #include <string.h>
11 #include <sys/ioctl.h>
13 void fatal(char *label)
15 fprintf(stderr, "eject: %s: %s\n", label, strerror(errno));
16 exit(1);
19 void main(int argc, char **argv)
21 char *device;
22 int fd;
24 if (argc != 2) {
25 fprintf(stderr, "Usage: eject <device>\n");
26 exit(1);
29 device= argv[1];
31 /* Try to open it in whatever mode. */
32 fd= open(device, O_RDONLY);
33 if (fd < 0 && errno == EACCES) fd= open(device, O_WRONLY);
34 if (fd < 0) fatal(device);
36 /* Tell it to eject. */
37 if (ioctl(fd, DIOCEJECT, nil) < 0) fatal(device);
38 exit(0);