* @return #EINA_TRUE if the operation was started, else #EINA_FALSE
*
* This call is used to begin an unmount operation on @p disk. The operation will
- * run asynchronously in a pipe, emitting an EEZE_EVENT_DISK_MOUNT event with the disk object
+ * run asynchronously in a pipe, emitting an EEZE_EVENT_DISK_UNMOUNT event with the disk object
* as its event on completion. If any errors are encountered, they will automatically logged
* to the eeze_disk domain and an EEZE_EVENT_DISK_ERROR event will be generated with
* an #Eeze_Event_Disk_Error struct as its event.
EAPI Eina_Bool eeze_disk_unmount(Eeze_Disk *disk);
/**
+ * @brief Begin an eject operation on the disk
+ * @param disk The disk
+ * @return #EINA_TRUE if the operation was started, else #EINA_FALSE
+ *
+ * This call is used to begin an eject operation on @p disk. The operation will
+ * run asynchronously in a pipe, emitting an EEZE_EVENT_DISK_EJECT event with the disk object
+ * as its event on completion. If any errors are encountered, they will automatically logged
+ * to the eeze_disk domain and an EEZE_EVENT_DISK_ERROR event will be generated with
+ * an #Eeze_Event_Disk_Error struct as its event.
+ *
+ * NOTE: The return value of this function does not in any way reflect the mount state of a disk.
+ */
+EAPI Eina_Bool eeze_disk_eject(Eeze_Disk *disk);
+/**
* @brief Cancel a pending operation on the disk
* @param disk The disk
*
EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW);
e->disk = disk;
disk->mounter = NULL;
+ disk->mounted = EINA_FALSE;
ecore_event_add(EEZE_EVENT_DISK_UNMOUNT, e, NULL, NULL);
break;
EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW);
e->disk = disk;
disk->mounter = NULL;
- ecore_event_add(EEZE_EVENT_DISK_EJECT, e, NULL, NULL);
+ if (disk->mount_status & EEZE_DISK_UNMOUNTING)
+ {
+ disk->mount_status |= EEZE_DISK_UNMOUNTING;
+ disk->mounted = EINA_FALSE;
+ ecore_event_add(EEZE_EVENT_DISK_UNMOUNT, e, NULL, NULL);
+ eeze_disk_eject(disk);
+ }
+ else
+ ecore_event_add(EEZE_EVENT_DISK_EJECT, e, NULL, NULL);
break;
default:
INF("Could not eject disk, retrying");
- disk->mounter = ecore_exe_run(eina_strbuf_string_get(disk->unmount_cmd), disk);
+ if (disk->mount_status & EEZE_DISK_UNMOUNTING)
+ disk->mounter = ecore_exe_run(eina_strbuf_string_get(disk->unmount_cmd), disk);
+ else
+ disk->mounter = ecore_exe_run(eina_strbuf_string_get(disk->eject_cmd), disk);
eeze_events = eina_list_append(eeze_events, disk);
return ECORE_CALLBACK_RENEW;
}
}
INF("Ejecting: %s", eina_strbuf_string_get(disk->eject_cmd));
+ if (eeze_disk_libmount_mounted_get(disk))
+ {
+ Eina_Bool ret;
+
+ ret = eeze_disk_unmount(disk);
+ if (ret) disk->mount_status |= EEZE_DISK_EJECTING;
+ return ret;
+ }
disk->mounter = ecore_exe_run(eina_strbuf_string_get(disk->eject_cmd), disk);
if (!disk->mounter)
return EINA_FALSE;