-
-
Notifications
You must be signed in to change notification settings - Fork 756
core:os
package read_entire_file_xxx
procedures don't work on /proc
filesystem even if on a Linux system
#4264
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
Comments
core:os
package read_entire_file_xxx
procedures doesn't work on /proc
filesystem even if I'm on a Linux systemcore:os
package read_entire_file_xxx
procedures don't work on /proc
filesystem even if on a Linux system
Some relevant info about the bug: The Lines 144 to 147 in 8814170
The issue is that 0-sized files can contain information too, seems like that's a quirk of the
Which seems to suggest that reading a file by first asking for its length is wrong on linux. At least with input streams ( Prompting @laytan, @Yawning to join this discussion, as I don't think it's a trivial fix. Since from what I know we can't tell these files from other regular files (aside from the name, which is unreliable, because we might not have that), my suggestion for the fix is making |
A complete example: package bug
import "core:fmt"
import "core:os"
main :: proc() {
data, err := os.read_entire_file_or_err("/proc/meminfo")
fmt.println(data, err)
} |
Use |
Isn't this fixed in os2? I think we stat there and if it returns size 0 we read into a buffer in chunks instead of all at once. May want to do that here too. |
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
Expected Behavior
os.read_entire_file
and fellow procedures should be able to read/proc
files such as/proc/meminfo
.Current Behavior
os.read_entire_file
procedures don't return error but will only return an empty slice.Failure Information (for bugs)
Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
The text was updated successfully, but these errors were encountered: