1 /* eject 1.3 - Eject removable media Author: Kees J. Bot
11 #include <sys/ioctl.h>
13 void fatal(char *label
)
15 fprintf(stderr
, "eject: %s: %s\n", label
, strerror(errno
));
19 int main(int argc
, char **argv
)
25 fprintf(stderr
, "Usage: eject <device>\n");
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
);