forked from enlightenment/efl
track all disk objects, fix typo in eeze optmap from earlier, catch and create external mount events
SVN revision: 59439
This commit is contained in:
parent
9989571099
commit
f4665b0140
|
@ -9,6 +9,8 @@
|
|||
#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)
|
||||
{
|
||||
|
@ -110,6 +112,8 @@ eeze_disk_new(const char *path)
|
|||
disk->mount_cmd_changed = EINA_TRUE;
|
||||
disk->unmount_cmd_changed = EINA_TRUE;
|
||||
|
||||
_eeze_disks = eina_list_append(_eeze_disks, disk);
|
||||
|
||||
return disk;
|
||||
}
|
||||
|
||||
|
@ -165,6 +169,8 @@ eeze_disk_new_from_mount(const char *mount_point)
|
|||
else
|
||||
disk->devpath = devpath;
|
||||
disk->mount_point = eina_stringshare_add(mount_point);
|
||||
|
||||
_eeze_disks = eina_list_append(_eeze_disks, disk);
|
||||
|
||||
return disk;
|
||||
error:
|
||||
|
@ -186,12 +192,12 @@ eeze_disk_free(Eeze_Disk *disk)
|
|||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ static struct libmnt_optmap eeze_optmap[] =
|
|||
{ "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;
|
||||
|
@ -41,6 +41,7 @@ static Eina_Bool _fstab_scan_active = EINA_FALSE;
|
|||
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);
|
||||
|
@ -123,6 +124,43 @@ _eeze_mount_tab_watcher(void *data, Ecore_File_Monitor *mon __UNUSED__, Ecore_Fi
|
|||
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;
|
||||
|
@ -197,9 +235,13 @@ eeze_disk_libmount_mounted_get(Eeze_Disk *disk)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ static Eina_Bool _fstab_scan_active = EINA_FALSE;
|
|||
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);
|
||||
|
@ -108,6 +109,44 @@ _eeze_mount_tab_watcher(void *data, Ecore_File_Monitor *mon __UNUSED__, Ecore_Fi
|
|||
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;
|
||||
|
||||
|
@ -159,9 +198,13 @@ eeze_disk_libmount_mounted_get(Eeze_Disk *disk)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,6 @@ _eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecor
|
|||
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)
|
||||
{
|
||||
|
@ -99,7 +98,6 @@ _eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecor
|
|||
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;
|
||||
|
|
|
@ -47,6 +47,7 @@ struct _Eeze_Disk
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue