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.
This commit is contained in:
parent
5404906b11
commit
4dc7109ce9
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue