Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 7 additions & 2 deletions 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 {
NORM_ERR("statfs '%s': %s", fs->path, strerror(errno));
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
Loading