-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[nodefs] Return real values for statvfs via __syscall_statfs64 #22631
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Carlos Garcia <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this?
I wonder if we can/should make this working under NODERAWFS too? Or can that be a followup? I think maybe it would need to happen at the same time?
src/library_fs.js
Outdated
return defaults; | ||
} | ||
|
||
return { ...defaults, ...parent.node_ops.statfs(parent.mount.opts.root) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
var rtn = {
... // defaults
}
var parent = FS.lookupPath(path, {follow: true}).node;
if (typeof parent.node_ops?.statfs) {
Object.assign(rtn, parent.node_ops.statfs(parent.mount.opts.root));
}
return rtn;
Also, so we really need to merge the defaults with the actual results? Are we expecting backends to only paritally fill the out the information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've applied the suggested changes.
The idea behind merging the defaults it to ensure that all the required fields are always set. In the case of Node, statfs does not return all of the information:
StatFs {
type: 1397114950,
bsize: 4096,
blocks: 121938943,
bfree: 61058895,
bavail: 61058895,
files: 999,
ffree: 1000000
}
We could add the missing fields in the node_ops.statfs
but it seemed appropriate to have the FS class ensure a valid response. Im happy to change it though, what do you think?
Actually I think the |
I agree, all filesystems, besides NODEFS, should continue using the hardcoded values so we can implement the real values for the others in follow-ups. |
Looks like a test is failing:
|
@sbc100 I've taken over this task from @jeroenpf to wrap the work. I had to start a new PR to push my fix. When you have time could you please take a look at it? |
See #22607
statfs syscall functions are returning hardcoded default values which can in some cases lead to unexpected results.
This PR introduces a way for
__syscall_statfs64
to return real values if the underlying filesystem supports this. For now, I've only implemented this for the NODEFS filesystem but we can expand this to other filesystems when it makes sense.Additionally, in the previous defaults,
ffree
could be larger thanfiles
which is incorrect, this has also been addressed.Ive added a test
test/fs/test_nodefs_statfs.c
which can be executed by running:test/runner test_fs_nodefs_statfs
As I am a new contributor I'm happy to get feedback and make improvements where needed.