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.

73 lines
2.1 KiB

  1. An eject functionality is rather handy on software controlled CD-ROM
  2. laptops (e.g. Apple ones) ...
  3. - Rene Rebe <rene@rocklinux.org>
  4. --- ./src/Makefile 1998-09-25 14:07:09.000000000 +0200
  5. +++ ./src/Makefile 2003-12-24 21:47:07.000000000 +0100
  6. @@ -66,7 +66,7 @@
  7. addstringstack.o expandtilde.o splitcmd.o addstringtostack.o \
  8. dokill.o dogrep.o dochown.o dosleep.o expandbackquotes.o dols.o \
  9. listdir.o listfile.o listoutput.o domknod.o dowc.o domount.o \
  10. - doumount.o dotouch.o
  11. + doumount.o dotouch.o doeject.o
  12. # entry point for making
  13. foo:
  14. --- ./src/doeject.c 1970-01-01 01:00:00.000000000 +0100
  15. +++ ./src/doeject.c 2003-12-24 22:03:09.000000000 +0100
  16. @@ -0,0 +1,33 @@
  17. +#include "kiss.h"
  18. +
  19. +#include <linux/cdrom.h>
  20. +
  21. +int doeject (Stringstack s)
  22. +{
  23. + register int
  24. + i;
  25. +
  26. + /* need at least one arg */
  27. + if (s.nstr == 1) {
  28. + error ("Bad commandline.\n"
  29. + "Usage: %s device\n", progname);
  30. + return (0);
  31. + }
  32. +
  33. + for (i = 1; i < s.nstr; i++) {
  34. + int status;
  35. + int fd = open(s.str[i], O_RDONLY|O_NONBLOCK);
  36. +
  37. + if (fd == -1) {
  38. + warning ("%s: unable to open %s\n", progname, s.str[i]);
  39. + continue;
  40. + }
  41. +
  42. + status = ioctl(fd, CDROMEJECT);
  43. + if (status != 0) {
  44. + error ("%s: failed\n");
  45. + }
  46. + close (fd);
  47. + }
  48. + return (0);
  49. +}
  50. --- ./src/kiss.c 1998-09-25 14:07:10.000000000 +0200
  51. +++ ./src/kiss.c 2003-12-24 21:34:31.000000000 +0100
  52. @@ -32,6 +32,7 @@
  53. { "chown", dochown, 0 },
  54. { "cp", docp, 0 },
  55. { "echo", doecho, 0 },
  56. + { "eject", doeject, 0 },
  57. { "exec", doexec, 1 },
  58. { "exit", doquit, 1 },
  59. { "grep", dogrep, 0 },
  60. --- ./srx/kiss.h 1998-09-25 14:07:10.000000000 +0200
  61. +++ ./src/kiss.h 2003-12-24 21:33:24.000000000 +0100
  62. @@ -194,6 +194,7 @@
  63. extern int dochown (Stringstack s);
  64. extern int docp (Stringstack s);
  65. extern int doecho (Stringstack s);
  66. +extern int doeject (Stringstack s);
  67. extern int doexec (Stringstack s);
  68. extern int dogrep (Stringstack s);
  69. extern int dohelp (Stringstack s);