mirror of
https://gitdl.cn/https://github.com/chakralinux/core.git
synced 2025-02-03 22:27:15 +08:00
26 lines
667 B
Diff
26 lines
667 B
Diff
|
diff -Naur a/eject.c b/eject.c
|
||
|
--- a/eject.c 2011-12-30 02:44:09.786560448 +0000
|
||
|
+++ b/eject.c 2011-12-30 02:45:10.322889868 +0000
|
||
|
@@ -610,6 +610,21 @@
|
||
|
|
||
|
#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 needed.
|
||
|
* In my experience the function needs less than 0.05
|
||
|
* seconds if the tray was already open, and at least 1.5 seconds
|