netstar pushed a commit to branch master. http://git.enlightenment.org/apps/evisum.git/commit/?id=4dc7109ce96fa642e58845e2f3d6f33cb3f4e512
commit 4dc7109ce96fa642e58845e2f3d6f33cb3f4e512 Author: Alastair Poole <[email protected]> Date: Sun Jun 7 12:17:03 2020 +0100 disks: abstract disks. We need to be able to know which maniac is using ZFS or some other weird filesystem that is going to munch as much RAM as possible before we report it as used... fs type is useful too...will need a mapping to the super block magic listing. --- src/bin/system/disks.c | 29 +++++++++++++++++++++++------ src/bin/system/disks.h | 19 +++++++++++++++++-- src/bin/ui/ui_disk.c | 12 ++++-------- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/src/bin/system/disks.c b/src/bin/system/disks.c index dde7012..71346b1 100644 --- a/src/bin/system/disks.c +++ b/src/bin/system/disks.c @@ -80,18 +80,35 @@ disk_mount_point_get(const char *path) return NULL; } -Eina_Bool -disk_usage_get(const char *mountpoint, unsigned long *total, unsigned long *used) +File_System * +disk_mount_file_system_get(const char *path) { + File_System *fs; + const char *mountpoint; struct statfs stats; + mountpoint = disk_mount_point_get(path); + if (!mountpoint) return NULL; + if (statfs(mountpoint, &stats) < 0) - return EINA_FALSE; + return NULL; - *total = stats.f_bsize * stats.f_blocks; - *used = *total - (stats.f_bsize * stats.f_bfree); + fs = calloc(1, sizeof(File_System)); + fs->mount = strdup(mountpoint); + fs->path = strdup(path); + fs->type = stats.f_type; + fs->usage.total = stats.f_bsize * stats.f_blocks; + fs->usage.used = fs->usage.total - (stats.f_bsize * stats.f_bfree); - return EINA_TRUE; + return fs; +} + +void +disk_mount_file_system_free(File_System *fs) +{ + free(fs->mount); + free(fs->path); + free(fs); } static int diff --git a/src/bin/system/disks.h b/src/bin/system/disks.h index c212e30..0aec7f0 100644 --- a/src/bin/system/disks.h +++ b/src/bin/system/disks.h @@ -4,8 +4,23 @@ #include <Eina.h> #include <Ecore.h> -Eina_Bool -disk_usage_get(const char *mountpoint, unsigned long *total, unsigned long *used); +typedef struct _Disk_Usage { + unsigned long total; + unsigned long used; +} Disk_Usage; + +typedef struct _File_System { + char *path; + char *mount; + unsigned int type; + Disk_Usage usage; +} File_System; + +File_System * +disk_mount_file_system_get(const char *path); + +void +disk_mount_file_system_free(File_System *fs); char * disk_mount_point_get(const char *path); diff --git a/src/bin/ui/ui_disk.c b/src/bin/ui/ui_disk.c index 80041c5..77cfbfa 100644 --- a/src/bin/ui/ui_disk.c +++ b/src/bin/ui/ui_disk.c @@ -91,7 +91,6 @@ ui_tab_disk_update(Ui *ui) { Eina_List *disks; char *path; - unsigned long total, used; if (!ui->disk_visible) return; @@ -101,14 +100,11 @@ ui_tab_disk_update(Ui *ui) disks = disks_get(); EINA_LIST_FREE(disks, path) { - char *mount = disk_mount_point_get(path); - if (mount) + File_System *fs = disk_mount_file_system_get(path); + if (fs) { - if (disk_usage_get(mount, &total, &used)) - { - _ui_disk_add(ui, path, mount, total, used); - } - free(mount); + _ui_disk_add(ui, fs->path, fs->mount, fs->usage.total, fs->usage.used); + disk_mount_file_system_free(fs); } free(path); } --
