summaryrefslogtreecommitdiff
path: root/extra/eject/eject-2.1.5-unlock.patch
diff options
context:
space:
mode:
Diffstat (limited to 'extra/eject/eject-2.1.5-unlock.patch')
-rw-r--r--extra/eject/eject-2.1.5-unlock.patch59
1 files changed, 59 insertions, 0 deletions
diff --git a/extra/eject/eject-2.1.5-unlock.patch b/extra/eject/eject-2.1.5-unlock.patch
new file mode 100644
index 000000000..d554f9bdf
--- /dev/null
+++ b/extra/eject/eject-2.1.5-unlock.patch
@@ -0,0 +1,59 @@
+diff -pur eject-orig/eject.c eject/eject.c
+--- eject-orig/eject.c 2006-02-11 04:54:38.000000000 +0300
++++ eject/eject.c 2011-08-11 13:12:16.568112725 +0400
+@@ -527,6 +527,25 @@ static void CloseTray(int fd)
+ }
+
+ /*
++ * Unlock tray using CDROM_LOCKDOOR ioctl.
++ * New kernels doesn't automatically unlock tray before ejecting,
++ * and the new udev automatically locks it.
++ */
++static int UnlockCdrom(int fd)
++{
++ int status = -1;
++
++ if (v_option)
++ printf(_("%s: unlocking tray using CDROM_LOCKDOOR ioctl\n"), programName);
++
++ status = ioctl(fd, CDROM_LOCKDOOR, 0);
++ if (v_option && status != 0)
++ printf(_("%s: CDROM_LOCKDOOR ioctl failed\n"), programName);
++
++ return (status == 0);
++}
++
++/*
+ * Toggle tray.
+ *
+ * Written by Benjamin Schwenk <benjaminschwenk@yahoo.de> and
+@@ -543,6 +562,8 @@ static void ToggleTray(int fd)
+
+ #ifdef CDROMCLOSETRAY
+
++ UnlockCdrom(fd);
++
+ /* Try to open the CDROM tray and measure the time therefor
+ * needed. In my experience the function needs less than 0.05
+ * seconds if the tray was already open, and at least 1.5 seconds
+@@ -566,7 +587,11 @@ static void ToggleTray(int fd)
+ * was already open. In this case, close it now. Else the tray was
+ * closed before. This would mean that we are done. */
+ if (time_elapsed < TRAY_WAS_ALREADY_OPEN_USECS)
++ {
++ if (v_option)
++ printf(_("%s: CD-ROM tray was already open, closing it\n"), programName);
+ CloseTray(fd);
++ }
+
+ #else
+ fprintf(stderr, _("%s: CD-ROM tray toggle command not supported by this kernel\n"), programName);
+@@ -681,7 +706,7 @@ static void ListSpeedCdrom(const char *f
+ static int EjectCdrom(int fd)
+ {
+ int status = -1;
+-
++ UnlockCdrom(fd);
+ #if defined(CDROMEJECT)
+ status = ioctl(fd, CDROMEJECT);
+ #elif defined(CDIOCEJECT)