Skip to content

Commit

Permalink
src/fs.{cc,h}: Update fs_stats without error spam.
Browse files Browse the repository at this point in the history
  • Loading branch information
pghvlaans authored and brndnmtthws committed Sep 15, 2024
1 parent 875c1af commit 839602b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ K. Eugene Carlson <kvngncrlsn at gmail dot com>
Additional Linux memory reporting variables
Linux CPU frequency governor reporting
Additional FreeBSD memory reporting variables
fs_stat patch

Kapil Hari Paranjape <kapil@imsc.res.in>
ibm_volume patch
Expand Down
7 changes: 6 additions & 1 deletion src/fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -142,10 +143,14 @@ static void update_fs_stat(struct fs_stat *fs) {
/* bfree (root) or bavail (non-roots) ? */
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->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;
Expand Down
1 change: 1 addition & 0 deletions src/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down

0 comments on commit 839602b

Please sign in to comment.