File grip-ejectfix.patch of Package grip

---------------------------------------------------------------------------

- correct location of #ifdef CDIOCEJECT, fixes door unlocking for eject

---------------------------------------------------------------------------
From: Bernhard Kaindl 
Fwd: esd vs. disk eject  
2005-10-16 11:28

Hi,

I ran into a problem of grip not being able to eject on Linux, while the
eject command was able to eject. After investigating, I found that at least
the Linux 2.6 kernels do not define CDIOEJECT, but with the order of
#ifdefs in grip-3.3.1/src/cddev.c, it would need to be defined to allow
that CDROM_LOCKDOOR, which is provided by Linux 2.6, to be checked.

What helped me was to move the #ifdef for it the the ioctl call where this
IOCTL is called, thus freeing the CDROM_LOCKDOOR #ifdef and ioctl from
this overlaying ifdef requirement, so the CDROM_LOCKDOOR ioctl is then
compiled whenever it's provided by the platform. As far as I could find
out CDIOEJECT is a FreeBSD ioctl and Linux uses CDROM_LOCKDOOR and
CDROMEJECT instead. The change causes that both were done on Linux
and my eject problems were solved.

I think the location of the ifdef must have been a mistake originally
since I cannot see much sense in require an FreeBSD define as precondition
for cheking if a Linux ioctls is available and can be called.

The attached patch contains the diff which I have been using since August
on two Linux machines where I had this problem. Besides moving the ifdef
in place, I also adds a missing "Eject failed" printout for the cases
that the CDROMEJECT may fail. With this g_print call, this error string
would be printed, togther the the errno, should the Linux kernel return
an error from CDROMEJECT call, to allow better diagnosis.

I propose to apply the attached patch to the next release.

Bernhard


--- grip-noeject/src/cddev.c	2004-04-15 20:23:09.000000000 +0200
+++ grip-doeject/src/cddev.c	2005-08-16 15:31:08.000000000 +0200
@@ -618,25 +618,29 @@
     return FALSE;
   }
 
-#ifdef CDIOCEJECT
   /*  always unlock door before an eject in case something else locked it  */
 #if defined(CDROM_LOCKDOOR)
   if(ioctl(disc->cd_desc,CDROM_LOCKDOOR,0)<0)
     g_print(_("Unlock failed: %d"), errno);
 #endif
+
 #ifdef CDIOCALLOW
   if(ioctl(disc->cd_desc,CDIOCALLOW)<0)
     g_print(_("Unlock failed: %d"),errno);
 #endif
 
+#ifdef CDIOCEJECT
   if(ioctl(disc->cd_desc,CDIOCEJECT)<0) {
     g_print(_("CDIOCEJECT"));
     return FALSE;
   }
 #endif
+
 #ifdef CDROMEJECT
-  if(ioctl(disc->cd_desc,CDROMEJECT)<0)
+  if(ioctl(disc->cd_desc,CDROMEJECT)<0) {
+    g_print(_("Eject failed: %d"),errno);
     return FALSE;
+  }
 #endif
    
   return TRUE;
openSUSE Build Service is sponsored by