polybar: Filesystem module displaying incorrect values

Hello,

For some reason the filesystem module of polybar is showing that the ‘/’ mount has a total size of 1.97GB and current used space of 851MB. This is with the default config (other than adding tags to display the total and used values). On the other hand, here is the output of df -h for that mountpoint:

/dev/dm-0 158G 8.9G 142G 6% /

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 28 (13 by maintainers)

Commits related to this issue

Most upvoted comments

You don’t need both packages, there were no changes to the filesystem module between polybar and polybar-git

/dev/sda1 ext4 227G 203G 203G 6%

This output for free looks weird, you have as much free space as is used

Both at the same time preferably. When you compile multiple times without each time clearing everything it should only compile the changed files, which should be a lot faster, if that works, it would be interesting to see the effects of only the second modification.

Also, can you then report the values for all three tokens (label-mounted = %total% %free% %used%)

Oh damn. I appreciate you helping use here 😃

Were you able to figure out where polybar does a wrong calculation?

Could you also try to change this line to

 mount->bytes_free = buffer.f_frsize * buffer.f_bfree;

and try if it displays the correct values?

The crash was unrelated to polybar hopefully?

We use the statvfs function (man 3 statvfs) to gather information about mounted filesystems (all the code for it is here).

I see that we are using f_frsize for some properties and f_bsize for others. Maybe that’s the issue. I suspect the integer underflow happens on line 102:

mount->bytes_used = mount->bytes_total - mount->bytes_free;

Just noticed, 16777216.00 TB converted to bytes is exactly 2^64. So we likely have some integer underflow/overflow or signed/unsigned weirdness.