From 7e441d3694c9e30c23f432bebfefdcd6910f871c Mon Sep 17 00:00:00 2001 From: Erik Troan Date: Mon, 31 Jul 2000 20:28:26 +0000 Subject: added eject command to /tmp/cleanup --- loader/init.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'loader') diff --git a/loader/init.c b/loader/init.c index 5c4d5d892..ee2779d11 100644 --- a/loader/init.c +++ b/loader/init.c @@ -410,7 +410,7 @@ int handleCleanup(void) { int i; char buf[4096]; int fd; - int loopfd; + int loopfd, ejectfd; char * start, * end; fd = open("/tmp/cleanup", O_RDONLY, 0); @@ -452,6 +452,20 @@ int handleCleanup(void) { if (umount(start) < 0) printf(" failed (%d)", errno); printf("\n"); + } else if (!strncmp(start, "eject ", 6)) { + start += 6; + while (isspace(*start) && start < end) start++; + if (start == end) return 1; + + printf("ejecting %s...", start); + if ((ejectfd = open(start, O_RDONLY | O_NONBLOCK, 0)) >= 0) { + if (ioctl(ejectfd, CDROMEJECT, 0)) + printf("eject failed %d ", errno); + + close(ejectfd); + } + + printf("\n"); } start = end + 1; -- cgit