and... first monitor mtab not fstab for MOUNT changes/ mtab is
"current mounted status" . fstab is "stuff i WANT to mount". secondly.. if mtab is a symlink.. pretend we arent monitoring. this then kicks in the poll checker after mount cmd is done. SVN revision: 74545
This commit is contained in:
parent
c7bf0ff14a
commit
e33c5d05cd
|
@ -283,6 +283,11 @@ eeze_disk_free(Eeze_Disk *disk)
|
||||||
if (disk->mounter) ecore_exe_kill(disk->mounter);
|
if (disk->mounter) ecore_exe_kill(disk->mounter);
|
||||||
_eeze_disks = eina_list_remove(_eeze_disks, disk);
|
_eeze_disks = eina_list_remove(_eeze_disks, disk);
|
||||||
eeze_events = eina_list_remove(eeze_events, disk);
|
eeze_events = eina_list_remove(eeze_events, disk);
|
||||||
|
if (disk->mount_fail_delay)
|
||||||
|
{
|
||||||
|
ecore_timer_del(disk->mount_fail_delay);
|
||||||
|
disk->mount_fail_delay = NULL;
|
||||||
|
}
|
||||||
free(disk);
|
free(disk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -408,6 +408,7 @@ EAPI Eina_Bool
|
||||||
eeze_mount_tabs_watch(void)
|
eeze_mount_tabs_watch(void)
|
||||||
{
|
{
|
||||||
libmnt_table *bak;
|
libmnt_table *bak;
|
||||||
|
char *lnk;
|
||||||
|
|
||||||
if (_watching)
|
if (_watching)
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
|
@ -417,7 +418,7 @@ eeze_mount_tabs_watch(void)
|
||||||
|
|
||||||
mnt_free_table(_eeze_mount_mtab);
|
mnt_free_table(_eeze_mount_mtab);
|
||||||
_eeze_mount_mtab = bak;
|
_eeze_mount_mtab = bak;
|
||||||
bak = _eeze_mount_tab_parse("/etc/fstab");
|
bak = _eeze_mount_tab_parse("/etc/mtab");
|
||||||
EINA_SAFETY_ON_NULL_GOTO(bak, error);
|
EINA_SAFETY_ON_NULL_GOTO(bak, error);
|
||||||
|
|
||||||
mnt_free_table(_eeze_mount_fstab);
|
mnt_free_table(_eeze_mount_fstab);
|
||||||
|
@ -433,8 +434,10 @@ eeze_mount_tabs_watch(void)
|
||||||
if (!_mountinfo) goto error;
|
if (!_mountinfo) goto error;
|
||||||
_mountinfo_fdh = ecore_main_fd_handler_add(fileno(_mountinfo), ECORE_FD_ERROR, _eeze_mount_fdh, NULL, NULL, NULL);
|
_mountinfo_fdh = ecore_main_fd_handler_add(fileno(_mountinfo), ECORE_FD_ERROR, _eeze_mount_fdh, NULL, NULL, NULL);
|
||||||
if (!_mountinfo_fdh) goto error;
|
if (!_mountinfo_fdh) goto error;
|
||||||
_fstab_mon = ecore_file_monitor_add("/etc/fstab", _eeze_mount_tab_watcher, NULL);
|
_fstab_mon = ecore_file_monitor_add("/etc/mtab", _eeze_mount_tab_watcher, NULL);
|
||||||
_watching = EINA_TRUE;
|
lnk = ecore_file_readlink("/etc/mtab");
|
||||||
|
if (lnk) free(lnk);
|
||||||
|
else _watching = EINA_TRUE;
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,38 @@ _eeze_disk_mount_error_handler(Eeze_Disk *disk, const char *error)
|
||||||
ecore_event_add(EEZE_EVENT_DISK_ERROR, de, (Ecore_End_Cb)_eeze_disk_mount_error_free, NULL);
|
ecore_event_add(EEZE_EVENT_DISK_ERROR, de, (Ecore_End_Cb)_eeze_disk_mount_error_free, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_eeze_disk_mount_fail_delay_check(void *data)
|
||||||
|
{
|
||||||
|
Eeze_Disk *disk = data;
|
||||||
|
|
||||||
|
disk->fail_pol_check++;
|
||||||
|
if (eeze_disk_mounted_get(disk))
|
||||||
|
{
|
||||||
|
Eeze_Event_Disk_Mount *e;
|
||||||
|
|
||||||
|
disk->mounted = EINA_TRUE;
|
||||||
|
e = malloc(sizeof(Eeze_Event_Disk_Mount));
|
||||||
|
if (e)
|
||||||
|
{
|
||||||
|
e->disk = disk;
|
||||||
|
ecore_event_add(EEZE_EVENT_DISK_MOUNT, e, NULL, NULL);
|
||||||
|
}
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
if (disk->fail_pol_check > 30)
|
||||||
|
{
|
||||||
|
if (disk->mount_fail_delay)
|
||||||
|
{
|
||||||
|
ecore_timer_del(disk->mount_fail_delay);
|
||||||
|
disk->mount_fail_delay = NULL;
|
||||||
|
}
|
||||||
|
_eeze_disk_mount_error_handler(disk, "mount failure");
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecore_Exe_Event_Del *ev)
|
_eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecore_Exe_Event_Del *ev)
|
||||||
{
|
{
|
||||||
|
@ -79,11 +111,25 @@ _eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecor
|
||||||
disk->mounter = NULL;
|
disk->mounter = NULL;
|
||||||
if (!ev->exit_code)
|
if (!ev->exit_code)
|
||||||
{
|
{
|
||||||
disk->mounted = EINA_TRUE;
|
if (!eeze_disk_mounted_get(disk))
|
||||||
e = malloc(sizeof(Eeze_Event_Disk_Mount));
|
{
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW);
|
/* libmount seems to have a nasty race condition... or
|
||||||
e->disk = disk;
|
* mount .. or something... the mount exe returns
|
||||||
ecore_event_add(EEZE_EVENT_DISK_MOUNT, e, NULL, NULL);
|
* BUT its not mounted yet! so poll for a bit.. and see */
|
||||||
|
if (!disk->mount_fail_delay)
|
||||||
|
disk->mount_fail_delay =
|
||||||
|
ecore_timer_add(0.1, _eeze_disk_mount_fail_delay_check,
|
||||||
|
disk);
|
||||||
|
disk->fail_pol_check = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disk->mounted = EINA_TRUE;
|
||||||
|
e = malloc(sizeof(Eeze_Event_Disk_Mount));
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW);
|
||||||
|
e->disk = disk;
|
||||||
|
ecore_event_add(EEZE_EVENT_DISK_MOUNT, e, NULL, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (ev->exit_code & 2)
|
else if (ev->exit_code & 2)
|
||||||
_eeze_disk_mount_error_handler(disk, "system error (out of memory, cannot fork, no more loop devices)");
|
_eeze_disk_mount_error_handler(disk, "system error (out of memory, cannot fork, no more loop devices)");
|
||||||
|
@ -417,6 +463,11 @@ eeze_disk_cancel(Eeze_Disk *disk)
|
||||||
disk->mount_status = EEZE_DISK_NULL;
|
disk->mount_status = EEZE_DISK_NULL;
|
||||||
ecore_exe_kill(disk->mounter);
|
ecore_exe_kill(disk->mounter);
|
||||||
disk->mounter = NULL;
|
disk->mounter = NULL;
|
||||||
|
if (disk->mount_fail_delay)
|
||||||
|
{
|
||||||
|
ecore_timer_del(disk->mount_fail_delay);
|
||||||
|
disk->mount_fail_delay = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI const char *
|
EAPI const char *
|
||||||
|
|
|
@ -51,6 +51,8 @@ struct _Eeze_Disk
|
||||||
Eina_Bool unmount_cmd_changed : 1;
|
Eina_Bool unmount_cmd_changed : 1;
|
||||||
Eina_Bool mounted : 1;
|
Eina_Bool mounted : 1;
|
||||||
Ecore_Exe *mounter;
|
Ecore_Exe *mounter;
|
||||||
|
Ecore_Timer *mount_fail_delay;
|
||||||
|
int fail_pol_check;
|
||||||
|
|
||||||
const char *syspath;
|
const char *syspath;
|
||||||
const char *devpath;
|
const char *devpath;
|
||||||
|
|
Loading…
Reference in New Issue