]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
eject: new auto_eject code from Fedora
authorKarel Zak <kzak@redhat.com>
Tue, 27 Mar 2012 15:47:40 +0000 (17:47 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 27 Mar 2012 15:47:40 +0000 (17:47 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/eject.c

index c37930177a42a023b842ecd3d94e80113c98adfc..a0f409fe998971a11eea3a32b20568fdd793bbac 100644 (file)
@@ -303,8 +303,18 @@ static char *find_device(const char *name)
 /* Set or clear auto-eject mode. */
 static void auto_eject(int fd, int on)
 {
-       if (ioctl(fd, CDROMEJECT_SW, on) != 0)
-               err(EXIT_FAILURE, _("CD-ROM auto-eject command failed"));
+       int status = -1;
+
+#if defined(CDROM_SET_OPTIONS) && defined(CDROM_CLEAR_OPTIONS)
+       if (on)
+               status = ioctl(fd, CDROM_SET_OPTIONS, CDO_AUTO_EJECT);
+       else
+               status = ioctl(fd, CDROM_CLEAR_OPTIONS, CDO_AUTO_EJECT);
+#else
+       errno = ENOSYS;
+#endif
+       if (status < 0)
+               err(EXIT_FAILURE,_("CD-ROM auto-eject command failed"));
 }
 
 /*