|
|
Is is highly useful to have a software possibility to eject CD's for soft-eject CD-ROMs, like always in use in Apple hardware ...
- Rene Rebe <rene@rocklinux.org>
--- mine-0.15/gasgui.c 2003-09-27 15:20:58.000000000 +0200
+++ mine-0.15-cdeject/gasgui.c 2003-12-26 17:38:38.880000000 +0100
@@ -1,6 +1,6 @@
/* * GEM MINE - The ROCK Linux Package Manager - * Copyright (C) 2002-2003 Clifford Wolf
+ * Copyright (C) 2002-2003 Clifford Wolf and Rene Rebe
* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,11 @@
#include <unistd.h> #include <stdlib.h> +/* disk eject ... */
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <linux/cdrom.h>
+
#ifndef ROCKCFG_ID # define ROCKCFG_ID "1.7-x86-reference" #endif @@ -66,6 +71,23 @@
); } +void eject_disk ()
+{
+ int status;
+ int fd = open(sourcedev, O_RDONLY|O_NONBLOCK);
+
+ if (fd == -1) {
+ printf ("Unable to open %s\n", sourcedev);
+ return;
+ }
+
+ status = ioctl(fd, CDROMEJECT);
+ if (status != 0) {
+ printf ("Eject failed\n");
+ }
+ close (fd);
+}
+
void remove_package(struct package *p, int just_print_commands) { char command[1024]; @@ -138,14 +160,17 @@
printf("Can't find: %s/%s/pkgs/%s.gem\n", sourcedir, config, p->name); printf("Not found on current disk: %s\n\n", p->name); - printf("Please insert Disk #%d and press ENTER.\n\n", p->disk_number);
+ printf("Please insert Disk #%d and press ENTER.\n\n",
+ p->disk_number);
while (1) { - printf("Skip or Retry (default=Retry) > ");
+ printf("Skip, Retry or Eject disk (default=Retry) > ");
fflush(stdout); fgets(command, 1024, stdin); if ( command[0] == 0 || command[0] == '\n' || command[0] == 'r' || command[0] == 'R' ) break; if ( command[0] == 's' || command[0] == 'S' ) return NULL; + if ( command[0] == 'e' || command[0] == 'E' )
+ eject_disk ();
} snprintf(gemfile, 1024, "%s/%s/pkgs/%s-%s.gem",
|