From c05f26469b43b38e7fec27da8c29f507585a99d9 Mon Sep 17 00:00:00 2001 From: Gene Carlson Date: Sat, 14 Sep 2024 13:11:09 +0900 Subject: [PATCH 1/2] src/fs.{cc,h}: Update fs_stats without error spam. --- AUTHORS | 1 + src/fs.cc | 7 ++++++- src/fs.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index cb4774e32..51173ca61 100644 --- a/AUTHORS +++ b/AUTHORS @@ -179,6 +179,7 @@ K. Eugene Carlson Additional Linux memory reporting variables Linux CPU frequency governor reporting Additional FreeBSD memory reporting variables + fs_stat patch Kapil Hari Paranjape ibm_volume patch diff --git a/src/fs.cc b/src/fs.cc index 7593d9947..2a064846e 100644 --- a/src/fs.cc +++ b/src/fs.cc @@ -79,7 +79,7 @@ int update_fs_stats() { if (current_update_time - last_fs_update < 13) { return 0; } 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; return 0; @@ -113,6 +113,7 @@ struct fs_stat *prepare_fs_stat(const char *s) { } strncpy(next->path, s, DEFAULT_TEXT_BUFFER_SIZE); next->set = 1; + next->errored = 0; update_fs_stat(next); return next; } @@ -142,10 +143,14 @@ static void update_fs_stat(struct fs_stat *fs) { /* bfree (root) or bavail (non-roots) ? */ fs->avail = static_cast(s.f_bavail) * s.f_bsize; fs->free = static_cast(s.f_bfree) * s.f_bsize; + fs->errored = 0; get_fs_type(fs->path, fs->type); #endif } else { + if (fs->errored == 0) { NORM_ERR("statfs '%s': %s", fs->path, strerror(errno)); + fs->errored = 1; + } fs->size = 0; fs->avail = 0; fs->free = 0; diff --git a/src/fs.h b/src/fs.h index 16bcafcb1..41d3a4d33 100644 --- a/src/fs.h +++ b/src/fs.h @@ -40,6 +40,7 @@ struct fs_stat { long long avail; long long free; char set; + char errored; }; /* forward declare to make gcc happy (fs.h <-> text_object.h include) */ From cf4f9af42ef9b311ab9a83ea02453d1796e1803f Mon Sep 17 00:00:00 2001 From: Gene Carlson Date: Sat, 14 Sep 2024 14:14:27 +0900 Subject: [PATCH 2/2] src/fs.cc: Fix whitespace mistake. --- src/fs.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fs.cc b/src/fs.cc index 2a064846e..964e82fd0 100644 --- a/src/fs.cc +++ b/src/fs.cc @@ -147,10 +147,10 @@ static void update_fs_stat(struct fs_stat *fs) { get_fs_type(fs->path, fs->type); #endif } else { - if (fs->errored == 0) { - NORM_ERR("statfs '%s': %s", fs->path, strerror(errno)); - fs->errored = 1; - } + if (fs->errored == 0) { + NORM_ERR("statfs '%s': %s", fs->path, strerror(errno)); + fs->errored = 1; + } fs->size = 0; fs->avail = 0; fs->free = 0;