blob: 30a96028fbd692f9233039f87b6e0cf2e356ef36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
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
|