-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix a bug in FS.getattr #25122
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
base: main
Are you sure you want to change the base?
fix a bug in FS.getattr #25122
Conversation
The implementation of BFS's getattr requires a 'this' and calling it without this will always fail.
src/lib/libfs.js
Outdated
@@ -983,7 +983,7 @@ FS.staticInit();`; | |||
var node = stream.node; | |||
var getattr = stream.stream_ops.getattr; | |||
var arg = getattr ? stream : node; | |||
getattr ??= node.node_ops.getattr; | |||
getattr ??= node.node_ops.getattr.bind(node.node_ops); | |||
FS.checkOpExists(getattr, {{{ cDefs.EPERM }}}) | |||
return getattr(arg); |
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 getattr.call(node.node_ops, arg)
here to avoid the temporary?
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.
The problem is that getattr
might have come from either stream.stream_ops
or node.node_ops
and so the wrong this
might break something else. I'm happy to rewrite the function, but I don't have enough experience with this project to test it thoroughly.
FS.checkOpExists(getattr, {{{ cDefs.EPERM }}}) | ||
return getattr(arg); | ||
return getattr.call(obj, arg); |
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.
@hoodmane like this?
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.
LGTM
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 think doSetAttr
needs updating too.
I guess we don't have any test coverage for this because our FS callback don't use this
.. :(
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.
Would be good to have a test.
The implementation of BFS's getattr requires a 'this' and calling it without this always fails.