summaryrefslogtreecommitdiff
path: root/legacy/eeze
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-07-29 13:21:09 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-07-29 13:21:09 +0000
commite33c5d05cd44f461d9cf658a06a2961e5801804f (patch)
tree6c92716405174acdcacf8ceb94faec0c564eb29b /legacy/eeze
parentc7bf0ff14a7bb1e15c6303d87c729aa373a2b4a2 (diff)
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
Diffstat (limited to 'legacy/eeze')
-rw-r--r--legacy/eeze/src/lib/eeze_disk.c5
-rw-r--r--legacy/eeze/src/lib/eeze_disk_libmount_new.c9
-rw-r--r--legacy/eeze/src/lib/eeze_disk_mount.c61
-rw-r--r--legacy/eeze/src/lib/eeze_disk_private.h2
4 files changed, 69 insertions, 8 deletions
diff --git a/legacy/eeze/src/lib/eeze_disk.c b/legacy/eeze/src/lib/eeze_disk.c
index 8d1aeec52d..722f47c023 100644
--- a/legacy/eeze/src/lib/eeze_disk.c
+++ b/legacy/eeze/src/lib/eeze_disk.c
@@ -283,6 +283,11 @@ eeze_disk_free(Eeze_Disk *disk)
283 if (disk->mounter) ecore_exe_kill(disk->mounter); 283 if (disk->mounter) ecore_exe_kill(disk->mounter);
284 _eeze_disks = eina_list_remove(_eeze_disks, disk); 284 _eeze_disks = eina_list_remove(_eeze_disks, disk);
285 eeze_events = eina_list_remove(eeze_events, disk); 285 eeze_events = eina_list_remove(eeze_events, disk);
286 if (disk->mount_fail_delay)
287 {
288 ecore_timer_del(disk->mount_fail_delay);
289 disk->mount_fail_delay = NULL;
290 }
286 free(disk); 291 free(disk);
287} 292}
288 293
diff --git a/legacy/eeze/src/lib/eeze_disk_libmount_new.c b/legacy/eeze/src/lib/eeze_disk_libmount_new.c
index c6248ff757..3b6357a1ae 100644
--- a/legacy/eeze/src/lib/eeze_disk_libmount_new.c
+++ b/legacy/eeze/src/lib/eeze_disk_libmount_new.c
@@ -408,6 +408,7 @@ EAPI Eina_Bool
408eeze_mount_tabs_watch(void) 408eeze_mount_tabs_watch(void)
409{ 409{
410 libmnt_table *bak; 410 libmnt_table *bak;
411 char *lnk;
411 412
412 if (_watching) 413 if (_watching)
413 return EINA_TRUE; 414 return EINA_TRUE;
@@ -417,7 +418,7 @@ eeze_mount_tabs_watch(void)
417 418
418 mnt_free_table(_eeze_mount_mtab); 419 mnt_free_table(_eeze_mount_mtab);
419 _eeze_mount_mtab = bak; 420 _eeze_mount_mtab = bak;
420 bak = _eeze_mount_tab_parse("/etc/fstab"); 421 bak = _eeze_mount_tab_parse("/etc/mtab");
421 EINA_SAFETY_ON_NULL_GOTO(bak, error); 422 EINA_SAFETY_ON_NULL_GOTO(bak, error);
422 423
423 mnt_free_table(_eeze_mount_fstab); 424 mnt_free_table(_eeze_mount_fstab);
@@ -433,8 +434,10 @@ eeze_mount_tabs_watch(void)
433 if (!_mountinfo) goto error; 434 if (!_mountinfo) goto error;
434 _mountinfo_fdh = ecore_main_fd_handler_add(fileno(_mountinfo), ECORE_FD_ERROR, _eeze_mount_fdh, NULL, NULL, NULL); 435 _mountinfo_fdh = ecore_main_fd_handler_add(fileno(_mountinfo), ECORE_FD_ERROR, _eeze_mount_fdh, NULL, NULL, NULL);
435 if (!_mountinfo_fdh) goto error; 436 if (!_mountinfo_fdh) goto error;
436 _fstab_mon = ecore_file_monitor_add("/etc/fstab", _eeze_mount_tab_watcher, NULL); 437 _fstab_mon = ecore_file_monitor_add("/etc/mtab", _eeze_mount_tab_watcher, NULL);
437 _watching = EINA_TRUE; 438 lnk = ecore_file_readlink("/etc/mtab");
439 if (lnk) free(lnk);
440 else _watching = EINA_TRUE;
438 441
439 return EINA_TRUE; 442 return EINA_TRUE;
440 443
diff --git a/legacy/eeze/src/lib/eeze_disk_mount.c b/legacy/eeze/src/lib/eeze_disk_mount.c
index cbb57aed7c..54a9566778 100644
--- a/legacy/eeze/src/lib/eeze_disk_mount.c
+++ b/legacy/eeze/src/lib/eeze_disk_mount.c
@@ -55,6 +55,38 @@ _eeze_disk_mount_error_handler(Eeze_Disk *disk, const char *error)
55} 55}
56 56
57static Eina_Bool 57static Eina_Bool
58_eeze_disk_mount_fail_delay_check(void *data)
59{
60 Eeze_Disk *disk = data;
61
62 disk->fail_pol_check++;
63 if (eeze_disk_mounted_get(disk))
64 {
65 Eeze_Event_Disk_Mount *e;
66
67 disk->mounted = EINA_TRUE;
68 e = malloc(sizeof(Eeze_Event_Disk_Mount));
69 if (e)
70 {
71 e->disk = disk;
72 ecore_event_add(EEZE_EVENT_DISK_MOUNT, e, NULL, NULL);
73 }
74 return EINA_FALSE;
75 }
76 if (disk->fail_pol_check > 30)
77 {
78 if (disk->mount_fail_delay)
79 {
80 ecore_timer_del(disk->mount_fail_delay);
81 disk->mount_fail_delay = NULL;
82 }
83 _eeze_disk_mount_error_handler(disk, "mount failure");
84 return EINA_FALSE;
85 }
86 return EINA_TRUE;
87}
88
89static Eina_Bool
58_eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecore_Exe_Event_Del *ev) 90_eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecore_Exe_Event_Del *ev)
59{ 91{
60 Eeze_Disk *disk; 92 Eeze_Disk *disk;
@@ -79,11 +111,25 @@ _eeze_disk_mount_result_handler(void *data __UNUSED__, int type __UNUSED__, Ecor
79 disk->mounter = NULL; 111 disk->mounter = NULL;
80 if (!ev->exit_code) 112 if (!ev->exit_code)
81 { 113 {
82 disk->mounted = EINA_TRUE; 114 if (!eeze_disk_mounted_get(disk))
83 e = malloc(sizeof(Eeze_Event_Disk_Mount)); 115 {
84 EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW); 116 /* libmount seems to have a nasty race condition... or
85 e->disk = disk; 117 * mount .. or something... the mount exe returns
86 ecore_event_add(EEZE_EVENT_DISK_MOUNT, e, NULL, NULL); 118 * BUT its not mounted yet! so poll for a bit.. and see */
119 if (!disk->mount_fail_delay)
120 disk->mount_fail_delay =
121 ecore_timer_add(0.1, _eeze_disk_mount_fail_delay_check,
122 disk);
123 disk->fail_pol_check = 0;
124 }
125 else
126 {
127 disk->mounted = EINA_TRUE;
128 e = malloc(sizeof(Eeze_Event_Disk_Mount));
129 EINA_SAFETY_ON_NULL_RETURN_VAL(e, ECORE_CALLBACK_RENEW);
130 e->disk = disk;
131 ecore_event_add(EEZE_EVENT_DISK_MOUNT, e, NULL, NULL);
132 }
87 } 133 }
88 else if (ev->exit_code & 2) 134 else if (ev->exit_code & 2)
89 _eeze_disk_mount_error_handler(disk, "system error (out of memory, cannot fork, no more loop devices)"); 135 _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)
417 disk->mount_status = EEZE_DISK_NULL; 463 disk->mount_status = EEZE_DISK_NULL;
418 ecore_exe_kill(disk->mounter); 464 ecore_exe_kill(disk->mounter);
419 disk->mounter = NULL; 465 disk->mounter = NULL;
466 if (disk->mount_fail_delay)
467 {
468 ecore_timer_del(disk->mount_fail_delay);
469 disk->mount_fail_delay = NULL;
470 }
420} 471}
421 472
422EAPI const char * 473EAPI const char *
diff --git a/legacy/eeze/src/lib/eeze_disk_private.h b/legacy/eeze/src/lib/eeze_disk_private.h
index afe2172388..080035fefa 100644
--- a/legacy/eeze/src/lib/eeze_disk_private.h
+++ b/legacy/eeze/src/lib/eeze_disk_private.h
@@ -51,6 +51,8 @@ struct _Eeze_Disk
51 Eina_Bool unmount_cmd_changed : 1; 51 Eina_Bool unmount_cmd_changed : 1;
52 Eina_Bool mounted : 1; 52 Eina_Bool mounted : 1;
53 Ecore_Exe *mounter; 53 Ecore_Exe *mounter;
54 Ecore_Timer *mount_fail_delay;
55 int fail_pol_check;
54 56
55 const char *syspath; 57 const char *syspath;
56 const char *devpath; 58 const char *devpath;