netstar pushed a commit to branch master.

http://git.enlightenment.org/apps/evisum.git/commit/?id=63953978d981a052ce031c917530d243dc30dfd4

commit 63953978d981a052ce031c917530d243dc30dfd4
Author: Alastair Poole <[email protected]>
Date:   Tue Dec 1 10:14:08 2020 +0000

    disks: Fix this horrible broken API.
    
    Some horrid left over from a tool i wrote to write disk images and
    parsing for physicaly disks. Well, it doesn't map well. Keep linux
    as is for now.
    
    FreeBSD win and OpenBSD win.
---
 src/bin/system/filesystems.c | 30 ++++++++++++++++++++++++++++++
 src/bin/system/filesystems.h |  3 +++
 src/bin/ui/ui_disk.c         |  9 ++++++---
 3 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/src/bin/system/filesystems.c b/src/bin/system/filesystems.c
index 9bee224..dac60f2 100644
--- a/src/bin/system/filesystems.c
+++ b/src/bin/system/filesystems.c
@@ -166,6 +166,36 @@ file_system_type_name(const char *mountpoint)
 
 #endif
 
+Eina_List *
+file_system_info_all_get(void)
+{
+# if defined(__linux__)
+   return NULL;
+# else
+   struct statfs *mounts;
+   int i, count;
+   Eina_List *list = NULL;
+
+   count = getmntinfo(&mounts, MNT_WAIT);
+   for (i = 0; i < count; i++)
+     {
+        File_System *fs = calloc(1, sizeof(File_System));
+        fs->mount = strdup(mounts[i].f_mntonname);
+        fs->path  = strdup(mounts[i].f_mntfromname);
+#if defined(__OpenBSD__)
+#else
+        fs->type  = mounts[i].f_type;
+#endif
+        fs->type_name = strdup(mounts[i].f_fstypename);
+        fs->usage.total = mounts[i].f_bsize * mounts[i].f_blocks;
+        fs->usage.used  = fs->usage.total - (mounts[i].f_bsize * 
mounts[i].f_bfree);
+
+        list = eina_list_append(list, fs);
+     }
+# endif
+   return list;
+}
+
 File_System *
 file_system_info_get(const char *path)
 {
diff --git a/src/bin/system/filesystems.h b/src/bin/system/filesystems.h
index a7d8c9f..2d201ba 100644
--- a/src/bin/system/filesystems.h
+++ b/src/bin/system/filesystems.h
@@ -22,6 +22,9 @@ file_system_name_by_id(unsigned int id);
 unsigned int
 file_system_id_by_name(const char *name);
 
+Eina_List *
+file_system_info_all_get(void);
+
 File_System *
 file_system_info_get(const char *path);
 
diff --git a/src/bin/ui/ui_disk.c b/src/bin/ui/ui_disk.c
index 0fcf639..1dcacd2 100644
--- a/src/bin/ui/ui_disk.c
+++ b/src/bin/ui/ui_disk.c
@@ -221,15 +221,15 @@ _item_disk_clicked_cb(void *data, Evas_Object *obj 
EINA_UNUSED, void *event_info
 static Eina_Bool
 _disks_poll_timer_cb(void *data)
 {
-   Eina_List *disks;
-   char *path;
    Elm_Object_Item *it;
    File_System *fs;
    Eina_List *mounted = NULL;
 
    eina_lock_take(&_lock);
 
-   disks = disks_get();
+#if defined(__linux__)
+   char *path;
+   Eina_List *disks = disks_get();
    EINA_LIST_FREE(disks, path)
      {
         fs = file_system_info_get(path);
@@ -238,6 +238,9 @@ _disks_poll_timer_cb(void *data)
 
         free(path);
      }
+#else
+   mounted = file_system_info_all_get();
+#endif
 
    if (_private_data->sort_cb)
      mounted = eina_list_sort(mounted, eina_list_count(mounted), 
_private_data->sort_cb);

-- 


Reply via email to