diff --git a/legacy/eeze/src/lib/Eeze_Disk.h b/legacy/eeze/src/lib/Eeze_Disk.h index 5bc031b72c..31e5fa6afe 100644 --- a/legacy/eeze/src/lib/Eeze_Disk.h +++ b/legacy/eeze/src/lib/Eeze_Disk.h @@ -288,7 +288,7 @@ EAPI Eina_Bool eeze_disk_mount(Eeze_Disk *disk); * @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. @@ -297,6 +297,20 @@ EAPI Eina_Bool eeze_disk_mount(Eeze_Disk *disk); */ 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 diff --git a/legacy/eeze/src/lib/eeze_disk_mount.c b/legacy/eeze/src/lib/eeze_disk_mount.c index 5dccbbee0b..89120415c6 100644 --- a/legacy/eeze/src/lib/eeze_disk_mount.c +++ b/legacy/eeze/src/lib/eeze_disk_mount.c @@ -100,6 +100,7 @@ _eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecor 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; @@ -117,12 +118,23 @@ _eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecor 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; } @@ -356,6 +368,14 @@ eeze_disk_eject(Eeze_Disk *disk) } 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; diff --git a/legacy/eeze/src/lib/eeze_disk_private.h b/legacy/eeze/src/lib/eeze_disk_private.h index 50347f0574..f7336ff576 100644 --- a/legacy/eeze/src/lib/eeze_disk_private.h +++ b/legacy/eeze/src/lib/eeze_disk_private.h @@ -32,10 +32,10 @@ extern int _eeze_disk_log_dom; typedef enum { - EEZE_DISK_NULL, - EEZE_DISK_MOUNTING, - EEZE_DISK_UNMOUNTING, - EEZE_DISK_EJECTING + EEZE_DISK_NULL = 0, + EEZE_DISK_MOUNTING = 1, + EEZE_DISK_UNMOUNTING = 2, + EEZE_DISK_EJECTING = 4 } Eeze_Disk_Status; struct _Eeze_Disk @@ -43,7 +43,7 @@ struct _Eeze_Disk _udev_device *device; void *data; - Eeze_Disk_Status mount_status; + int mount_status; Eina_Strbuf *mount_cmd; Eina_Strbuf *unmount_cmd; Eina_Strbuf *eject_cmd;