rendered paste bodydiff --git a/tools/hal-storage-shared.c b/tools/hal-storage-shared.c
index 005abd4..e4f22eb 100644
--- a/tools/hal-storage-shared.c
+++ b/tools/hal-storage-shared.c
@@ -658,6 +658,48 @@ #endif
/* eject was succesful... */
+ /* Do not unbind CDROM, eject on thoses are "open the tray", not unbind */
+ if(libhal_drive_get_type(drive) != LIBHAL_DRIVE_TYPE_CDROM) {
+ char * usb_if;
+ char * usb_dev = NULL;
+ /* Get the usb Interface */
+ usb_if = libhal_device_get_property_string(hal_ctx,udi,"storage.originating_device",NULL);
+ if(usb_if) {
+ /* Get usb device */
+ usb_dev = libhal_device_get_property_string(hal_ctx,usb_if,"info.parent",NULL);
+ if(usb_dev) {
+ /* Make sure this is an usb device */
+ char * device_path;
+ char * driver;
+ driver = libhal_device_get_property_string(hal_ctx,usb_dev,"info.linux.driver",NULL);
+ if(!strcmp(driver,"usb")) {
+ /* Get the sysfs path, top directory is the device string */
+ device_path = libhal_device_get_property_string(hal_ctx,usb_dev,"linux.sysfs_path",NULL);
+ if(device_path) {
+ char * dev_str;
+ dev_str = rindex(device_path,'/')+1;
+ if(dev_str) {
+ int fd;
+ fd = open("/sys/bus/usb/drivers/usb/unbind",O_WRONLY);
+ if(fd != -1) {
+ write(fd,dev_str,strlen(dev_str));
+ close(fd);
+ }
+ }
+ }
+ }
+ if(driver)
+ libhal_free_string(driver);
+ if(device_path)
+ libhal_free_string(device_path);
+ }
+ }
+ if(usb_if)
+ libhal_free_string(usb_if);
+ if(usb_dev)
+ libhal_free_string(usb_dev);
+ }
+
#ifdef DEBUG
printf ("done ejecting\n");
#endif