[FS] Make fstatfs actually work #23381
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prior to this change,
fstatfs
callsstatfs64
with thechar*
path pointer argument set to zero. Generally byte zero of the memory seems to be null, so whenstatfs64
converts thischar*
to a JS string it gets the empty string. Then it callsFS.statfs
with the empty string as an argument.FS.statfs
callslookupPath
with an empty string argument which returns anull
node, sofstatfs
returns the default values for when there is no statfs handler in the files system.This fixes the problem and adds testing for statfs/fstatfs on nodefs and rawfs. We have to add separate
FS.statfsNode
andFS.statfsStream
handlers because in some casesstream.node
is null and in some casesstream.path
is useless (like for stdout). Also, in noderawfs we need to give paths for the standard streams because there is unfortunately nofs.fstatfsSync
so we can only access information from the host via a path. This means the noderawfs test won't be portable to windows.