#include "eeze_udev_private.h"
#include "eeze_disk_private.h"
+Eina_List *_eeze_disks = NULL;
+
static Eeze_Disk_Type
_eeze_disk_type_find(Eeze_Disk *disk)
{
disk->mount_cmd_changed = EINA_TRUE;
disk->unmount_cmd_changed = EINA_TRUE;
+ _eeze_disks = eina_list_append(_eeze_disks, disk);
+
return disk;
}
else
disk->devpath = devpath;
disk->mount_point = eina_stringshare_add(mount_point);
+
+ _eeze_disks = eina_list_append(_eeze_disks, disk);
return disk;
error:
{
EINA_SAFETY_ON_NULL_RETURN(disk);
-
udev_device_unref(disk->device);
if (disk->mount_cmd)
eina_strbuf_free(disk->mount_cmd);
if (disk->unmount_cmd)
eina_strbuf_free(disk->unmount_cmd);
+ _eeze_disks = eina_list_remove(_eeze_disks, disk);
free(disk);
}
{ "noexec", EEZE_DISK_MOUNTOPT_NOEXEC, 0 },
{ "nosuid", EEZE_DISK_MOUNTOPT_NOSUID, 0 },
{ "remount", EEZE_DISK_MOUNTOPT_REMOUNT, 0 },
- { "uid[=]", EEZE_DISK_MOUNTOPT_LOOP, 0 },
+ { "uid[=]", EEZE_DISK_MOUNTOPT_UID, 0 },
{ NULL, 0, 0 }
};
typedef struct libmnt_table libmnt_table;
static libmnt_table *_eeze_mount_mtab = NULL;
static libmnt_table *_eeze_mount_fstab = NULL;
static libmnt_lock *_eeze_mtab_lock = NULL;
+extern Eina_List *_eeze_disks;
static libmnt_table *_eeze_mount_tab_parse(const char *filename);
static void _eeze_mount_tab_watcher(void *data, Ecore_File_Monitor *mon __UNUSED__, Ecore_File_Event event __UNUSED__, const char *path);
ERR("Could not parse %s! keeping old tab...", path);
goto error;
}
+ if (data)
+ {
+ Eina_List *l;
+ Eeze_Disk *disk;
+
+ /* catch externally initiated mounts on existing disks by comparing known mount state to current state */
+ EINA_LIST_FOREACH(_eeze_disks, l, disk)
+ {
+ Eina_Bool mounted;
+
+ mounted = disk->mounted;
+
+ if ((eeze_disk_libmount_mounted_get(disk) != mounted) && (!disk->mount_status))
+ {
+ if (!mounted)
+ {
+ Eeze_Event_Disk_Mount *e;
+ e = malloc(sizeof(Eeze_Event_Disk_Mount));
+ if (e)
+ {
+ e->disk = disk;
+ ecore_event_add(EEZE_EVENT_DISK_MOUNT, e, NULL, NULL);
+ }
+ }
+ else
+ {
+ Eeze_Event_Disk_Unmount *e;
+ e = malloc(sizeof(Eeze_Event_Disk_Unmount));
+ if (e)
+ {
+ e->disk = disk;
+ ecore_event_add(EEZE_EVENT_DISK_UNMOUNT, e, NULL, NULL);
+ }
+ }
+ }
+ }
+ }
mnt_free_table(bak);
return;
mnt = mnt_table_find_srcpath(_eeze_mount_mtab, eeze_disk_devpath_get(disk), MNT_ITER_BACKWARD);
if (!mnt)
- return EINA_FALSE;
+ {
+ disk->mounted = EINA_FALSE;
+ return EINA_FALSE;
+ }
eina_stringshare_replace(&disk->mount_point, mnt_fs_get_target(mnt));
+ disk->mounted = EINA_TRUE;
return EINA_TRUE;
}
static mnt_tab *_eeze_mount_mtab = NULL;
static mnt_tab *_eeze_mount_fstab = NULL;
static mnt_lock *_eeze_mtab_lock = NULL;
+extern Eina_List *_eeze_disks;
static mnt_tab *_eeze_mount_tab_parse(const char *filename);
static void _eeze_mount_tab_watcher(void *data, Ecore_File_Monitor *mon __UNUSED__, Ecore_File_Event event __UNUSED__, const char *path);
goto error;
}
+ if (data)
+ {
+ Eina_List *l;
+ Eeze_Disk *disk;
+
+ /* catch externally initiated mounts on existing disks by comparing known mount state to current state */
+ EINA_LIST_FOREACH(_eeze_disks, l, disk)
+ {
+ Eina_Bool mounted;
+
+ mounted = disk->mounted;
+
+ if ((eeze_disk_libmount_mounted_get(disk) != mounted) && (!disk->mount_status))
+ {
+ if (!mounted)
+ {
+ Eeze_Event_Disk_Mount *e;
+ e = malloc(sizeof(Eeze_Event_Disk_Mount));
+ if (e)
+ {
+ e->disk = disk;
+ ecore_event_add(EEZE_EVENT_DISK_MOUNT, e, NULL, NULL);
+ }
+ }
+ else
+ {
+ Eeze_Event_Disk_Unmount *e;
+ e = malloc(sizeof(Eeze_Event_Disk_Unmount));
+ if (e)
+ {
+ e->disk = disk;
+ ecore_event_add(EEZE_EVENT_DISK_UNMOUNT, e, NULL, NULL);
+ }
+ }
+ }
+ }
+ }
+
mnt_free_tab(bak);
return;
mnt = mnt_tab_find_srcpath(_eeze_mount_mtab, eeze_disk_devpath_get(disk), MNT_ITER_BACKWARD);
if (!mnt)
- return EINA_FALSE;
+ {
+ disk->mounted = EINA_FALSE;
+ return EINA_FALSE;
+ }
disk->mount_point = eina_stringshare_add(mnt_fs_get_target(mnt));
+ disk->mounted = EINA_TRUE;
return EINA_TRUE;
}
eeze_events = eina_list_remove_list(eeze_events, l);
if (disk->mount_status == EEZE_DISK_MOUNTING)
{
- disk->mount_status = EEZE_DISK_NULL;
disk->mounter = NULL;
if (!ev->exit_code)
{
e = malloc(sizeof(Eeze_Event_Disk_Unmount));
EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW);
e->disk = disk;
- disk->mount_status = EEZE_DISK_NULL;
disk->mounter = NULL;
ecore_event_add(EEZE_EVENT_DISK_UNMOUNT, e, NULL, NULL);
break;
Eina_Strbuf *unmount_cmd;
Eina_Bool mount_cmd_changed : 1;
Eina_Bool unmount_cmd_changed : 1;
+ Eina_Bool mounted : 1;
Ecore_Exe *mounter;
const char *syspath;