fbsd: fs type name.

This commit is contained in:
Alastair Poole 2020-06-08 11:23:12 +01:00
parent 86d7f2adda
commit ed267ba555
2 changed files with 10 additions and 4 deletions

View File

@ -107,19 +107,20 @@ static _magic _magique[] = {
unsigned int
filesystem_id_by_name(const char *name)
{
for (int i = 0; i < sizeof(_magique); i++)
size_t n = sizeof(_magique) / sizeof(_magic);
for (int i = 0; i < n; i++)
{
if (!strcasecmp(name, _magique[i].name))
return _magique[i].magic;
}
return 0;
}
const char *
filesystem_name_by_id(unsigned int id)
{
for (int i = 0; i < sizeof(_magique); i++)
size_t n = sizeof(_magique) / sizeof(_magic);
for (int i = 0; i < n; i++)
{
if (_magique[i].magic == id)
return _magique[i].name;
@ -144,6 +145,9 @@ filesystem_info_get(const char *path)
fs->mount = strdup(mountpoint);
fs->path = strdup(path);
fs->type = stats.f_type;
#if defined(__FreeBSD__) || defined(__DragonFly__)
fs->type_name = strdup(stats.f_fstypename);
#endif
fs->usage.total = stats.f_bsize * stats.f_blocks;
fs->usage.used = fs->usage.total - (stats.f_bsize * stats.f_bfree);

View File

@ -44,7 +44,9 @@ _ui_disk_add(Ui *ui, Filesystem_Info *inf)
const char *type;
double ratio, value;
type = filesystem_name_by_id(inf->type);
type = inf->type_name;
if (!type)
type = filesystem_name_by_id(inf->type);
if (!type) type = "unknown";
box = elm_box_add(ui->disk_activity);