summaryrefslogtreecommitdiff
path: root/legacy/eeze
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2012-07-30 07:31:34 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2012-07-30 07:31:34 +0000
commit244e5f79198a20d0abeaf862091cfaf49657d8e9 (patch)
tree52ccbaf196753fb16c249e4012ce6f24a963701d /legacy/eeze
parent10e1c670dd13587a7181f1fc7c64baf4066c8840 (diff)
revert part of 74545 and change fopen to open; somehow this broke reading
SVN revision: 74557
Diffstat (limited to 'legacy/eeze')
-rw-r--r--legacy/eeze/src/lib/eeze_disk_libmount_new.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/legacy/eeze/src/lib/eeze_disk_libmount_new.c b/legacy/eeze/src/lib/eeze_disk_libmount_new.c
index 3b6357a1ae..1c77b03d40 100644
--- a/legacy/eeze/src/lib/eeze_disk_libmount_new.c
+++ b/legacy/eeze/src/lib/eeze_disk_libmount_new.c
@@ -6,12 +6,15 @@
6# define USE_UNSTABLE_LIBMOUNT_API 1 6# define USE_UNSTABLE_LIBMOUNT_API 1
7#endif 7#endif
8 8
9#include <unistd.h>
10#include <sys/types.h>
11#include <sys/stat.h>
12#include <fcntl.h>
13
9#include <Ecore.h> 14#include <Ecore.h>
10#include <Eeze.h> 15#include <Eeze.h>
11#include <Eeze_Disk.h> 16#include <Eeze_Disk.h>
12#include <libmount.h> 17#include <libmount.h>
13#include <unistd.h>
14
15#include "eeze_udev_private.h" 18#include "eeze_udev_private.h"
16#include "eeze_disk_private.h" 19#include "eeze_disk_private.h"
17 20
@@ -44,7 +47,7 @@ static libmnt_table *_eeze_mount_fstab = NULL;
44extern Eina_List *_eeze_disks; 47extern Eina_List *_eeze_disks;
45 48
46static Ecore_Fd_Handler *_mountinfo_fdh = NULL; 49static Ecore_Fd_Handler *_mountinfo_fdh = NULL;
47static FILE *_mountinfo = NULL; 50static int _mountinfo = -1;
48 51
49static libmnt_table *_eeze_mount_tab_parse(const char *filename); 52static libmnt_table *_eeze_mount_tab_parse(const char *filename);
50static void _eeze_mount_tab_watcher(void *data, Ecore_File_Monitor *mon __UNUSED__, Ecore_File_Event event __UNUSED__, const char *path); 53static void _eeze_mount_tab_watcher(void *data, Ecore_File_Monitor *mon __UNUSED__, Ecore_File_Event event __UNUSED__, const char *path);
@@ -136,8 +139,7 @@ _eeze_mount_fdh(void *d __UNUSED__, Ecore_Fd_Handler *fdh __UNUSED__)
136 EINA_SAFETY_ON_NULL_GOTO(itr, err); 139 EINA_SAFETY_ON_NULL_GOTO(itr, err);
137 diff = mnt_new_tabdiff(); 140 diff = mnt_new_tabdiff();
138 EINA_SAFETY_ON_NULL_GOTO(diff, err); 141 EINA_SAFETY_ON_NULL_GOTO(diff, err);
139 rewind(_mountinfo); 142 if (mnt_table_parse_file(tb_new, "/proc/self/mountinfo"))
140 if (mnt_table_parse_stream(tb_new, _mountinfo, "/proc/self/mountinfo"))
141 { 143 {
142 ERR("PARSING FAILED FOR /proc/self/mountinfo! THIS IS WEIRD!"); 144 ERR("PARSING FAILED FOR /proc/self/mountinfo! THIS IS WEIRD!");
143 goto err; 145 goto err;
@@ -408,7 +410,6 @@ EAPI Eina_Bool
408eeze_mount_tabs_watch(void) 410eeze_mount_tabs_watch(void)
409{ 411{
410 libmnt_table *bak; 412 libmnt_table *bak;
411 char *lnk;
412 413
413 if (_watching) 414 if (_watching)
414 return EINA_TRUE; 415 return EINA_TRUE;
@@ -418,7 +419,7 @@ eeze_mount_tabs_watch(void)
418 419
419 mnt_free_table(_eeze_mount_mtab); 420 mnt_free_table(_eeze_mount_mtab);
420 _eeze_mount_mtab = bak; 421 _eeze_mount_mtab = bak;
421 bak = _eeze_mount_tab_parse("/etc/mtab"); 422 bak = _eeze_mount_tab_parse("/etc/fstab");
422 EINA_SAFETY_ON_NULL_GOTO(bak, error); 423 EINA_SAFETY_ON_NULL_GOTO(bak, error);
423 424
424 mnt_free_table(_eeze_mount_fstab); 425 mnt_free_table(_eeze_mount_fstab);
@@ -430,20 +431,18 @@ eeze_mount_tabs_watch(void)
430 _eeze_mount_fstab_cache = mnt_new_cache(); 431 _eeze_mount_fstab_cache = mnt_new_cache();
431 mnt_table_set_cache(_eeze_mount_fstab, _eeze_mount_fstab_cache); 432 mnt_table_set_cache(_eeze_mount_fstab, _eeze_mount_fstab_cache);
432 433
433 _mountinfo = fopen("/proc/self/mountinfo", "r"); 434 _mountinfo = open("/proc/self/mountinfo", O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
434 if (!_mountinfo) goto error; 435 if (_mountinfo < 0) goto error;
435 _mountinfo_fdh = ecore_main_fd_handler_add(fileno(_mountinfo), ECORE_FD_ERROR, _eeze_mount_fdh, NULL, NULL, NULL); 436 _mountinfo_fdh = ecore_main_fd_handler_add(_mountinfo, ECORE_FD_ERROR, _eeze_mount_fdh, NULL, NULL, NULL);
436 if (!_mountinfo_fdh) goto error; 437 if (!_mountinfo_fdh) goto error;
437 _fstab_mon = ecore_file_monitor_add("/etc/mtab", _eeze_mount_tab_watcher, NULL); 438 _fstab_mon = ecore_file_monitor_add("/etc/fstab", _eeze_mount_tab_watcher, NULL);
438 lnk = ecore_file_readlink("/etc/mtab"); 439 _watching = EINA_TRUE;
439 if (lnk) free(lnk);
440 else _watching = EINA_TRUE;
441 440
442 return EINA_TRUE; 441 return EINA_TRUE;
443 442
444error: 443error:
445 if (_mountinfo) fclose(_mountinfo); 444 if (_mountinfo >= 0) close(_mountinfo);
446 _mountinfo = NULL; 445 _mountinfo = -1;
447 if (!_eeze_mount_mtab) 446 if (!_eeze_mount_mtab)
448 ERR("Could not parse /proc/self/mountinfo!"); 447 ERR("Could not parse /proc/self/mountinfo!");
449 else 448 else
@@ -461,8 +460,10 @@ eeze_mount_tabs_unwatch(void)
461 if (!_watching) 460 if (!_watching)
462 return; 461 return;
463 462
464 _mountinfo_fdh = ecore_main_fd_handler_del(_mountinfo_fdh); 463 ecore_main_fd_handler_del(_mountinfo_fdh);
465 ecore_file_monitor_del(_fstab_mon); 464 ecore_file_monitor_del(_fstab_mon);
465 close(_mountinfo);
466 _mountinfo = -1;
466 _fstab_mon = NULL; 467 _fstab_mon = NULL;
467 _watching = EINA_FALSE; 468 _watching = EINA_FALSE;
468} 469}