mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.0 KiB

  1. Is is highly useful to have a software possibility to eject CD's for
  2. soft-eject CD-ROMs, like always in use in Apple hardware ...
  3. - Rene Rebe <rene@rocklinux.org>
  4. --- mine-0.15/gasgui.c 2003-09-27 15:20:58.000000000 +0200
  5. +++ mine-0.15-cdeject/gasgui.c 2003-12-26 17:38:38.880000000 +0100
  6. @@ -1,6 +1,6 @@
  7. /*
  8. * GEM MINE - The ROCK Linux Package Manager
  9. - * Copyright (C) 2002-2003 Clifford Wolf
  10. + * Copyright (C) 2002-2003 Clifford Wolf and Rene Rebe
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. @@ -23,6 +23,11 @@
  15. #include <unistd.h>
  16. #include <stdlib.h>
  17. +/* disk eject ... */
  18. +#include <fcntl.h>
  19. +#include <sys/ioctl.h>
  20. +#include <linux/cdrom.h>
  21. +
  22. #ifndef ROCKCFG_ID
  23. # define ROCKCFG_ID "1.7-x86-reference"
  24. #endif
  25. @@ -66,6 +71,23 @@
  26. );
  27. }
  28. +void eject_disk ()
  29. +{
  30. + int status;
  31. + int fd = open(sourcedev, O_RDONLY|O_NONBLOCK);
  32. +
  33. + if (fd == -1) {
  34. + printf ("Unable to open %s\n", sourcedev);
  35. + return;
  36. + }
  37. +
  38. + status = ioctl(fd, CDROMEJECT);
  39. + if (status != 0) {
  40. + printf ("Eject failed\n");
  41. + }
  42. + close (fd);
  43. +}
  44. +
  45. void remove_package(struct package *p, int just_print_commands)
  46. {
  47. char command[1024];
  48. @@ -138,14 +160,17 @@
  49. printf("Can't find: %s/%s/pkgs/%s.gem\n",
  50. sourcedir, config, p->name);
  51. printf("Not found on current disk: %s\n\n", p->name);
  52. - printf("Please insert Disk #%d and press ENTER.\n\n", p->disk_number);
  53. + printf("Please insert Disk #%d and press ENTER.\n\n",
  54. + p->disk_number);
  55. while (1) {
  56. - printf("Skip or Retry (default=Retry) > ");
  57. + printf("Skip, Retry or Eject disk (default=Retry) > ");
  58. fflush(stdout);
  59. fgets(command, 1024, stdin);
  60. if ( command[0] == 0 || command[0] == '\n' ||
  61. command[0] == 'r' || command[0] == 'R' ) break;
  62. if ( command[0] == 's' || command[0] == 'S' ) return NULL;
  63. + if ( command[0] == 'e' || command[0] == 'E' )
  64. + eject_disk ();
  65. }
  66. snprintf(gemfile, 1024, "%s/%s/pkgs/%s-%s.gem",