diff -pur eject-fedora/eject.c eject/eject.c --- eject-fedora/eject.c 2011-08-17 13:39:48.113669785 +0400 +++ eject/eject.c 2011-08-17 15:09:10.236431467 +0400 @@ -595,6 +595,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 and @@ -611,6 +630,8 @@ static void ToggleTray(int fd) #ifdef CDROMCLOSETRAY + UnlockCdrom(fd); + /* Try to open the CDROM tray and measure the time needed. * In my experience the function needs less than 0.05 * seconds if the tray was already open, and at least 1.5 seconds @@ -635,7 +656,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); @@ -750,7 +775,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)