with_umount="/bin/umount"
AC_ARG_WITH([mount], AS_HELP_STRING([--with-mount], [specify mount bin @<:@default=detect@:>@]))
AC_ARG_WITH([umount], AS_HELP_STRING([--with-umount], [specify umount bin @<:@default=detect@:>@]))
+ AC_ARG_WITH([eject], AS_HELP_STRING([--with-eject], [specify eject bin @<:@default=detect@:>@]))
PKG_CHECK_MODULES([LIBMOUNT], [mount >= 2.18.0])
mount_v=$(pkg-config --modversion mount)
PKG_CHECK_MODULES([ECORE_FILE], [ecore-file >= 1.0.0])
AC_PATH_PROG([with_umount], [umount], AC_MSG_ERROR([umount could not be found in PATH]))
fi
AC_DEFINE_UNQUOTED([EEZE_UNMOUNT_BIN], ["$with_umount"], [umount bin to use])
+
+ if test "x$with_eject" = "xdetect";then
+ AC_PATH_PROG([with_eject], [eject], AC_MSG_ERROR([eject could not be found in PATH]))
+ fi
+ AC_DEFINE_UNQUOTED([EEZE_EJECT_BIN], ["$with_eject"], [eject bin to use])
fi
AM_CONDITIONAL([OLD_LIBMOUNT], [test -n $mount_v -a $(echo $mount_v | cut -d'.' -f2) -lt 19])
if test -z "$OLD_LIBMOUNT_TRUE" ; then
echo
echo "Mount..................: ${with_mount}"
echo "Umount.................: ${with_umount}"
+ echo "Eject..................: ${with_eject}"
echo
fi
echo "Test...................: ${have_eeze_udev_test}"
EAPI extern int EEZE_EVENT_DISK_MOUNT;
EAPI extern int EEZE_EVENT_DISK_UNMOUNT;
+EAPI extern int EEZE_EVENT_DISK_EJECT;
EAPI extern int EEZE_EVENT_DISK_ERROR;
-typedef struct _Eeze_Event_Disk_Mount Eeze_Event_Disk_Mount;
-typedef struct _Eeze_Event_Disk_Unmount Eeze_Event_Disk_Unmount;
+typedef struct _Eeze_Event_Disk Eeze_Event_Disk_Mount;
+typedef struct _Eeze_Event_Disk Eeze_Event_Disk_Unmount;
+typedef struct _Eeze_Event_Disk Eeze_Event_Disk_Eject;
typedef struct _Eeze_Disk Eeze_Disk;
-struct _Eeze_Event_Disk_Mount
+struct _Eeze_Event_Disk
{
Eeze_Disk *disk;
};
-struct _Eeze_Event_Disk_Unmount
-{
- Eeze_Disk *disk;
-};
-
-
typedef struct _Eeze_Event_Disk_Error Eeze_Event_Disk_Error;
struct _Eeze_Event_Disk_Error
EAPI int EEZE_EVENT_DISK_MOUNT = 0;
EAPI int EEZE_EVENT_DISK_UNMOUNT = 0;
+EAPI int EEZE_EVENT_DISK_EJECT = 0;
EAPI int EEZE_EVENT_DISK_ERROR = 0;
static Ecore_Event_Handler *_mount_handler = NULL;
static Eina_List *eeze_events = NULL;
else
_eeze_disk_mount_error_handler(disk, "incorrect invocation or permissions");
}
- else
+ else if (disk->mount_status == EEZE_DISK_UNMOUNTING)
switch (ev->exit_code)
{
case 0:
default:
INF("Could not unmount disk, retrying");
- disk->mounter = ecore_exe_pipe_run(eina_strbuf_string_get(disk->unmount_cmd), 0, disk);
+ disk->mounter = ecore_exe_run(eina_strbuf_string_get(disk->unmount_cmd), disk);
eeze_events = eina_list_append(eeze_events, disk);
return ECORE_CALLBACK_RENEW;
}
-
+ else
+ switch (ev->exit_code)
+ {
+ case 0:
+ e = malloc(sizeof(Eeze_Event_Disk_Eject));
+ 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);
+ break;
+
+ default:
+ INF("Could not eject disk, retrying");
+ disk->mounter = ecore_exe_run(eina_strbuf_string_get(disk->unmount_cmd), disk);
+ eeze_events = eina_list_append(eeze_events, disk);
+ return ECORE_CALLBACK_RENEW;
+ }
return ECORE_CALLBACK_RENEW;
}
{
EEZE_EVENT_DISK_MOUNT = ecore_event_type_new();
EEZE_EVENT_DISK_UNMOUNT = ecore_event_type_new();
+ EEZE_EVENT_DISK_EJECT = ecore_event_type_new();
EEZE_EVENT_DISK_ERROR = ecore_event_type_new();
_mount_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
(Ecore_Event_Handler_Cb)_eeze_disk_mount_result_handler, NULL);
return EINA_TRUE;
}
+EAPI Eina_Bool
+eeze_disk_eject(Eeze_Disk *disk)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(disk, EINA_FALSE);
+
+ if (!disk->eject_cmd)
+ {
+ disk->eject_cmd = eina_strbuf_new();
+ if (disk->mount_wrapper)
+ eina_strbuf_append_printf(disk->eject_cmd, "%s ", disk->mount_wrapper);
+ eina_strbuf_append_printf(disk->eject_cmd, EEZE_EJECT_BIN" %s", eeze_disk_devpath_get(disk));
+ }
+
+ INF("Ejecting: %s", eina_strbuf_string_get(disk->eject_cmd));
+ disk->mounter = ecore_exe_run(eina_strbuf_string_get(disk->eject_cmd), disk);
+ if (!disk->mounter)
+ return EINA_FALSE;
+
+ eeze_events = eina_list_append(eeze_events, disk);
+ disk->mount_status = EEZE_DISK_EJECTING;
+ return EINA_TRUE;
+}
+
EAPI void
eeze_disk_cancel(Eeze_Disk *disk)
{
EINA_SAFETY_ON_NULL_RETURN(disk);
if ((!disk->mount_status) || (!disk->mounter)) return;
disk->mount_status = EEZE_DISK_NULL;
- ecore_exe_quit(disk->mounter);
+ ecore_exe_kill(disk->mounter);
+ disk->mounter = NULL;
}
EAPI const char *