1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-15 19:56:55 +00:00

src/fs.{cc,h}: Update fs_stats without error spam.

This commit is contained in:
Gene Carlson 2024-09-14 13:11:09 +09:00 committed by Brenden Matthews
parent 875c1af663
commit 839602baec
3 changed files with 8 additions and 1 deletions

View File

@ -179,6 +179,7 @@ K. Eugene Carlson <kvngncrlsn at gmail dot com>
Additional Linux memory reporting variables Additional Linux memory reporting variables
Linux CPU frequency governor reporting Linux CPU frequency governor reporting
Additional FreeBSD memory reporting variables Additional FreeBSD memory reporting variables
fs_stat patch
Kapil Hari Paranjape <kapil@imsc.res.in> Kapil Hari Paranjape <kapil@imsc.res.in>
ibm_volume patch ibm_volume patch

View File

@ -79,7 +79,7 @@ int update_fs_stats() {
if (current_update_time - last_fs_update < 13) { return 0; } if (current_update_time - last_fs_update < 13) { return 0; }
for (i = 0; i < MAX_FS_STATS; ++i) { for (i = 0; i < MAX_FS_STATS; ++i) {
fs_stats[i].set = 0; if (fs_stats[i].set != 0) { update_fs_stat(&fs_stats[i]); }
} }
last_fs_update = current_update_time; last_fs_update = current_update_time;
return 0; return 0;
@ -113,6 +113,7 @@ struct fs_stat *prepare_fs_stat(const char *s) {
} }
strncpy(next->path, s, DEFAULT_TEXT_BUFFER_SIZE); strncpy(next->path, s, DEFAULT_TEXT_BUFFER_SIZE);
next->set = 1; next->set = 1;
next->errored = 0;
update_fs_stat(next); update_fs_stat(next);
return next; return next;
} }
@ -142,10 +143,14 @@ static void update_fs_stat(struct fs_stat *fs) {
/* bfree (root) or bavail (non-roots) ? */ /* bfree (root) or bavail (non-roots) ? */
fs->avail = static_cast<long long>(s.f_bavail) * s.f_bsize; fs->avail = static_cast<long long>(s.f_bavail) * s.f_bsize;
fs->free = static_cast<long long>(s.f_bfree) * s.f_bsize; fs->free = static_cast<long long>(s.f_bfree) * s.f_bsize;
fs->errored = 0;
get_fs_type(fs->path, fs->type); get_fs_type(fs->path, fs->type);
#endif #endif
} else { } else {
if (fs->errored == 0) {
NORM_ERR("statfs '%s': %s", fs->path, strerror(errno)); NORM_ERR("statfs '%s': %s", fs->path, strerror(errno));
fs->errored = 1;
}
fs->size = 0; fs->size = 0;
fs->avail = 0; fs->avail = 0;
fs->free = 0; fs->free = 0;

View File

@ -40,6 +40,7 @@ struct fs_stat {
long long avail; long long avail;
long long free; long long free;
char set; char set;
char errored;
}; };
/* forward declare to make gcc happy (fs.h <-> text_object.h include) */ /* forward declare to make gcc happy (fs.h <-> text_object.h include) */