Disk Space readout reporting wrong disk size
0323pin opened this issue ยท 9 comments
Describe the bug
Disk Space readout reporting wrong disk size.
To Reproduce
Config macchina
to display DiskSpace
.
Expected behavior
Should report the correct values.
Output of df -h
:
Filesystem Size Used Avail %Cap Mounted on
/dev/wd0a 394G 9.1G 365G 2% /
tmpfs 2.4G 16K 2.4G 0% /tmp
kernfs 1.0K 1.0K 0B 100% /kern
ptyfs 1.0K 1.0K 0B 100% /dev/pts
procfs 4.0K 4.0K 0B 100% /proc
tmpfs 2.4G 7.4M 2.4G 0% /var/shm
macchina --doctor
output
We've collected a total of 12 readouts including 0 failed read(s) and 0 read(s) resulting in a warning.
๐ You are good to go! No failures detected.
System Information
- Distribution: NA
- Desktop Environment: None
- Operating System: NetBSD
- Terminal: Alacritty
- Macchina's version: 6.2.0
I also see wrong information but it's much lower than the expected value on my side.
I'd love to know if @Rolv-Apneseth could pursue his ideas in #286, the feature discussed in that ticket is really essential for the disk usage readout.
Hey! Been a while but yes I'd be happy to look into it. I did go off on a dev branch on my fork for my own personal use but I'll have a go at making a PR when I get some time
Wonderful, thanks for chiming in!
In relation to this issue, I have no idea where such a wildly inaccurate value is coming from, though the NetBSD code for reading used/total bytes does seem to differ a bit from the *nix code.
Just as a side note, df -h
gives the values in powers of 1024 but I believe macchina
uses the SI units, so powers of 1000. df --si
should be more accurate if that is the case, which it is for me.
Just as a side note, df -h gives the values in powers of 1024 but I believe macchina uses the SI units, so powers of 1000. df --si should be more accurate if that is the case, which it is for me.
Believe me, I know the difference between SI and other widely accepted units but, this is seriously wrong. I have a 365 Gb SSD being reported as 3.4 Tb
df -si
doesn't exist on NetBSD but, I can give you df -g
,
~> df -g
Filesystem 1G-blocks Used Avail %Cap Mounted on
/dev/wd0a 394 9 365 2% /
tmpfs 2 0 2 0% /tmp
kernfs 0 0 0 100% /kern
ptyfs 0 0 0 100% /dev/pts
procfs 0 0 0 100% /proc
tmpfs 2 0 2 0% /var/shm
and perhaps man df(1)
I assumed you did yes, sorry, was just mentioning in case someone searches this issue in the future for differences which might be accounted for by the units.
Didn't realise that df
would be different on NetBSD, the more you know. But from that man page I can see they just don't have the long form, df -H
should be the same on both. Irrelevant here anyway, like you said the issue is much bigger than that.
I think I know what's going on.
Rust's libc
does not have any bindings for NetBSD's statfs
syscall (https://man.netbsd.org/NetBSD-1.6/statfs.2), this can be confirmed both from the documentation of the libc
crate 1 and filtering for the statfs
keyword in the crate's source code 2.
I'm really disappointed that I didn't catch this discrepancy before porting the code. I suppose this is why @0323pin is getting "garbage" output in his disk space readout.
Footnotes
Rust's libc does not have any bindings for NetBSD's statfs syscall
That's because statfs
is a deprecated syscall that has been replaced by statvfs
on NetBSD in 2005, see statvfs(2).
Note: other OSs might still use statfs
, I know that FreeBSD and DragonFly BSD do but, on NetBSD it has been removed.
statvfs is supported, I've added this to libc
about a year ago to fix issues with the trash-rs
crate.
Alright, I'll write a working port this time.