void-packages/srcpkgs/eject/patches/eject-2.1.5-unlock.patch

60 lines
1.7 KiB
Diff

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)