-
Notifications
You must be signed in to change notification settings - Fork 30
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
does not produce accurate numbers #5
Comments
@drrob1 This library is actually a very thin wrapper around the following code:
This probably means one of the following:
Could you post the code you are using? |
package main |
Of course, the site removed my indentations. But gofmt would restore those, I guess. I never tested it on windows, though I did write code to be able to. |
@drrob1 I'm not sure if you meant to close this issue or not, but I thought I'd reply anyway. I was able to reproduce you results on CentOS 7 running on WSL. The numbers are close, but not exact. I'm not an expert at df so I can't speak to what exactly the numbers are reported. However, I did verify that the results from this code in go
closely resembles this code in c
There are differences in the lower order bits from run to run but both programs produce very similar results. This is not surprising because I believe go calls statfs under the covers. The math for calculating the results is pretty straightforward using those results. |
My point is that the usage.Free() returned from the Go function is off by 3 orders of magnitude from the output of the linux df command. So I don't understand what you are saying And I did not intend to close the issue. I must have clicked on the wrong thing. |
I have a WSL system so it was a little difficult to test your code directly because I don't know how devices like /dev/sda1 apply. I got a hold of a native centos 7 machine and ran your code and replicated your results. This library as written expects a path and not a device. Which is to say it needs "/" not "/dev/sda1". This is because this library uses https://pkg.go.dev/syscall#Statfs which requires a path. I can look into updating the library to something like https://pkg.go.dev/syscall#Fstatfs but I'd need to investigate and think through this to make sure I don't break live code depending on this functionality. If this goes as expected I'll add this soon... |
I want to add that there needs to be a way to not follow other
filesystems that are mounted, perhaps by not following any symlinks or
mount points
Like the linux command "du --one-file-system"
…--rob
On 7/21/21 6:46 PM, Rick Smith wrote:
I have a WSL system so it was a little difficult to test your code
directly because I don't know how devices like /dev/sda1 apply. I got
a hold of a native centos 7 machine and ran your code and replicated
your results.
This library as written expects a path and not a device. Which is to
say it needs "/" not "/dev/sda1". This is because this library uses
https://pkg.go.dev/syscall#Statfs <https://pkg.go.dev/syscall#Statfs>
which requires a path. I can look into updating the library to
something like https://pkg.go.dev/syscall#Fstatfs
<https://pkg.go.dev/syscall#Fstatfs> but I'd need to investigate and
think through this to make sure I don't break live code depending on
this functionality. If this goes as expected I'll add this soon...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEDMFBUJP3RRK7NWNOUWC43TY5E3RANCNFSM426EJL7Q>.
|
On Ubuntu 20.04, the numbers it produces are all the same. IE, Free(), Available(), Size() and Used() all produce the same output.
These numbers do not match the output of the df command at all. I'm currently using a script that uses
$(df -k --output=avail /dev/sda1 | tail -n1)
I have kernel 5.8.0.7642-generic
The text was updated successfully, but these errors were encountered: