| idea take from opensuse |
| http://bugs.gentoo.org/261880 |
| |
| --- a/eject.c |
| +++ b/eject.c |
| @@ -576,6 +576,21 @@ static void ToggleTray(int fd) |
| |
| #ifdef CDROMCLOSETRAY |
| |
| + /* Ask the CDROM for info, otherwise fall back to manual */ |
| + switch (ioctl(fd, CDROM_DRIVE_STATUS)) { |
| + case CDS_TRAY_OPEN: |
| + CloseTray(fd); |
| + return; |
| + |
| + case CDS_NO_DISC: |
| + case CDS_DISC_OK: |
| + if (ioctl(fd, CDROMEJECT, 0) < 0) { |
| + perror("ioctl"); |
| + exit(1); |
| + } |
| + return; |
| + } |
| + |
| /* 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 |