diff options
Diffstat (limited to 'sys-apps/eject/files/eject-2.0.13-toggle.patch')
-rw-r--r-- | sys-apps/eject/files/eject-2.0.13-toggle.patch | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/sys-apps/eject/files/eject-2.0.13-toggle.patch b/sys-apps/eject/files/eject-2.0.13-toggle.patch new file mode 100644 index 000000000000..d095fad57e5c --- /dev/null +++ b/sys-apps/eject/files/eject-2.0.13-toggle.patch @@ -0,0 +1,101 @@ +Add support for toggling the cdrom. + +Patch by Patrik Kullman. + +http://bugs.gentoo.org/62612 + +Note: this requires the no-umount.patch be applied first +or the 4th and 5th hunks will fail. + +--- eject.c ++++ eject.c +@@ -51,6 +51,7 @@ + #endif /* GETOPTLONG */ + #include <errno.h> + #include <regex.h> ++#include <sys/time.h> + #include <sys/types.h> + #include <sys/stat.h> + #include <sys/ioctl.h> +@@ -79,6 +80,7 @@ + int r_option = 0; + int s_option = 0; + int t_option = 0; ++int T_option = 0; + int v_option = 0; + int x_option = 0; + int p_option = 0; +@@ -118,11 +120,13 @@ + " eject [-vn] -a on|off|1|0 [<name>] -- turn auto-eject feature on or off\n" + " eject [-vn] -c <slot> [<name>] -- switch discs on a CD-ROM changer\n" + " eject [-vn] -t [<name>] -- close tray\n" ++" eject [-vn] -T [<name>] -- toggle tray status (EXPERIMENTAL)\n" + " eject [-vn] -x <speed> [<name>] -- set CD-ROM max speed\n" + "Options:\n" + " -v\t-- enable verbose output\n" + " -n\t-- don't eject, just show device found\n" + " -r\t-- eject CD-ROM\n" ++" -T\t-- toggle tray status (EXPERIMENTAL)" + " -s\t-- eject SCSI device\n" + " -f\t-- eject floppy\n" + " -q\t-- eject tape\n" +@@ -135,7 +139,7 @@ + " -a --auto -c --changerslot -t --trayclose -x --cdspeed\n" + " -r --cdrom -s --scsi -f --floppy\n" + " -q --tape -n --noop -V --version\n" +-" -p --proc -m --no-unmount\n")); ++" -p --proc -m --no-unmount -T --toggletray\n")); + #endif /* GETOPTLONG */ + fprintf(stderr,_( + "Parameter <name> can be a device file or a mount point.\n" +@@ -149,7 +153,7 @@ + /* Handle command line options. */ + static void parse_args(int argc, char **argv, char **device) + { +- const char *flags = "a:c:x:dfhnqrstvVpm"; ++ const char *flags = "a:c:x:dfhnqrstTvVpm"; + #ifdef GETOPTLONG + static struct option long_options[] = + { +@@ -159,6 +163,7 @@ + {"auto", required_argument, NULL, 'a'}, + {"changerslot", required_argument, NULL, 'c'}, + {"trayclose", no_argument, NULL, 't'}, ++ {"toggletray", no_argument, NULL, 'T'}, + {"cdspeed", required_argument, NULL, 'x'}, + {"noop", no_argument, NULL, 'n'}, + {"cdrom", no_argument, NULL, 'r'}, +@@ -247,6 +252,9 @@ + case 't': + t_option = 1; + break; ++ case 'T': ++ T_option = 1; ++ break; + case 'v': + v_option = 1; + break; +@@ -909,6 +917,23 @@ + exit(0); + } + ++ /* handle -T option */ ++ if (T_option) { ++ if (v_option) ++ printf(_("%s: trying to eject\n"), programName); ++ fd = OpenDevice(deviceName); ++ struct timeval tv, tv2; ++ gettimeofday(&tv, NULL); ++ EjectCdrom(fd); ++ gettimeofday(&tv2, NULL); ++ if ((tv2.tv_sec - tv.tv_sec) < 1) { ++ if (v_option) ++ printf(_("%s: tray seems open, trying to close\n"), programName); ++ CloseTray(fd); ++ HandleXOption(deviceName); ++ exit(0); ++ } ++ } + /* handle -t option */ + if (t_option) { + if (v_option) |