[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,
fstatfscallsstatfs64with thechar*path pointer argument set to zero. Generally byte zero of the memory seems to be null, so whenstatfs64converts thischar*to a JS string it gets the empty string. Then it callsFS.statfswith the empty string as an argument.FS.statfscallslookupPathwith an empty string argument which returns anullnode, sofstatfsreturns 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.statfsNodeandFS.statfsStreamhandlers because in some casesstream.nodeis null and in some casesstream.pathis useless (like for stdout). Also, in noderawfs we need to give paths for the standard streams because there is unfortunately nofs.fstatfsSyncso we can only access information from the host via a path. This means the noderawfs test won't be portable to windows.