Skip to content

Conversation

warrenfalk
Copy link

The implementation of BFS's getattr requires a 'this' and calling it without this always fails.

image

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);
Copy link
Collaborator

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?

Copy link
Author

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);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hoodmane like this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

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.. :(

@warrenfalk warrenfalk requested a review from hoodmane August 31, 2025 16:18
Copy link
Collaborator

@hoodmane hoodmane left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants